babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467
  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. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate 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. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * 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.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * 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.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * 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).
  4312. * 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.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @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.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** 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 */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** 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 */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** 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 */
  4473. static readonly GEQUAL: number;
  4474. /** 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 */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * 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.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @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
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. 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);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** 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 */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Animations/runtimeAnimation" {
  6777. import { Animation } from "babylonjs/Animations/animation";
  6778. import { Animatable } from "babylonjs/Animations/animatable";
  6779. import { Scene } from "babylonjs/scene";
  6780. /**
  6781. * Defines a runtime animation
  6782. */
  6783. export class RuntimeAnimation {
  6784. private _events;
  6785. /**
  6786. * The current frame of the runtime animation
  6787. */
  6788. private _currentFrame;
  6789. /**
  6790. * The animation used by the runtime animation
  6791. */
  6792. private _animation;
  6793. /**
  6794. * The target of the runtime animation
  6795. */
  6796. private _target;
  6797. /**
  6798. * The initiating animatable
  6799. */
  6800. private _host;
  6801. /**
  6802. * The original value of the runtime animation
  6803. */
  6804. private _originalValue;
  6805. /**
  6806. * The original blend value of the runtime animation
  6807. */
  6808. private _originalBlendValue;
  6809. /**
  6810. * The offsets cache of the runtime animation
  6811. */
  6812. private _offsetsCache;
  6813. /**
  6814. * The high limits cache of the runtime animation
  6815. */
  6816. private _highLimitsCache;
  6817. /**
  6818. * Specifies if the runtime animation has been stopped
  6819. */
  6820. private _stopped;
  6821. /**
  6822. * The blending factor of the runtime animation
  6823. */
  6824. private _blendingFactor;
  6825. /**
  6826. * The BabylonJS scene
  6827. */
  6828. private _scene;
  6829. /**
  6830. * The current value of the runtime animation
  6831. */
  6832. private _currentValue;
  6833. /** @hidden */
  6834. _workValue: any;
  6835. /**
  6836. * The active target of the runtime animation
  6837. */
  6838. private _activeTarget;
  6839. /**
  6840. * The target path of the runtime animation
  6841. */
  6842. private _targetPath;
  6843. /**
  6844. * The weight of the runtime animation
  6845. */
  6846. private _weight;
  6847. /**
  6848. * The ratio offset of the runtime animation
  6849. */
  6850. private _ratioOffset;
  6851. /**
  6852. * The previous delay of the runtime animation
  6853. */
  6854. private _previousDelay;
  6855. /**
  6856. * The previous ratio of the runtime animation
  6857. */
  6858. private _previousRatio;
  6859. /**
  6860. * Gets the current frame of the runtime animation
  6861. */
  6862. readonly currentFrame: number;
  6863. /**
  6864. * Gets the weight of the runtime animation
  6865. */
  6866. readonly weight: number;
  6867. /**
  6868. * Gets the current value of the runtime animation
  6869. */
  6870. readonly currentValue: any;
  6871. /**
  6872. * Gets the target path of the runtime animation
  6873. */
  6874. readonly targetPath: string;
  6875. /**
  6876. * Gets the actual target of the runtime animation
  6877. */
  6878. readonly target: any;
  6879. /**
  6880. * Create a new RuntimeAnimation object
  6881. * @param target defines the target of the animation
  6882. * @param animation defines the source animation object
  6883. * @param scene defines the hosting scene
  6884. * @param host defines the initiating Animatable
  6885. */
  6886. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6887. /**
  6888. * Gets the animation from the runtime animation
  6889. */
  6890. readonly animation: Animation;
  6891. /**
  6892. * Resets the runtime animation to the beginning
  6893. * @param restoreOriginal defines whether to restore the target property to the original value
  6894. */
  6895. reset(restoreOriginal?: boolean): void;
  6896. /**
  6897. * Specifies if the runtime animation is stopped
  6898. * @returns Boolean specifying if the runtime animation is stopped
  6899. */
  6900. isStopped(): boolean;
  6901. /**
  6902. * Disposes of the runtime animation
  6903. */
  6904. dispose(): void;
  6905. /**
  6906. * Interpolates the animation from the current frame
  6907. * @param currentFrame The frame to interpolate the animation to
  6908. * @param repeatCount The number of times that the animation should loop
  6909. * @param loopMode The type of looping mode to use
  6910. * @param offsetValue Animation offset value
  6911. * @param highLimitValue The high limit value
  6912. * @returns The interpolated value
  6913. */
  6914. private _interpolate;
  6915. /**
  6916. * Apply the interpolated value to the target
  6917. * @param currentValue defines the value computed by the animation
  6918. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6919. */
  6920. setValue(currentValue: any, weight?: number): void;
  6921. private _setValue;
  6922. /**
  6923. * Gets the loop pmode of the runtime animation
  6924. * @returns Loop Mode
  6925. */
  6926. private _getCorrectLoopMode;
  6927. /**
  6928. * Move the current animation to a given frame
  6929. * @param frame defines the frame to move to
  6930. */
  6931. goToFrame(frame: number): void;
  6932. /**
  6933. * @hidden Internal use only
  6934. */
  6935. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6936. /**
  6937. * Execute the current animation
  6938. * @param delay defines the delay to add to the current frame
  6939. * @param from defines the lower bound of the animation range
  6940. * @param to defines the upper bound of the animation range
  6941. * @param loop defines if the current animation must loop
  6942. * @param speedRatio defines the current speed ratio
  6943. * @param weight defines the weight of the animation (default is -1 so no weight)
  6944. * @param onLoop optional callback called when animation loops
  6945. * @returns a boolean indicating if the animation is running
  6946. */
  6947. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6948. }
  6949. }
  6950. declare module "babylonjs/Collisions/intersectionInfo" {
  6951. import { Nullable } from "babylonjs/types";
  6952. /**
  6953. * @hidden
  6954. */
  6955. export class IntersectionInfo {
  6956. bu: Nullable<number>;
  6957. bv: Nullable<number>;
  6958. distance: number;
  6959. faceId: number;
  6960. subMeshId: number;
  6961. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingSphere" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6967. /**
  6968. * Class used to store bounding sphere information
  6969. */
  6970. export class BoundingSphere {
  6971. /**
  6972. * Gets the center of the bounding sphere in local space
  6973. */
  6974. readonly center: Vector3;
  6975. /**
  6976. * Radius of the bounding sphere in local space
  6977. */
  6978. radius: number;
  6979. /**
  6980. * Gets the center of the bounding sphere in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Radius of the bounding sphere in world space
  6985. */
  6986. radiusWorld: number;
  6987. /**
  6988. * Gets the minimum vector in local space
  6989. */
  6990. readonly minimum: Vector3;
  6991. /**
  6992. * Gets the maximum vector in local space
  6993. */
  6994. readonly maximum: Vector3;
  6995. private _worldMatrix;
  6996. private static readonly TmpVector3;
  6997. /**
  6998. * Creates a new bounding sphere
  6999. * @param min defines the minimum vector (in local space)
  7000. * @param max defines the maximum vector (in local space)
  7001. * @param worldMatrix defines the new world matrix
  7002. */
  7003. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7004. /**
  7005. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7006. * @param min defines the new minimum vector (in local space)
  7007. * @param max defines the new maximum vector (in local space)
  7008. * @param worldMatrix defines the new world matrix
  7009. */
  7010. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7011. /**
  7012. * Scale the current bounding sphere by applying a scale factor
  7013. * @param factor defines the scale factor to apply
  7014. * @returns the current bounding box
  7015. */
  7016. scale(factor: number): BoundingSphere;
  7017. /**
  7018. * Gets the world matrix of the bounding box
  7019. * @returns a matrix
  7020. */
  7021. getWorldMatrix(): DeepImmutable<Matrix>;
  7022. /** @hidden */
  7023. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7024. /**
  7025. * Tests if the bounding sphere is intersecting the frustum planes
  7026. * @param frustumPlanes defines the frustum planes to test
  7027. * @returns true if there is an intersection
  7028. */
  7029. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7030. /**
  7031. * Tests if the bounding sphere center is in between the frustum planes.
  7032. * Used for optimistic fast inclusion.
  7033. * @param frustumPlanes defines the frustum planes to test
  7034. * @returns true if the sphere center is in between the frustum planes
  7035. */
  7036. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7037. /**
  7038. * Tests if a point is inside the bounding sphere
  7039. * @param point defines the point to test
  7040. * @returns true if the point is inside the bounding sphere
  7041. */
  7042. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7043. /**
  7044. * Checks if two sphere intersct
  7045. * @param sphere0 sphere 0
  7046. * @param sphere1 sphere 1
  7047. * @returns true if the speres intersect
  7048. */
  7049. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7050. }
  7051. }
  7052. declare module "babylonjs/Culling/boundingBox" {
  7053. import { DeepImmutable } from "babylonjs/types";
  7054. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7055. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7056. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7057. /**
  7058. * Class used to store bounding box information
  7059. */
  7060. export class BoundingBox implements ICullable {
  7061. /**
  7062. * Gets the 8 vectors representing the bounding box in local space
  7063. */
  7064. readonly vectors: Vector3[];
  7065. /**
  7066. * Gets the center of the bounding box in local space
  7067. */
  7068. readonly center: Vector3;
  7069. /**
  7070. * Gets the center of the bounding box in world space
  7071. */
  7072. readonly centerWorld: Vector3;
  7073. /**
  7074. * Gets the extend size in local space
  7075. */
  7076. readonly extendSize: Vector3;
  7077. /**
  7078. * Gets the extend size in world space
  7079. */
  7080. readonly extendSizeWorld: Vector3;
  7081. /**
  7082. * Gets the OBB (object bounding box) directions
  7083. */
  7084. readonly directions: Vector3[];
  7085. /**
  7086. * Gets the 8 vectors representing the bounding box in world space
  7087. */
  7088. readonly vectorsWorld: Vector3[];
  7089. /**
  7090. * Gets the minimum vector in world space
  7091. */
  7092. readonly minimumWorld: Vector3;
  7093. /**
  7094. * Gets the maximum vector in world space
  7095. */
  7096. readonly maximumWorld: Vector3;
  7097. /**
  7098. * Gets the minimum vector in local space
  7099. */
  7100. readonly minimum: Vector3;
  7101. /**
  7102. * Gets the maximum vector in local space
  7103. */
  7104. readonly maximum: Vector3;
  7105. private _worldMatrix;
  7106. private static readonly TmpVector3;
  7107. /**
  7108. * @hidden
  7109. */
  7110. _tag: number;
  7111. /**
  7112. * Creates a new bounding box
  7113. * @param min defines the minimum vector (in local space)
  7114. * @param max defines the maximum vector (in local space)
  7115. * @param worldMatrix defines the new world matrix
  7116. */
  7117. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7118. /**
  7119. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7120. * @param min defines the new minimum vector (in local space)
  7121. * @param max defines the new maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7125. /**
  7126. * Scale the current bounding box by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding box
  7129. */
  7130. scale(factor: number): BoundingBox;
  7131. /**
  7132. * Gets the world matrix of the bounding box
  7133. * @returns a matrix
  7134. */
  7135. getWorldMatrix(): DeepImmutable<Matrix>;
  7136. /** @hidden */
  7137. _update(world: DeepImmutable<Matrix>): void;
  7138. /**
  7139. * Tests if the bounding box is intersecting the frustum planes
  7140. * @param frustumPlanes defines the frustum planes to test
  7141. * @returns true if there is an intersection
  7142. */
  7143. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7144. /**
  7145. * Tests if the bounding box is entirely inside the frustum planes
  7146. * @param frustumPlanes defines the frustum planes to test
  7147. * @returns true if there is an inclusion
  7148. */
  7149. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7150. /**
  7151. * Tests if a point is inside the bounding box
  7152. * @param point defines the point to test
  7153. * @returns true if the point is inside the bounding box
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Tests if the bounding box intersects with a bounding sphere
  7158. * @param sphere defines the sphere to test
  7159. * @returns true if there is an intersection
  7160. */
  7161. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7162. /**
  7163. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7164. * @param min defines the min vector to use
  7165. * @param max defines the max vector to use
  7166. * @returns true if there is an intersection
  7167. */
  7168. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7169. /**
  7170. * Tests if two bounding boxes are intersections
  7171. * @param box0 defines the first box to test
  7172. * @param box1 defines the second box to test
  7173. * @returns true if there is an intersection
  7174. */
  7175. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7176. /**
  7177. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7178. * @param minPoint defines the minimum vector of the bounding box
  7179. * @param maxPoint defines the maximum vector of the bounding box
  7180. * @param sphereCenter defines the sphere center
  7181. * @param sphereRadius defines the sphere radius
  7182. * @returns true if there is an intersection
  7183. */
  7184. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7185. /**
  7186. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7187. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7188. * @param frustumPlanes defines the frustum planes to test
  7189. * @return true if there is an inclusion
  7190. */
  7191. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /**
  7193. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7195. * @param frustumPlanes defines the frustum planes to test
  7196. * @return true if there is an intersection
  7197. */
  7198. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. }
  7200. }
  7201. declare module "babylonjs/Collisions/collider" {
  7202. import { Nullable, IndicesArray } from "babylonjs/types";
  7203. import { Vector3, Plane } from "babylonjs/Maths/math";
  7204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7205. /** @hidden */
  7206. export class Collider {
  7207. /** Define if a collision was found */
  7208. collisionFound: boolean;
  7209. /**
  7210. * Define last intersection point in local space
  7211. */
  7212. intersectionPoint: Vector3;
  7213. /**
  7214. * Define last collided mesh
  7215. */
  7216. collidedMesh: Nullable<AbstractMesh>;
  7217. private _collisionPoint;
  7218. private _planeIntersectionPoint;
  7219. private _tempVector;
  7220. private _tempVector2;
  7221. private _tempVector3;
  7222. private _tempVector4;
  7223. private _edge;
  7224. private _baseToVertex;
  7225. private _destinationPoint;
  7226. private _slidePlaneNormal;
  7227. private _displacementVector;
  7228. /** @hidden */
  7229. _radius: Vector3;
  7230. /** @hidden */
  7231. _retry: number;
  7232. private _velocity;
  7233. private _basePoint;
  7234. private _epsilon;
  7235. /** @hidden */
  7236. _velocityWorldLength: number;
  7237. /** @hidden */
  7238. _basePointWorld: Vector3;
  7239. private _velocityWorld;
  7240. private _normalizedVelocity;
  7241. /** @hidden */
  7242. _initialVelocity: Vector3;
  7243. /** @hidden */
  7244. _initialPosition: Vector3;
  7245. private _nearestDistance;
  7246. private _collisionMask;
  7247. collisionMask: number;
  7248. /**
  7249. * Gets the plane normal used to compute the sliding response (in local space)
  7250. */
  7251. readonly slidePlaneNormal: Vector3;
  7252. /** @hidden */
  7253. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7254. /** @hidden */
  7255. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7256. /** @hidden */
  7257. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7258. /** @hidden */
  7259. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7260. /** @hidden */
  7261. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7262. /** @hidden */
  7263. _getResponse(pos: Vector3, vel: Vector3): void;
  7264. }
  7265. }
  7266. declare module "babylonjs/Culling/boundingInfo" {
  7267. import { DeepImmutable } from "babylonjs/types";
  7268. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7269. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7270. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7271. import { Collider } from "babylonjs/Collisions/collider";
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. readonly minimum: Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. readonly maximum: Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. isLocked: boolean;
  7331. /**
  7332. * Updates the bounding sphere and box
  7333. * @param world world matrix to be used to update
  7334. */
  7335. update(world: DeepImmutable<Matrix>): void;
  7336. /**
  7337. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7338. * @param center New center of the bounding info
  7339. * @param extend New extend of the bounding info
  7340. * @returns the current bounding info
  7341. */
  7342. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7343. /**
  7344. * Scale the current bounding info by applying a scale factor
  7345. * @param factor defines the scale factor to apply
  7346. * @returns the current bounding info
  7347. */
  7348. scale(factor: number): BoundingInfo;
  7349. /**
  7350. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7351. * @param frustumPlanes defines the frustum to test
  7352. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7353. * @returns true if the bounding info is in the frustum planes
  7354. */
  7355. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7356. /**
  7357. * Gets the world distance between the min and max points of the bounding box
  7358. */
  7359. readonly diagonalLength: number;
  7360. /**
  7361. * Checks if a cullable object (mesh...) is in the camera frustum
  7362. * Unlike isInFrustum this cheks the full bounding box
  7363. * @param frustumPlanes Camera near/planes
  7364. * @returns true if the object is in frustum otherwise false
  7365. */
  7366. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7367. /** @hidden */
  7368. _checkCollision(collider: Collider): boolean;
  7369. /**
  7370. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7371. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7372. * @param point the point to check intersection with
  7373. * @returns if the point intersects
  7374. */
  7375. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7376. /**
  7377. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7378. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7379. * @param boundingInfo the bounding info to check intersection with
  7380. * @param precise if the intersection should be done using OBB
  7381. * @returns if the bounding info intersects
  7382. */
  7383. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7384. }
  7385. }
  7386. declare module "babylonjs/Misc/smartArray" {
  7387. /**
  7388. * Defines an array and its length.
  7389. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7390. */
  7391. export interface ISmartArrayLike<T> {
  7392. /**
  7393. * The data of the array.
  7394. */
  7395. data: Array<T>;
  7396. /**
  7397. * The active length of the array.
  7398. */
  7399. length: number;
  7400. }
  7401. /**
  7402. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7403. */
  7404. export class SmartArray<T> implements ISmartArrayLike<T> {
  7405. /**
  7406. * The full set of data from the array.
  7407. */
  7408. data: Array<T>;
  7409. /**
  7410. * The active length of the array.
  7411. */
  7412. length: number;
  7413. protected _id: number;
  7414. /**
  7415. * Instantiates a Smart Array.
  7416. * @param capacity defines the default capacity of the array.
  7417. */
  7418. constructor(capacity: number);
  7419. /**
  7420. * Pushes a value at the end of the active data.
  7421. * @param value defines the object to push in the array.
  7422. */
  7423. push(value: T): void;
  7424. /**
  7425. * Iterates over the active data and apply the lambda to them.
  7426. * @param func defines the action to apply on each value.
  7427. */
  7428. forEach(func: (content: T) => void): void;
  7429. /**
  7430. * Sorts the full sets of data.
  7431. * @param compareFn defines the comparison function to apply.
  7432. */
  7433. sort(compareFn: (a: T, b: T) => number): void;
  7434. /**
  7435. * Resets the active data to an empty array.
  7436. */
  7437. reset(): void;
  7438. /**
  7439. * Releases all the data from the array as well as the array.
  7440. */
  7441. dispose(): void;
  7442. /**
  7443. * Concats the active data with a given array.
  7444. * @param array defines the data to concatenate with.
  7445. */
  7446. concat(array: any): void;
  7447. /**
  7448. * Returns the position of a value in the active data.
  7449. * @param value defines the value to find the index for
  7450. * @returns the index if found in the active data otherwise -1
  7451. */
  7452. indexOf(value: T): number;
  7453. /**
  7454. * Returns whether an element is part of the active data.
  7455. * @param value defines the value to look for
  7456. * @returns true if found in the active data otherwise false
  7457. */
  7458. contains(value: T): boolean;
  7459. private static _GlobalId;
  7460. }
  7461. /**
  7462. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7463. * The data in this array can only be present once
  7464. */
  7465. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7466. private _duplicateId;
  7467. /**
  7468. * Pushes a value at the end of the active data.
  7469. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7470. * @param value defines the object to push in the array.
  7471. */
  7472. push(value: T): void;
  7473. /**
  7474. * Pushes a value at the end of the active data.
  7475. * If the data is already present, it won t be added again
  7476. * @param value defines the object to push in the array.
  7477. * @returns true if added false if it was already present
  7478. */
  7479. pushNoDuplicate(value: T): boolean;
  7480. /**
  7481. * Resets the active data to an empty array.
  7482. */
  7483. reset(): void;
  7484. /**
  7485. * Concats the active data with a given array.
  7486. * This ensures no dupplicate will be present in the result.
  7487. * @param array defines the data to concatenate with.
  7488. */
  7489. concatWithNoDuplicate(array: any): void;
  7490. }
  7491. }
  7492. declare module "babylonjs/Materials/multiMaterial" {
  7493. import { Nullable } from "babylonjs/types";
  7494. import { Scene } from "babylonjs/scene";
  7495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7496. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7498. import { Material } from "babylonjs/Materials/material";
  7499. /**
  7500. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7501. * separate meshes. This can be use to improve performances.
  7502. * @see http://doc.babylonjs.com/how_to/multi_materials
  7503. */
  7504. export class MultiMaterial extends Material {
  7505. private _subMaterials;
  7506. /**
  7507. * Gets or Sets the list of Materials used within the multi material.
  7508. * They need to be ordered according to the submeshes order in the associated mesh
  7509. */
  7510. subMaterials: Nullable<Material>[];
  7511. /**
  7512. * Function used to align with Node.getChildren()
  7513. * @returns the list of Materials used within the multi material
  7514. */
  7515. getChildren(): Nullable<Material>[];
  7516. /**
  7517. * Instantiates a new Multi Material
  7518. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7519. * separate meshes. This can be use to improve performances.
  7520. * @see http://doc.babylonjs.com/how_to/multi_materials
  7521. * @param name Define the name in the scene
  7522. * @param scene Define the scene the material belongs to
  7523. */
  7524. constructor(name: string, scene: Scene);
  7525. private _hookArray;
  7526. /**
  7527. * Get one of the submaterial by its index in the submaterials array
  7528. * @param index The index to look the sub material at
  7529. * @returns The Material if the index has been defined
  7530. */
  7531. getSubMaterial(index: number): Nullable<Material>;
  7532. /**
  7533. * Get the list of active textures for the whole sub materials list.
  7534. * @returns All the textures that will be used during the rendering
  7535. */
  7536. getActiveTextures(): BaseTexture[];
  7537. /**
  7538. * Gets the current class name of the material e.g. "MultiMaterial"
  7539. * Mainly use in serialization.
  7540. * @returns the class name
  7541. */
  7542. getClassName(): string;
  7543. /**
  7544. * Checks if the material is ready to render the requested sub mesh
  7545. * @param mesh Define the mesh the submesh belongs to
  7546. * @param subMesh Define the sub mesh to look readyness for
  7547. * @param useInstances Define whether or not the material is used with instances
  7548. * @returns true if ready, otherwise false
  7549. */
  7550. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7551. /**
  7552. * Clones the current material and its related sub materials
  7553. * @param name Define the name of the newly cloned material
  7554. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7555. * @returns the cloned material
  7556. */
  7557. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7558. /**
  7559. * Serializes the materials into a JSON representation.
  7560. * @returns the JSON representation
  7561. */
  7562. serialize(): any;
  7563. /**
  7564. * Dispose the material and release its associated resources
  7565. * @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)
  7566. * @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)
  7567. * @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)
  7568. */
  7569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7570. /**
  7571. * Creates a MultiMaterial from parsed MultiMaterial data.
  7572. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7573. * @param scene defines the hosting scene
  7574. * @returns a new MultiMaterial
  7575. */
  7576. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7577. }
  7578. }
  7579. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7580. /**
  7581. * Class used to represent data loading progression
  7582. */
  7583. export class SceneLoaderFlags {
  7584. private static _ForceFullSceneLoadingForIncremental;
  7585. private static _ShowLoadingScreen;
  7586. private static _CleanBoneMatrixWeights;
  7587. private static _loggingLevel;
  7588. /**
  7589. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7590. */
  7591. static ForceFullSceneLoadingForIncremental: boolean;
  7592. /**
  7593. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7594. */
  7595. static ShowLoadingScreen: boolean;
  7596. /**
  7597. * Defines the current logging level (while loading the scene)
  7598. * @ignorenaming
  7599. */
  7600. static loggingLevel: number;
  7601. /**
  7602. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7603. */
  7604. static CleanBoneMatrixWeights: boolean;
  7605. }
  7606. }
  7607. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7608. /**
  7609. * Class used to override all child animations of a given target
  7610. */
  7611. export class AnimationPropertiesOverride {
  7612. /**
  7613. * Gets or sets a value indicating if animation blending must be used
  7614. */
  7615. enableBlending: boolean;
  7616. /**
  7617. * Gets or sets the blending speed to use when enableBlending is true
  7618. */
  7619. blendingSpeed: number;
  7620. /**
  7621. * Gets or sets the default loop mode to use
  7622. */
  7623. loopMode: number;
  7624. }
  7625. }
  7626. declare module "babylonjs/Morph/morphTarget" {
  7627. import { IAnimatable } from "babylonjs/Misc/tools";
  7628. import { Observable } from "babylonjs/Misc/observable";
  7629. import { Nullable, FloatArray } from "babylonjs/types";
  7630. import { Scene } from "babylonjs/scene";
  7631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7632. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7633. /**
  7634. * Defines a target to use with MorphTargetManager
  7635. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7636. */
  7637. export class MorphTarget implements IAnimatable {
  7638. /** defines the name of the target */
  7639. name: string;
  7640. /**
  7641. * Gets or sets the list of animations
  7642. */
  7643. animations: import("babylonjs/Animations/animation").Animation[];
  7644. private _scene;
  7645. private _positions;
  7646. private _normals;
  7647. private _tangents;
  7648. private _influence;
  7649. /**
  7650. * Observable raised when the influence changes
  7651. */
  7652. onInfluenceChanged: Observable<boolean>;
  7653. /** @hidden */
  7654. _onDataLayoutChanged: Observable<void>;
  7655. /**
  7656. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7657. */
  7658. influence: number;
  7659. /**
  7660. * Gets or sets the id of the morph Target
  7661. */
  7662. id: string;
  7663. private _animationPropertiesOverride;
  7664. /**
  7665. * Gets or sets the animation properties override
  7666. */
  7667. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7668. /**
  7669. * Creates a new MorphTarget
  7670. * @param name defines the name of the target
  7671. * @param influence defines the influence to use
  7672. * @param scene defines the scene the morphtarget belongs to
  7673. */
  7674. constructor(
  7675. /** defines the name of the target */
  7676. name: string, influence?: number, scene?: Nullable<Scene>);
  7677. /**
  7678. * Gets a boolean defining if the target contains position data
  7679. */
  7680. readonly hasPositions: boolean;
  7681. /**
  7682. * Gets a boolean defining if the target contains normal data
  7683. */
  7684. readonly hasNormals: boolean;
  7685. /**
  7686. * Gets a boolean defining if the target contains tangent data
  7687. */
  7688. readonly hasTangents: boolean;
  7689. /**
  7690. * Affects position data to this target
  7691. * @param data defines the position data to use
  7692. */
  7693. setPositions(data: Nullable<FloatArray>): void;
  7694. /**
  7695. * Gets the position data stored in this target
  7696. * @returns a FloatArray containing the position data (or null if not present)
  7697. */
  7698. getPositions(): Nullable<FloatArray>;
  7699. /**
  7700. * Affects normal data to this target
  7701. * @param data defines the normal data to use
  7702. */
  7703. setNormals(data: Nullable<FloatArray>): void;
  7704. /**
  7705. * Gets the normal data stored in this target
  7706. * @returns a FloatArray containing the normal data (or null if not present)
  7707. */
  7708. getNormals(): Nullable<FloatArray>;
  7709. /**
  7710. * Affects tangent data to this target
  7711. * @param data defines the tangent data to use
  7712. */
  7713. setTangents(data: Nullable<FloatArray>): void;
  7714. /**
  7715. * Gets the tangent data stored in this target
  7716. * @returns a FloatArray containing the tangent data (or null if not present)
  7717. */
  7718. getTangents(): Nullable<FloatArray>;
  7719. /**
  7720. * Serializes the current target into a Serialization object
  7721. * @returns the serialized object
  7722. */
  7723. serialize(): any;
  7724. /**
  7725. * Returns the string "MorphTarget"
  7726. * @returns "MorphTarget"
  7727. */
  7728. getClassName(): string;
  7729. /**
  7730. * Creates a new target from serialized data
  7731. * @param serializationObject defines the serialized data to use
  7732. * @returns a new MorphTarget
  7733. */
  7734. static Parse(serializationObject: any): MorphTarget;
  7735. /**
  7736. * Creates a MorphTarget from mesh data
  7737. * @param mesh defines the source mesh
  7738. * @param name defines the name to use for the new target
  7739. * @param influence defines the influence to attach to the target
  7740. * @returns a new MorphTarget
  7741. */
  7742. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7743. }
  7744. }
  7745. declare module "babylonjs/Morph/morphTargetManager" {
  7746. import { Nullable } from "babylonjs/types";
  7747. import { Scene } from "babylonjs/scene";
  7748. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  7749. /**
  7750. * This class is used to deform meshes using morphing between different targets
  7751. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7752. */
  7753. export class MorphTargetManager {
  7754. private _targets;
  7755. private _targetInfluenceChangedObservers;
  7756. private _targetDataLayoutChangedObservers;
  7757. private _activeTargets;
  7758. private _scene;
  7759. private _influences;
  7760. private _supportsNormals;
  7761. private _supportsTangents;
  7762. private _vertexCount;
  7763. private _uniqueId;
  7764. private _tempInfluences;
  7765. /**
  7766. * Creates a new MorphTargetManager
  7767. * @param scene defines the current scene
  7768. */
  7769. constructor(scene?: Nullable<Scene>);
  7770. /**
  7771. * Gets the unique ID of this manager
  7772. */
  7773. readonly uniqueId: number;
  7774. /**
  7775. * Gets the number of vertices handled by this manager
  7776. */
  7777. readonly vertexCount: number;
  7778. /**
  7779. * Gets a boolean indicating if this manager supports morphing of normals
  7780. */
  7781. readonly supportsNormals: boolean;
  7782. /**
  7783. * Gets a boolean indicating if this manager supports morphing of tangents
  7784. */
  7785. readonly supportsTangents: boolean;
  7786. /**
  7787. * Gets the number of targets stored in this manager
  7788. */
  7789. readonly numTargets: number;
  7790. /**
  7791. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7792. */
  7793. readonly numInfluencers: number;
  7794. /**
  7795. * Gets the list of influences (one per target)
  7796. */
  7797. readonly influences: Float32Array;
  7798. /**
  7799. * Gets the active target at specified index. An active target is a target with an influence > 0
  7800. * @param index defines the index to check
  7801. * @returns the requested target
  7802. */
  7803. getActiveTarget(index: number): MorphTarget;
  7804. /**
  7805. * Gets the target at specified index
  7806. * @param index defines the index to check
  7807. * @returns the requested target
  7808. */
  7809. getTarget(index: number): MorphTarget;
  7810. /**
  7811. * Add a new target to this manager
  7812. * @param target defines the target to add
  7813. */
  7814. addTarget(target: MorphTarget): void;
  7815. /**
  7816. * Removes a target from the manager
  7817. * @param target defines the target to remove
  7818. */
  7819. removeTarget(target: MorphTarget): void;
  7820. /**
  7821. * Serializes the current manager into a Serialization object
  7822. * @returns the serialized object
  7823. */
  7824. serialize(): any;
  7825. private _syncActiveTargets;
  7826. /**
  7827. * Syncrhonize the targets with all the meshes using this morph target manager
  7828. */
  7829. synchronize(): void;
  7830. /**
  7831. * Creates a new MorphTargetManager from serialized data
  7832. * @param serializationObject defines the serialized data
  7833. * @param scene defines the hosting scene
  7834. * @returns the new MorphTargetManager
  7835. */
  7836. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7837. }
  7838. }
  7839. declare module "babylonjs/Meshes/instancedMesh" {
  7840. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  7841. import { Vector3 } from "babylonjs/Maths/math";
  7842. import { Camera } from "babylonjs/Cameras/camera";
  7843. import { Node } from "babylonjs/node";
  7844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7845. import { Mesh } from "babylonjs/Meshes/mesh";
  7846. import { Material } from "babylonjs/Materials/material";
  7847. import { Skeleton } from "babylonjs/Bones/skeleton";
  7848. /**
  7849. * Creates an instance based on a source mesh.
  7850. */
  7851. export class InstancedMesh extends AbstractMesh {
  7852. private _sourceMesh;
  7853. private _currentLOD;
  7854. /** @hidden */
  7855. _indexInSourceMeshInstanceArray: number;
  7856. constructor(name: string, source: Mesh);
  7857. /**
  7858. * Returns the string "InstancedMesh".
  7859. */
  7860. getClassName(): string;
  7861. /**
  7862. * If the source mesh receives shadows
  7863. */
  7864. readonly receiveShadows: boolean;
  7865. /**
  7866. * The material of the source mesh
  7867. */
  7868. readonly material: Nullable<Material>;
  7869. /**
  7870. * Visibility of the source mesh
  7871. */
  7872. readonly visibility: number;
  7873. /**
  7874. * Skeleton of the source mesh
  7875. */
  7876. readonly skeleton: Nullable<Skeleton>;
  7877. /**
  7878. * Rendering ground id of the source mesh
  7879. */
  7880. renderingGroupId: number;
  7881. /**
  7882. * Returns the total number of vertices (integer).
  7883. */
  7884. getTotalVertices(): number;
  7885. /**
  7886. * Returns a positive integer : the total number of indices in this mesh geometry.
  7887. * @returns the numner of indices or zero if the mesh has no geometry.
  7888. */
  7889. getTotalIndices(): number;
  7890. /**
  7891. * The source mesh of the instance
  7892. */
  7893. readonly sourceMesh: Mesh;
  7894. /**
  7895. * Is this node ready to be used/rendered
  7896. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7897. * @return {boolean} is it ready
  7898. */
  7899. isReady(completeCheck?: boolean): boolean;
  7900. /**
  7901. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7902. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7903. * @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.
  7904. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7905. */
  7906. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7907. /**
  7908. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7909. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7910. * The `data` are either a numeric array either a Float32Array.
  7911. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7912. * 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).
  7913. * Note that a new underlying VertexBuffer object is created each call.
  7914. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7915. *
  7916. * Possible `kind` values :
  7917. * - VertexBuffer.PositionKind
  7918. * - VertexBuffer.UVKind
  7919. * - VertexBuffer.UV2Kind
  7920. * - VertexBuffer.UV3Kind
  7921. * - VertexBuffer.UV4Kind
  7922. * - VertexBuffer.UV5Kind
  7923. * - VertexBuffer.UV6Kind
  7924. * - VertexBuffer.ColorKind
  7925. * - VertexBuffer.MatricesIndicesKind
  7926. * - VertexBuffer.MatricesIndicesExtraKind
  7927. * - VertexBuffer.MatricesWeightsKind
  7928. * - VertexBuffer.MatricesWeightsExtraKind
  7929. *
  7930. * Returns the Mesh.
  7931. */
  7932. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7933. /**
  7934. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7935. * If the mesh has no geometry, it is simply returned as it is.
  7936. * The `data` are either a numeric array either a Float32Array.
  7937. * No new underlying VertexBuffer object is created.
  7938. * 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.
  7939. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7940. *
  7941. * Possible `kind` values :
  7942. * - VertexBuffer.PositionKind
  7943. * - VertexBuffer.UVKind
  7944. * - VertexBuffer.UV2Kind
  7945. * - VertexBuffer.UV3Kind
  7946. * - VertexBuffer.UV4Kind
  7947. * - VertexBuffer.UV5Kind
  7948. * - VertexBuffer.UV6Kind
  7949. * - VertexBuffer.ColorKind
  7950. * - VertexBuffer.MatricesIndicesKind
  7951. * - VertexBuffer.MatricesIndicesExtraKind
  7952. * - VertexBuffer.MatricesWeightsKind
  7953. * - VertexBuffer.MatricesWeightsExtraKind
  7954. *
  7955. * Returns the Mesh.
  7956. */
  7957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7958. /**
  7959. * Sets the mesh indices.
  7960. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7961. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7962. * This method creates a new index buffer each call.
  7963. * Returns the Mesh.
  7964. */
  7965. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7966. /**
  7967. * Boolean : True if the mesh owns the requested kind of data.
  7968. */
  7969. isVerticesDataPresent(kind: string): boolean;
  7970. /**
  7971. * Returns an array of indices (IndicesArray).
  7972. */
  7973. getIndices(): Nullable<IndicesArray>;
  7974. readonly _positions: Nullable<Vector3[]>;
  7975. /**
  7976. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7977. * This means the mesh underlying bounding box and sphere are recomputed.
  7978. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7979. * @returns the current mesh
  7980. */
  7981. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7982. /** @hidden */
  7983. _preActivate(): InstancedMesh;
  7984. /** @hidden */
  7985. _activate(renderId: number): InstancedMesh;
  7986. /**
  7987. * Returns the current associated LOD AbstractMesh.
  7988. */
  7989. getLOD(camera: Camera): AbstractMesh;
  7990. /** @hidden */
  7991. _syncSubMeshes(): InstancedMesh;
  7992. /** @hidden */
  7993. _generatePointsArray(): boolean;
  7994. /**
  7995. * Creates a new InstancedMesh from the current mesh.
  7996. * - name (string) : the cloned mesh name
  7997. * - newParent (optional Node) : the optional Node to parent the clone to.
  7998. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7999. *
  8000. * Returns the clone.
  8001. */
  8002. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  8003. /**
  8004. * Disposes the InstancedMesh.
  8005. * Returns nothing.
  8006. */
  8007. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8008. }
  8009. }
  8010. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8011. import { Nullable } from "babylonjs/types";
  8012. import { Scene } from "babylonjs/scene";
  8013. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8015. /**
  8016. * Class for creating a cube texture
  8017. */
  8018. export class CubeTexture extends BaseTexture {
  8019. private _delayedOnLoad;
  8020. /**
  8021. * The url of the texture
  8022. */
  8023. url: string;
  8024. /**
  8025. * Gets or sets the center of the bounding box associated with the cube texture.
  8026. * It must define where the camera used to render the texture was set
  8027. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8028. */
  8029. boundingBoxPosition: Vector3;
  8030. private _boundingBoxSize;
  8031. /**
  8032. * Gets or sets the size of the bounding box associated with the cube texture
  8033. * When defined, the cubemap will switch to local mode
  8034. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8035. * @example https://www.babylonjs-playground.com/#RNASML
  8036. */
  8037. /**
  8038. * Returns the bounding box size
  8039. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8040. */
  8041. boundingBoxSize: Vector3;
  8042. protected _rotationY: number;
  8043. /**
  8044. * Sets texture matrix rotation angle around Y axis in radians.
  8045. */
  8046. /**
  8047. * Gets texture matrix rotation angle around Y axis radians.
  8048. */
  8049. rotationY: number;
  8050. /**
  8051. * Are mip maps generated for this texture or not.
  8052. */
  8053. readonly noMipmap: boolean;
  8054. private _noMipmap;
  8055. private _files;
  8056. private _extensions;
  8057. private _textureMatrix;
  8058. private _format;
  8059. private _createPolynomials;
  8060. /** @hidden */
  8061. _prefiltered: boolean;
  8062. /**
  8063. * Creates a cube texture from an array of image urls
  8064. * @param files defines an array of image urls
  8065. * @param scene defines the hosting scene
  8066. * @param noMipmap specifies if mip maps are not used
  8067. * @returns a cube texture
  8068. */
  8069. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8070. /**
  8071. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8072. * @param url defines the url of the prefiltered texture
  8073. * @param scene defines the scene the texture is attached to
  8074. * @param forcedExtension defines the extension of the file if different from the url
  8075. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8076. * @return the prefiltered texture
  8077. */
  8078. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8079. /**
  8080. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8081. * as prefiltered data.
  8082. * @param rootUrl defines the url of the texture or the root name of the six images
  8083. * @param scene defines the scene the texture is attached to
  8084. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8085. * @param noMipmap defines if mipmaps should be created or not
  8086. * @param files defines the six files to load for the different faces
  8087. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8088. * @param onError defines a callback triggered in case of error during load
  8089. * @param format defines the internal format to use for the texture once loaded
  8090. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8091. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8092. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8093. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8094. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8095. * @return the cube texture
  8096. */
  8097. 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);
  8098. /**
  8099. * Get the current class name of the texture useful for serialization or dynamic coding.
  8100. * @returns "CubeTexture"
  8101. */
  8102. getClassName(): string;
  8103. /**
  8104. * Update the url (and optional buffer) of this texture if url was null during construction.
  8105. * @param url the url of the texture
  8106. * @param forcedExtension defines the extension to use
  8107. * @param onLoad callback called when the texture is loaded (defaults to null)
  8108. */
  8109. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8110. /**
  8111. * Delays loading of the cube texture
  8112. * @param forcedExtension defines the extension to use
  8113. */
  8114. delayLoad(forcedExtension?: string): void;
  8115. /**
  8116. * Returns the reflection texture matrix
  8117. * @returns the reflection texture matrix
  8118. */
  8119. getReflectionTextureMatrix(): Matrix;
  8120. /**
  8121. * Sets the reflection texture matrix
  8122. * @param value Reflection texture matrix
  8123. */
  8124. setReflectionTextureMatrix(value: Matrix): void;
  8125. /**
  8126. * Parses text to create a cube texture
  8127. * @param parsedTexture define the serialized text to read from
  8128. * @param scene defines the hosting scene
  8129. * @param rootUrl defines the root url of the cube texture
  8130. * @returns a cube texture
  8131. */
  8132. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8133. /**
  8134. * Makes a clone, or deep copy, of the cube texture
  8135. * @returns a new cube texture
  8136. */
  8137. clone(): CubeTexture;
  8138. }
  8139. }
  8140. declare module "babylonjs/Shaders/postprocess.vertex" {
  8141. /** @hidden */
  8142. export var postprocessVertexShader: {
  8143. name: string;
  8144. shader: string;
  8145. };
  8146. }
  8147. declare module "babylonjs/Cameras/targetCamera" {
  8148. import { Nullable } from "babylonjs/types";
  8149. import { Camera } from "babylonjs/Cameras/camera";
  8150. import { Scene } from "babylonjs/scene";
  8151. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8152. /**
  8153. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8154. * This is the base of the follow, arc rotate cameras and Free camera
  8155. * @see http://doc.babylonjs.com/features/cameras
  8156. */
  8157. export class TargetCamera extends Camera {
  8158. private static _RigCamTransformMatrix;
  8159. private static _TargetTransformMatrix;
  8160. private static _TargetFocalPoint;
  8161. /**
  8162. * Define the current direction the camera is moving to
  8163. */
  8164. cameraDirection: Vector3;
  8165. /**
  8166. * Define the current rotation the camera is rotating to
  8167. */
  8168. cameraRotation: Vector2;
  8169. /**
  8170. * When set, the up vector of the camera will be updated by the rotation of the camera
  8171. */
  8172. updateUpVectorFromRotation: boolean;
  8173. private _tmpQuaternion;
  8174. /**
  8175. * Define the current rotation of the camera
  8176. */
  8177. rotation: Vector3;
  8178. /**
  8179. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8180. */
  8181. rotationQuaternion: Quaternion;
  8182. /**
  8183. * Define the current speed of the camera
  8184. */
  8185. speed: number;
  8186. /**
  8187. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8188. * around all axis.
  8189. */
  8190. noRotationConstraint: boolean;
  8191. /**
  8192. * Define the current target of the camera as an object or a position.
  8193. */
  8194. lockedTarget: any;
  8195. /** @hidden */
  8196. _currentTarget: Vector3;
  8197. /** @hidden */
  8198. _initialFocalDistance: number;
  8199. /** @hidden */
  8200. _viewMatrix: Matrix;
  8201. /** @hidden */
  8202. _camMatrix: Matrix;
  8203. /** @hidden */
  8204. _cameraTransformMatrix: Matrix;
  8205. /** @hidden */
  8206. _cameraRotationMatrix: Matrix;
  8207. /** @hidden */
  8208. _referencePoint: Vector3;
  8209. /** @hidden */
  8210. _transformedReferencePoint: Vector3;
  8211. protected _globalCurrentTarget: Vector3;
  8212. protected _globalCurrentUpVector: Vector3;
  8213. /** @hidden */
  8214. _reset: () => void;
  8215. private _defaultUp;
  8216. /**
  8217. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8218. * This is the base of the follow, arc rotate cameras and Free camera
  8219. * @see http://doc.babylonjs.com/features/cameras
  8220. * @param name Defines the name of the camera in the scene
  8221. * @param position Defines the start position of the camera in the scene
  8222. * @param scene Defines the scene the camera belongs to
  8223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8224. */
  8225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8226. /**
  8227. * Gets the position in front of the camera at a given distance.
  8228. * @param distance The distance from the camera we want the position to be
  8229. * @returns the position
  8230. */
  8231. getFrontPosition(distance: number): Vector3;
  8232. /** @hidden */
  8233. _getLockedTargetPosition(): Nullable<Vector3>;
  8234. private _storedPosition;
  8235. private _storedRotation;
  8236. private _storedRotationQuaternion;
  8237. /**
  8238. * Store current camera state of the camera (fov, position, rotation, etc..)
  8239. * @returns the camera
  8240. */
  8241. storeState(): Camera;
  8242. /**
  8243. * Restored camera state. You must call storeState() first
  8244. * @returns whether it was successful or not
  8245. * @hidden
  8246. */
  8247. _restoreStateValues(): boolean;
  8248. /** @hidden */
  8249. _initCache(): void;
  8250. /** @hidden */
  8251. _updateCache(ignoreParentClass?: boolean): void;
  8252. /** @hidden */
  8253. _isSynchronizedViewMatrix(): boolean;
  8254. /** @hidden */
  8255. _computeLocalCameraSpeed(): number;
  8256. /** @hidden */
  8257. setTarget(target: Vector3): void;
  8258. /**
  8259. * Return the current target position of the camera. This value is expressed in local space.
  8260. * @returns the target position
  8261. */
  8262. getTarget(): Vector3;
  8263. /** @hidden */
  8264. _decideIfNeedsToMove(): boolean;
  8265. /** @hidden */
  8266. _updatePosition(): void;
  8267. /** @hidden */
  8268. _checkInputs(): void;
  8269. protected _updateCameraRotationMatrix(): void;
  8270. /**
  8271. * 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)
  8272. * @returns the current camera
  8273. */
  8274. private _rotateUpVectorWithCameraRotationMatrix;
  8275. private _cachedRotationZ;
  8276. private _cachedQuaternionRotationZ;
  8277. /** @hidden */
  8278. _getViewMatrix(): Matrix;
  8279. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8280. /**
  8281. * @hidden
  8282. */
  8283. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8284. /**
  8285. * @hidden
  8286. */
  8287. _updateRigCameras(): void;
  8288. private _getRigCamPositionAndTarget;
  8289. /**
  8290. * Gets the current object class name.
  8291. * @return the class name
  8292. */
  8293. getClassName(): string;
  8294. }
  8295. }
  8296. declare module "babylonjs/Cameras/cameraInputsManager" {
  8297. import { Nullable } from "babylonjs/types";
  8298. import { Camera } from "babylonjs/Cameras/camera";
  8299. /**
  8300. * @ignore
  8301. * This is a list of all the different input types that are available in the application.
  8302. * Fo instance: ArcRotateCameraGamepadInput...
  8303. */
  8304. export var CameraInputTypes: {};
  8305. /**
  8306. * This is the contract to implement in order to create a new input class.
  8307. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8308. */
  8309. export interface ICameraInput<TCamera extends Camera> {
  8310. /**
  8311. * Defines the camera the input is attached to.
  8312. */
  8313. camera: Nullable<TCamera>;
  8314. /**
  8315. * Gets the class name of the current intput.
  8316. * @returns the class name
  8317. */
  8318. getClassName(): string;
  8319. /**
  8320. * Get the friendly name associated with the input class.
  8321. * @returns the input friendly name
  8322. */
  8323. getSimpleName(): string;
  8324. /**
  8325. * Attach the input controls to a specific dom element to get the input from.
  8326. * @param element Defines the element the controls should be listened from
  8327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8328. */
  8329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8330. /**
  8331. * Detach the current controls from the specified dom element.
  8332. * @param element Defines the element to stop listening the inputs from
  8333. */
  8334. detachControl(element: Nullable<HTMLElement>): void;
  8335. /**
  8336. * Update the current camera state depending on the inputs that have been used this frame.
  8337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8338. */
  8339. checkInputs?: () => void;
  8340. }
  8341. /**
  8342. * Represents a map of input types to input instance or input index to input instance.
  8343. */
  8344. export interface CameraInputsMap<TCamera extends Camera> {
  8345. /**
  8346. * Accessor to the input by input type.
  8347. */
  8348. [name: string]: ICameraInput<TCamera>;
  8349. /**
  8350. * Accessor to the input by input index.
  8351. */
  8352. [idx: number]: ICameraInput<TCamera>;
  8353. }
  8354. /**
  8355. * This represents the input manager used within a camera.
  8356. * It helps dealing with all the different kind of input attached to a camera.
  8357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8358. */
  8359. export class CameraInputsManager<TCamera extends Camera> {
  8360. /**
  8361. * Defines the list of inputs attahed to the camera.
  8362. */
  8363. attached: CameraInputsMap<TCamera>;
  8364. /**
  8365. * Defines the dom element the camera is collecting inputs from.
  8366. * This is null if the controls have not been attached.
  8367. */
  8368. attachedElement: Nullable<HTMLElement>;
  8369. /**
  8370. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8371. */
  8372. noPreventDefault: boolean;
  8373. /**
  8374. * Defined the camera the input manager belongs to.
  8375. */
  8376. camera: TCamera;
  8377. /**
  8378. * Update the current camera state depending on the inputs that have been used this frame.
  8379. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8380. */
  8381. checkInputs: () => void;
  8382. /**
  8383. * Instantiate a new Camera Input Manager.
  8384. * @param camera Defines the camera the input manager blongs to
  8385. */
  8386. constructor(camera: TCamera);
  8387. /**
  8388. * Add an input method to a camera
  8389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8390. * @param input camera input method
  8391. */
  8392. add(input: ICameraInput<TCamera>): void;
  8393. /**
  8394. * Remove a specific input method from a camera
  8395. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8396. * @param inputToRemove camera input method
  8397. */
  8398. remove(inputToRemove: ICameraInput<TCamera>): void;
  8399. /**
  8400. * Remove a specific input type from a camera
  8401. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8402. * @param inputType the type of the input to remove
  8403. */
  8404. removeByType(inputType: string): void;
  8405. private _addCheckInputs;
  8406. /**
  8407. * Attach the input controls to the currently attached dom element to listen the events from.
  8408. * @param input Defines the input to attach
  8409. */
  8410. attachInput(input: ICameraInput<TCamera>): void;
  8411. /**
  8412. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8413. * @param element Defines the dom element to collect the events from
  8414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8415. */
  8416. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8417. /**
  8418. * Detach the current manager inputs controls from a specific dom element.
  8419. * @param element Defines the dom element to collect the events from
  8420. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8421. */
  8422. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8423. /**
  8424. * Rebuild the dynamic inputCheck function from the current list of
  8425. * defined inputs in the manager.
  8426. */
  8427. rebuildInputCheck(): void;
  8428. /**
  8429. * Remove all attached input methods from a camera
  8430. */
  8431. clear(): void;
  8432. /**
  8433. * Serialize the current input manager attached to a camera.
  8434. * This ensures than once parsed,
  8435. * the input associated to the camera will be identical to the current ones
  8436. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8437. */
  8438. serialize(serializedCamera: any): void;
  8439. /**
  8440. * Parses an input manager serialized JSON to restore the previous list of inputs
  8441. * and states associated to a camera.
  8442. * @param parsedCamera Defines the JSON to parse
  8443. */
  8444. parse(parsedCamera: any): void;
  8445. }
  8446. }
  8447. declare module "babylonjs/Events/keyboardEvents" {
  8448. /**
  8449. * Gather the list of keyboard event types as constants.
  8450. */
  8451. export class KeyboardEventTypes {
  8452. /**
  8453. * The keydown event is fired when a key becomes active (pressed).
  8454. */
  8455. static readonly KEYDOWN: number;
  8456. /**
  8457. * The keyup event is fired when a key has been released.
  8458. */
  8459. static readonly KEYUP: number;
  8460. }
  8461. /**
  8462. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8463. */
  8464. export class KeyboardInfo {
  8465. /**
  8466. * Defines the type of event (KeyboardEventTypes)
  8467. */
  8468. type: number;
  8469. /**
  8470. * Defines the related dom event
  8471. */
  8472. event: KeyboardEvent;
  8473. /**
  8474. * Instantiates a new keyboard info.
  8475. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8476. * @param type Defines the type of event (KeyboardEventTypes)
  8477. * @param event Defines the related dom event
  8478. */
  8479. constructor(
  8480. /**
  8481. * Defines the type of event (KeyboardEventTypes)
  8482. */
  8483. type: number,
  8484. /**
  8485. * Defines the related dom event
  8486. */
  8487. event: KeyboardEvent);
  8488. }
  8489. /**
  8490. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8491. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8492. */
  8493. export class KeyboardInfoPre extends KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8504. */
  8505. skipOnPointerObservable: boolean;
  8506. /**
  8507. * Instantiates a new keyboard pre info.
  8508. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8509. * @param type Defines the type of event (KeyboardEventTypes)
  8510. * @param event Defines the related dom event
  8511. */
  8512. constructor(
  8513. /**
  8514. * Defines the type of event (KeyboardEventTypes)
  8515. */
  8516. type: number,
  8517. /**
  8518. * Defines the related dom event
  8519. */
  8520. event: KeyboardEvent);
  8521. }
  8522. }
  8523. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8524. import { Nullable } from "babylonjs/types";
  8525. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8526. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8527. /**
  8528. * Manage the keyboard inputs to control the movement of a free camera.
  8529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8530. */
  8531. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8532. /**
  8533. * Defines the camera the input is attached to.
  8534. */
  8535. camera: FreeCamera;
  8536. /**
  8537. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8538. */
  8539. keysUp: number[];
  8540. /**
  8541. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8542. */
  8543. keysDown: number[];
  8544. /**
  8545. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8546. */
  8547. keysLeft: number[];
  8548. /**
  8549. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8550. */
  8551. keysRight: number[];
  8552. private _keys;
  8553. private _onCanvasBlurObserver;
  8554. private _onKeyboardObserver;
  8555. private _engine;
  8556. private _scene;
  8557. /**
  8558. * Attach the input controls to a specific dom element to get the input from.
  8559. * @param element Defines the element the controls should be listened from
  8560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8561. */
  8562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8563. /**
  8564. * Detach the current controls from the specified dom element.
  8565. * @param element Defines the element to stop listening the inputs from
  8566. */
  8567. detachControl(element: Nullable<HTMLElement>): void;
  8568. /**
  8569. * Update the current camera state depending on the inputs that have been used this frame.
  8570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8571. */
  8572. checkInputs(): void;
  8573. /**
  8574. * Gets the class name of the current intput.
  8575. * @returns the class name
  8576. */
  8577. getClassName(): string;
  8578. /** @hidden */
  8579. _onLostFocus(): void;
  8580. /**
  8581. * Get the friendly name associated with the input class.
  8582. * @returns the input friendly name
  8583. */
  8584. getSimpleName(): string;
  8585. }
  8586. }
  8587. declare module "babylonjs/Actions/actionEvent" {
  8588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8589. import { Nullable } from "babylonjs/types";
  8590. import { Sprite } from "babylonjs/Sprites/sprite";
  8591. import { Scene } from "babylonjs/scene";
  8592. import { Vector2 } from "babylonjs/Maths/math";
  8593. /**
  8594. * Interface used to define ActionEvent
  8595. */
  8596. export interface IActionEvent {
  8597. /** The mesh or sprite that triggered the action */
  8598. source: any;
  8599. /** The X mouse cursor position at the time of the event */
  8600. pointerX: number;
  8601. /** The Y mouse cursor position at the time of the event */
  8602. pointerY: number;
  8603. /** The mesh that is currently pointed at (can be null) */
  8604. meshUnderPointer: Nullable<AbstractMesh>;
  8605. /** the original (browser) event that triggered the ActionEvent */
  8606. sourceEvent?: any;
  8607. /** additional data for the event */
  8608. additionalData?: any;
  8609. }
  8610. /**
  8611. * ActionEvent is the event being sent when an action is triggered.
  8612. */
  8613. export class ActionEvent implements IActionEvent {
  8614. /** The mesh or sprite that triggered the action */
  8615. source: any;
  8616. /** The X mouse cursor position at the time of the event */
  8617. pointerX: number;
  8618. /** The Y mouse cursor position at the time of the event */
  8619. pointerY: number;
  8620. /** The mesh that is currently pointed at (can be null) */
  8621. meshUnderPointer: Nullable<AbstractMesh>;
  8622. /** the original (browser) event that triggered the ActionEvent */
  8623. sourceEvent?: any;
  8624. /** additional data for the event */
  8625. additionalData?: any;
  8626. /**
  8627. * Creates a new ActionEvent
  8628. * @param source The mesh or sprite that triggered the action
  8629. * @param pointerX The X mouse cursor position at the time of the event
  8630. * @param pointerY The Y mouse cursor position at the time of the event
  8631. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8632. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8633. * @param additionalData additional data for the event
  8634. */
  8635. constructor(
  8636. /** The mesh or sprite that triggered the action */
  8637. source: any,
  8638. /** The X mouse cursor position at the time of the event */
  8639. pointerX: number,
  8640. /** The Y mouse cursor position at the time of the event */
  8641. pointerY: number,
  8642. /** The mesh that is currently pointed at (can be null) */
  8643. meshUnderPointer: Nullable<AbstractMesh>,
  8644. /** the original (browser) event that triggered the ActionEvent */
  8645. sourceEvent?: any,
  8646. /** additional data for the event */
  8647. additionalData?: any);
  8648. /**
  8649. * Helper function to auto-create an ActionEvent from a source mesh.
  8650. * @param source The source mesh that triggered the event
  8651. * @param evt The original (browser) event
  8652. * @param additionalData additional data for the event
  8653. * @returns the new ActionEvent
  8654. */
  8655. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8656. /**
  8657. * Helper function to auto-create an ActionEvent from a source sprite
  8658. * @param source The source sprite that triggered the event
  8659. * @param scene Scene associated with the sprite
  8660. * @param evt The original (browser) event
  8661. * @param additionalData additional data for the event
  8662. * @returns the new ActionEvent
  8663. */
  8664. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8665. /**
  8666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8667. * @param scene the scene where the event occurred
  8668. * @param evt The original (browser) event
  8669. * @returns the new ActionEvent
  8670. */
  8671. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8672. /**
  8673. * Helper function to auto-create an ActionEvent from a primitive
  8674. * @param prim defines the target primitive
  8675. * @param pointerPos defines the pointer position
  8676. * @param evt The original (browser) event
  8677. * @param additionalData additional data for the event
  8678. * @returns the new ActionEvent
  8679. */
  8680. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8681. }
  8682. }
  8683. declare module "babylonjs/Lights/shadowLight" {
  8684. import { Camera } from "babylonjs/Cameras/camera";
  8685. import { Scene } from "babylonjs/scene";
  8686. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8688. import { Light } from "babylonjs/Lights/light";
  8689. /**
  8690. * Interface describing all the common properties and methods a shadow light needs to implement.
  8691. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8692. * as well as binding the different shadow properties to the effects.
  8693. */
  8694. export interface IShadowLight extends Light {
  8695. /**
  8696. * The light id in the scene (used in scene.findLighById for instance)
  8697. */
  8698. id: string;
  8699. /**
  8700. * The position the shdow will be casted from.
  8701. */
  8702. position: Vector3;
  8703. /**
  8704. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8705. */
  8706. direction: Vector3;
  8707. /**
  8708. * The transformed position. Position of the light in world space taking parenting in account.
  8709. */
  8710. transformedPosition: Vector3;
  8711. /**
  8712. * The transformed direction. Direction of the light in world space taking parenting in account.
  8713. */
  8714. transformedDirection: Vector3;
  8715. /**
  8716. * The friendly name of the light in the scene.
  8717. */
  8718. name: string;
  8719. /**
  8720. * Defines the shadow projection clipping minimum z value.
  8721. */
  8722. shadowMinZ: number;
  8723. /**
  8724. * Defines the shadow projection clipping maximum z value.
  8725. */
  8726. shadowMaxZ: number;
  8727. /**
  8728. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8729. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8730. */
  8731. computeTransformedInformation(): boolean;
  8732. /**
  8733. * Gets the scene the light belongs to.
  8734. * @returns The scene
  8735. */
  8736. getScene(): Scene;
  8737. /**
  8738. * Callback defining a custom Projection Matrix Builder.
  8739. * This can be used to override the default projection matrix computation.
  8740. */
  8741. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8742. /**
  8743. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8744. * @param matrix The materix to updated with the projection information
  8745. * @param viewMatrix The transform matrix of the light
  8746. * @param renderList The list of mesh to render in the map
  8747. * @returns The current light
  8748. */
  8749. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8750. /**
  8751. * Gets the current depth scale used in ESM.
  8752. * @returns The scale
  8753. */
  8754. getDepthScale(): number;
  8755. /**
  8756. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8757. * @returns true if a cube texture needs to be use
  8758. */
  8759. needCube(): boolean;
  8760. /**
  8761. * Detects if the projection matrix requires to be recomputed this frame.
  8762. * @returns true if it requires to be recomputed otherwise, false.
  8763. */
  8764. needProjectionMatrixCompute(): boolean;
  8765. /**
  8766. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8767. */
  8768. forceProjectionMatrixCompute(): void;
  8769. /**
  8770. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8771. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8772. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8773. */
  8774. getShadowDirection(faceIndex?: number): Vector3;
  8775. /**
  8776. * Gets the minZ used for shadow according to both the scene and the light.
  8777. * @param activeCamera The camera we are returning the min for
  8778. * @returns the depth min z
  8779. */
  8780. getDepthMinZ(activeCamera: Camera): number;
  8781. /**
  8782. * Gets the maxZ used for shadow according to both the scene and the light.
  8783. * @param activeCamera The camera we are returning the max for
  8784. * @returns the depth max z
  8785. */
  8786. getDepthMaxZ(activeCamera: Camera): number;
  8787. }
  8788. /**
  8789. * Base implementation IShadowLight
  8790. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8791. */
  8792. export abstract class ShadowLight extends Light implements IShadowLight {
  8793. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8794. protected _position: Vector3;
  8795. protected _setPosition(value: Vector3): void;
  8796. /**
  8797. * Sets the position the shadow will be casted from. Also use as the light position for both
  8798. * point and spot lights.
  8799. */
  8800. /**
  8801. * Sets the position the shadow will be casted from. Also use as the light position for both
  8802. * point and spot lights.
  8803. */
  8804. position: Vector3;
  8805. protected _direction: Vector3;
  8806. protected _setDirection(value: Vector3): void;
  8807. /**
  8808. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8809. * Also use as the light direction on spot and directional lights.
  8810. */
  8811. /**
  8812. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8813. * Also use as the light direction on spot and directional lights.
  8814. */
  8815. direction: Vector3;
  8816. private _shadowMinZ;
  8817. /**
  8818. * Gets the shadow projection clipping minimum z value.
  8819. */
  8820. /**
  8821. * Sets the shadow projection clipping minimum z value.
  8822. */
  8823. shadowMinZ: number;
  8824. private _shadowMaxZ;
  8825. /**
  8826. * Sets the shadow projection clipping maximum z value.
  8827. */
  8828. /**
  8829. * Gets the shadow projection clipping maximum z value.
  8830. */
  8831. shadowMaxZ: number;
  8832. /**
  8833. * Callback defining a custom Projection Matrix Builder.
  8834. * This can be used to override the default projection matrix computation.
  8835. */
  8836. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8837. /**
  8838. * The transformed position. Position of the light in world space taking parenting in account.
  8839. */
  8840. transformedPosition: Vector3;
  8841. /**
  8842. * The transformed direction. Direction of the light in world space taking parenting in account.
  8843. */
  8844. transformedDirection: Vector3;
  8845. private _needProjectionMatrixCompute;
  8846. /**
  8847. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8848. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8849. */
  8850. computeTransformedInformation(): boolean;
  8851. /**
  8852. * Return the depth scale used for the shadow map.
  8853. * @returns the depth scale.
  8854. */
  8855. getDepthScale(): number;
  8856. /**
  8857. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8858. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8859. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8860. */
  8861. getShadowDirection(faceIndex?: number): Vector3;
  8862. /**
  8863. * Returns the ShadowLight absolute position in the World.
  8864. * @returns the position vector in world space
  8865. */
  8866. getAbsolutePosition(): Vector3;
  8867. /**
  8868. * Sets the ShadowLight direction toward the passed target.
  8869. * @param target The point to target in local space
  8870. * @returns the updated ShadowLight direction
  8871. */
  8872. setDirectionToTarget(target: Vector3): Vector3;
  8873. /**
  8874. * Returns the light rotation in euler definition.
  8875. * @returns the x y z rotation in local space.
  8876. */
  8877. getRotation(): Vector3;
  8878. /**
  8879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8880. * @returns true if a cube texture needs to be use
  8881. */
  8882. needCube(): boolean;
  8883. /**
  8884. * Detects if the projection matrix requires to be recomputed this frame.
  8885. * @returns true if it requires to be recomputed otherwise, false.
  8886. */
  8887. needProjectionMatrixCompute(): boolean;
  8888. /**
  8889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8890. */
  8891. forceProjectionMatrixCompute(): void;
  8892. /** @hidden */
  8893. _initCache(): void;
  8894. /** @hidden */
  8895. _isSynchronized(): boolean;
  8896. /**
  8897. * Computes the world matrix of the node
  8898. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8899. * @returns the world matrix
  8900. */
  8901. computeWorldMatrix(force?: boolean): Matrix;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. /**
  8915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8916. * @param matrix The materix to updated with the projection information
  8917. * @param viewMatrix The transform matrix of the light
  8918. * @param renderList The list of mesh to render in the map
  8919. * @returns The current light
  8920. */
  8921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8922. }
  8923. }
  8924. declare module "babylonjs/Materials/materialHelper" {
  8925. import { Nullable } from "babylonjs/types";
  8926. import { Scene } from "babylonjs/scene";
  8927. import { Engine } from "babylonjs/Engines/engine";
  8928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8929. import { Light } from "babylonjs/Lights/light";
  8930. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8931. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8933. /**
  8934. * "Static Class" containing the most commonly used helper while dealing with material for
  8935. * rendering purpose.
  8936. *
  8937. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8938. *
  8939. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8940. */
  8941. export class MaterialHelper {
  8942. /**
  8943. * Bind the current view position to an effect.
  8944. * @param effect The effect to be bound
  8945. * @param scene The scene the eyes position is used from
  8946. */
  8947. static BindEyePosition(effect: Effect, scene: Scene): void;
  8948. /**
  8949. * Helps preparing the defines values about the UVs in used in the effect.
  8950. * UVs are shared as much as we can accross channels in the shaders.
  8951. * @param texture The texture we are preparing the UVs for
  8952. * @param defines The defines to update
  8953. * @param key The channel key "diffuse", "specular"... used in the shader
  8954. */
  8955. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8956. /**
  8957. * Binds a texture matrix value to its corrsponding uniform
  8958. * @param texture The texture to bind the matrix for
  8959. * @param uniformBuffer The uniform buffer receivin the data
  8960. * @param key The channel key "diffuse", "specular"... used in the shader
  8961. */
  8962. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8963. /**
  8964. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8965. * @param mesh defines the current mesh
  8966. * @param scene defines the current scene
  8967. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8968. * @param pointsCloud defines if point cloud rendering has to be turned on
  8969. * @param fogEnabled defines if fog has to be turned on
  8970. * @param alphaTest defines if alpha testing has to be turned on
  8971. * @param defines defines the current list of defines
  8972. */
  8973. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8974. /**
  8975. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8976. * @param scene defines the current scene
  8977. * @param engine defines the current engine
  8978. * @param defines specifies the list of active defines
  8979. * @param useInstances defines if instances have to be turned on
  8980. * @param useClipPlane defines if clip plane have to be turned on
  8981. */
  8982. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8983. /**
  8984. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8985. * @param mesh The mesh containing the geometry data we will draw
  8986. * @param defines The defines to update
  8987. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8988. * @param useBones Precise whether bones should be used or not (override mesh info)
  8989. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8990. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8991. * @returns false if defines are considered not dirty and have not been checked
  8992. */
  8993. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8994. /**
  8995. * Prepares the defines related to the light information passed in parameter
  8996. * @param scene The scene we are intending to draw
  8997. * @param mesh The mesh the effect is compiling for
  8998. * @param defines The defines to update
  8999. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9000. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9001. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9002. * @returns true if normals will be required for the rest of the effect
  9003. */
  9004. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9007. * that won t be acctive due to defines being turned off.
  9008. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9009. * @param samplersList The samplers list
  9010. * @param defines The defines helping in the list generation
  9011. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9012. */
  9013. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9014. /**
  9015. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9016. * @param defines The defines to update while falling back
  9017. * @param fallbacks The authorized effect fallbacks
  9018. * @param maxSimultaneousLights The maximum number of lights allowed
  9019. * @param rank the current rank of the Effect
  9020. * @returns The newly affected rank
  9021. */
  9022. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param defines The current Defines of the effect
  9028. */
  9029. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9030. /**
  9031. * Prepares the list of attributes required for bones according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the bones attributes for
  9034. * @param defines The current Defines of the effect
  9035. * @param fallbacks The current efffect fallback strategy
  9036. */
  9037. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9038. /**
  9039. * Prepares the list of attributes required for instances according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param defines The current Defines of the effect
  9042. */
  9043. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9044. /**
  9045. * Binds the light shadow information to the effect for the given mesh.
  9046. * @param light The light containing the generator
  9047. * @param scene The scene the lights belongs to
  9048. * @param mesh The mesh we are binding the information to render
  9049. * @param lightIndex The light index in the effect used to render the mesh
  9050. * @param effect The effect we are binding the data to
  9051. */
  9052. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9053. /**
  9054. * Binds the light information to the effect.
  9055. * @param light The light containing the generator
  9056. * @param effect The effect we are binding the data to
  9057. * @param lightIndex The light index in the effect used to render
  9058. */
  9059. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9060. /**
  9061. * Binds the lights information from the scene to the effect for the given mesh.
  9062. * @param scene The scene the lights belongs to
  9063. * @param mesh The mesh we are binding the information to render
  9064. * @param effect The effect we are binding the data to
  9065. * @param defines The generated defines for the effect
  9066. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9067. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9068. */
  9069. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9070. private static _tempFogColor;
  9071. /**
  9072. * Binds the fog information from the scene to the effect for the given mesh.
  9073. * @param scene The scene the lights belongs to
  9074. * @param mesh The mesh we are binding the information to render
  9075. * @param effect The effect we are binding the data to
  9076. * @param linearSpace Defines if the fog effect is applied in linear space
  9077. */
  9078. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9079. /**
  9080. * Binds the bones information from the mesh to the effect.
  9081. * @param mesh The mesh we are binding the information to render
  9082. * @param effect The effect we are binding the data to
  9083. */
  9084. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9085. /**
  9086. * Binds the morph targets information from the mesh to the effect.
  9087. * @param abstractMesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. */
  9090. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9091. /**
  9092. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9093. * @param defines The generated defines used in the effect
  9094. * @param effect The effect we are binding the data to
  9095. * @param scene The scene we are willing to render with logarithmic scale for
  9096. */
  9097. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9098. /**
  9099. * Binds the clip plane information from the scene to the effect.
  9100. * @param scene The scene the clip plane information are extracted from
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindClipPlane(effect: Effect, scene: Scene): void;
  9104. }
  9105. }
  9106. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9107. /** @hidden */
  9108. export var kernelBlurVaryingDeclaration: {
  9109. name: string;
  9110. shader: string;
  9111. };
  9112. }
  9113. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9114. /** @hidden */
  9115. export var kernelBlurFragment: {
  9116. name: string;
  9117. shader: string;
  9118. };
  9119. }
  9120. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9121. /** @hidden */
  9122. export var kernelBlurFragment2: {
  9123. name: string;
  9124. shader: string;
  9125. };
  9126. }
  9127. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9128. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9129. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9130. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9131. /** @hidden */
  9132. export var kernelBlurPixelShader: {
  9133. name: string;
  9134. shader: string;
  9135. };
  9136. }
  9137. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9138. /** @hidden */
  9139. export var kernelBlurVertex: {
  9140. name: string;
  9141. shader: string;
  9142. };
  9143. }
  9144. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9145. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9146. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9147. /** @hidden */
  9148. export var kernelBlurVertexShader: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9154. import { Vector2 } from "babylonjs/Maths/math";
  9155. import { Nullable } from "babylonjs/types";
  9156. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9157. import { Camera } from "babylonjs/Cameras/camera";
  9158. import { Effect } from "babylonjs/Materials/effect";
  9159. import { Engine } from "babylonjs/Engines/engine";
  9160. import "babylonjs/Shaders/kernelBlur.fragment";
  9161. import "babylonjs/Shaders/kernelBlur.vertex";
  9162. /**
  9163. * The Blur Post Process which blurs an image based on a kernel and direction.
  9164. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9165. */
  9166. export class BlurPostProcess extends PostProcess {
  9167. /** The direction in which to blur the image. */
  9168. direction: Vector2;
  9169. private blockCompilation;
  9170. protected _kernel: number;
  9171. protected _idealKernel: number;
  9172. protected _packedFloat: boolean;
  9173. private _staticDefines;
  9174. /**
  9175. * Sets the length in pixels of the blur sample region
  9176. */
  9177. /**
  9178. * Gets the length in pixels of the blur sample region
  9179. */
  9180. kernel: number;
  9181. /**
  9182. * Sets wether or not the blur needs to unpack/repack floats
  9183. */
  9184. /**
  9185. * Gets wether or not the blur is unpacking/repacking floats
  9186. */
  9187. packedFloat: boolean;
  9188. /**
  9189. * Creates a new instance BlurPostProcess
  9190. * @param name The name of the effect.
  9191. * @param direction The direction in which to blur the image.
  9192. * @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.
  9193. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9194. * @param camera The camera to apply the render pass to.
  9195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9196. * @param engine The engine which the post process will be applied. (default: current engine)
  9197. * @param reusable If the post process can be reused on the same frame. (default: false)
  9198. * @param textureType Type of textures used when performing the post process. (default: 0)
  9199. * @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)
  9200. */
  9201. constructor(name: string,
  9202. /** The direction in which to blur the image. */
  9203. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9204. /**
  9205. * Updates the effect with the current post process compile time values and recompiles the shader.
  9206. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9207. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9208. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9209. * @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
  9210. * @param onCompiled Called when the shader has been compiled.
  9211. * @param onError Called if there is an error when compiling a shader.
  9212. */
  9213. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9214. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9215. /**
  9216. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9217. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9218. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9219. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9220. * The gaps between physical kernels are compensated for in the weighting of the samples
  9221. * @param idealKernel Ideal blur kernel.
  9222. * @return Nearest best kernel.
  9223. */
  9224. protected _nearestBestKernel(idealKernel: number): number;
  9225. /**
  9226. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9227. * @param x The point on the Gaussian distribution to sample.
  9228. * @return the value of the Gaussian function at x.
  9229. */
  9230. protected _gaussianWeight(x: number): number;
  9231. /**
  9232. * Generates a string that can be used as a floating point number in GLSL.
  9233. * @param x Value to print.
  9234. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9235. * @return GLSL float string.
  9236. */
  9237. protected _glslFloat(x: number, decimalFigures?: number): string;
  9238. }
  9239. }
  9240. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9241. /** @hidden */
  9242. export var shadowMapPixelShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9248. /** @hidden */
  9249. export var bonesDeclaration: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9255. /** @hidden */
  9256. export var morphTargetsVertexGlobalDeclaration: {
  9257. name: string;
  9258. shader: string;
  9259. };
  9260. }
  9261. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9262. /** @hidden */
  9263. export var morphTargetsVertexDeclaration: {
  9264. name: string;
  9265. shader: string;
  9266. };
  9267. }
  9268. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9269. /** @hidden */
  9270. export var instancesDeclaration: {
  9271. name: string;
  9272. shader: string;
  9273. };
  9274. }
  9275. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9276. /** @hidden */
  9277. export var helperFunctions: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9283. /** @hidden */
  9284. export var morphTargetsVertex: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9290. /** @hidden */
  9291. export var instancesVertex: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9297. /** @hidden */
  9298. export var bonesVertex: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9304. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9305. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9309. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9310. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9311. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9312. /** @hidden */
  9313. export var shadowMapVertexShader: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9319. /** @hidden */
  9320. export var depthBoxBlurPixelShader: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9326. import { Nullable } from "babylonjs/types";
  9327. import { Scene } from "babylonjs/scene";
  9328. import { Matrix } from "babylonjs/Maths/math";
  9329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9331. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9332. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9333. import { Effect } from "babylonjs/Materials/effect";
  9334. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9335. import "babylonjs/Shaders/shadowMap.fragment";
  9336. import "babylonjs/Shaders/shadowMap.vertex";
  9337. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9338. import { Observable } from "babylonjs/Misc/observable";
  9339. /**
  9340. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9341. */
  9342. export interface ICustomShaderOptions {
  9343. /**
  9344. * Gets or sets the custom shader name to use
  9345. */
  9346. shaderName: string;
  9347. /**
  9348. * The list of attribute names used in the shader
  9349. */
  9350. attributes?: string[];
  9351. /**
  9352. * The list of unifrom names used in the shader
  9353. */
  9354. uniforms?: string[];
  9355. /**
  9356. * The list of sampler names used in the shader
  9357. */
  9358. samplers?: string[];
  9359. /**
  9360. * The list of defines used in the shader
  9361. */
  9362. defines?: string[];
  9363. }
  9364. /**
  9365. * Interface to implement to create a shadow generator compatible with BJS.
  9366. */
  9367. export interface IShadowGenerator {
  9368. /**
  9369. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9370. * @returns The render target texture if present otherwise, null
  9371. */
  9372. getShadowMap(): Nullable<RenderTargetTexture>;
  9373. /**
  9374. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9375. * @returns The render target texture if the shadow map is present otherwise, null
  9376. */
  9377. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9378. /**
  9379. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9380. * @param subMesh The submesh we want to render in the shadow map
  9381. * @param useInstances Defines wether will draw in the map using instances
  9382. * @returns true if ready otherwise, false
  9383. */
  9384. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9385. /**
  9386. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9387. * @param defines Defines of the material we want to update
  9388. * @param lightIndex Index of the light in the enabled light list of the material
  9389. */
  9390. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9391. /**
  9392. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9393. * defined in the generator but impacting the effect).
  9394. * It implies the unifroms available on the materials are the standard BJS ones.
  9395. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9396. * @param effect The effect we are binfing the information for
  9397. */
  9398. bindShadowLight(lightIndex: string, effect: Effect): void;
  9399. /**
  9400. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9401. * (eq to shadow prjection matrix * light transform matrix)
  9402. * @returns The transform matrix used to create the shadow map
  9403. */
  9404. getTransformMatrix(): Matrix;
  9405. /**
  9406. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9407. * Cube and 2D textures for instance.
  9408. */
  9409. recreateShadowMap(): void;
  9410. /**
  9411. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9412. * @param onCompiled Callback triggered at the and of the effects compilation
  9413. * @param options Sets of optional options forcing the compilation with different modes
  9414. */
  9415. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9416. useInstances: boolean;
  9417. }>): void;
  9418. /**
  9419. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9420. * @param options Sets of optional options forcing the compilation with different modes
  9421. * @returns A promise that resolves when the compilation completes
  9422. */
  9423. forceCompilationAsync(options?: Partial<{
  9424. useInstances: boolean;
  9425. }>): Promise<void>;
  9426. /**
  9427. * Serializes the shadow generator setup to a json object.
  9428. * @returns The serialized JSON object
  9429. */
  9430. serialize(): any;
  9431. /**
  9432. * Disposes the Shadow map and related Textures and effects.
  9433. */
  9434. dispose(): void;
  9435. }
  9436. /**
  9437. * Default implementation IShadowGenerator.
  9438. * This is the main object responsible of generating shadows in the framework.
  9439. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9440. */
  9441. export class ShadowGenerator implements IShadowGenerator {
  9442. /**
  9443. * Shadow generator mode None: no filtering applied.
  9444. */
  9445. static readonly FILTER_NONE: number;
  9446. /**
  9447. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9448. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9449. */
  9450. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9451. /**
  9452. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9453. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9454. */
  9455. static readonly FILTER_POISSONSAMPLING: number;
  9456. /**
  9457. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9458. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9459. */
  9460. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9461. /**
  9462. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9463. * edge artifacts on steep falloff.
  9464. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9465. */
  9466. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9467. /**
  9468. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9469. * edge artifacts on steep falloff.
  9470. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9471. */
  9472. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9473. /**
  9474. * Shadow generator mode PCF: Percentage Closer Filtering
  9475. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9476. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9477. */
  9478. static readonly FILTER_PCF: number;
  9479. /**
  9480. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9481. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9482. * Contact Hardening
  9483. */
  9484. static readonly FILTER_PCSS: number;
  9485. /**
  9486. * Reserved for PCF and PCSS
  9487. * Highest Quality.
  9488. *
  9489. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9490. *
  9491. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9492. */
  9493. static readonly QUALITY_HIGH: number;
  9494. /**
  9495. * Reserved for PCF and PCSS
  9496. * Good tradeoff for quality/perf cross devices
  9497. *
  9498. * Execute PCF on a 3*3 kernel.
  9499. *
  9500. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9501. */
  9502. static readonly QUALITY_MEDIUM: number;
  9503. /**
  9504. * Reserved for PCF and PCSS
  9505. * The lowest quality but the fastest.
  9506. *
  9507. * Execute PCF on a 1*1 kernel.
  9508. *
  9509. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9510. */
  9511. static readonly QUALITY_LOW: number;
  9512. /** Gets or sets the custom shader name to use */
  9513. customShaderOptions: ICustomShaderOptions;
  9514. /**
  9515. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9516. */
  9517. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9518. private _bias;
  9519. /**
  9520. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9521. */
  9522. /**
  9523. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9524. */
  9525. bias: number;
  9526. private _normalBias;
  9527. /**
  9528. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9529. */
  9530. /**
  9531. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9532. */
  9533. normalBias: number;
  9534. private _blurBoxOffset;
  9535. /**
  9536. * Gets the blur box offset: offset applied during the blur pass.
  9537. * Only useful if useKernelBlur = false
  9538. */
  9539. /**
  9540. * Sets the blur box offset: offset applied during the blur pass.
  9541. * Only useful if useKernelBlur = false
  9542. */
  9543. blurBoxOffset: number;
  9544. private _blurScale;
  9545. /**
  9546. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9547. * 2 means half of the size.
  9548. */
  9549. /**
  9550. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9551. * 2 means half of the size.
  9552. */
  9553. blurScale: number;
  9554. private _blurKernel;
  9555. /**
  9556. * Gets the blur kernel: kernel size of the blur pass.
  9557. * Only useful if useKernelBlur = true
  9558. */
  9559. /**
  9560. * Sets the blur kernel: kernel size of the blur pass.
  9561. * Only useful if useKernelBlur = true
  9562. */
  9563. blurKernel: number;
  9564. private _useKernelBlur;
  9565. /**
  9566. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9567. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9568. */
  9569. /**
  9570. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9571. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9572. */
  9573. useKernelBlur: boolean;
  9574. private _depthScale;
  9575. /**
  9576. * Gets the depth scale used in ESM mode.
  9577. */
  9578. /**
  9579. * Sets the depth scale used in ESM mode.
  9580. * This can override the scale stored on the light.
  9581. */
  9582. depthScale: number;
  9583. private _filter;
  9584. /**
  9585. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9586. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9587. */
  9588. /**
  9589. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9590. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9591. */
  9592. filter: number;
  9593. /**
  9594. * Gets if the current filter is set to Poisson Sampling.
  9595. */
  9596. /**
  9597. * Sets the current filter to Poisson Sampling.
  9598. */
  9599. usePoissonSampling: boolean;
  9600. /**
  9601. * Gets if the current filter is set to ESM.
  9602. */
  9603. /**
  9604. * Sets the current filter is to ESM.
  9605. */
  9606. useExponentialShadowMap: boolean;
  9607. /**
  9608. * Gets if the current filter is set to filtered ESM.
  9609. */
  9610. /**
  9611. * Gets if the current filter is set to filtered ESM.
  9612. */
  9613. useBlurExponentialShadowMap: boolean;
  9614. /**
  9615. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9616. * exponential to prevent steep falloff artifacts).
  9617. */
  9618. /**
  9619. * Sets the current filter to "close ESM" (using the inverse of the
  9620. * exponential to prevent steep falloff artifacts).
  9621. */
  9622. useCloseExponentialShadowMap: boolean;
  9623. /**
  9624. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9625. * exponential to prevent steep falloff artifacts).
  9626. */
  9627. /**
  9628. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9629. * exponential to prevent steep falloff artifacts).
  9630. */
  9631. useBlurCloseExponentialShadowMap: boolean;
  9632. /**
  9633. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9634. */
  9635. /**
  9636. * Sets the current filter to "PCF" (percentage closer filtering).
  9637. */
  9638. usePercentageCloserFiltering: boolean;
  9639. private _filteringQuality;
  9640. /**
  9641. * Gets the PCF or PCSS Quality.
  9642. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9643. */
  9644. /**
  9645. * Sets the PCF or PCSS Quality.
  9646. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9647. */
  9648. filteringQuality: number;
  9649. /**
  9650. * Gets if the current filter is set to "PCSS" (contact hardening).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCSS" (contact hardening).
  9654. */
  9655. useContactHardeningShadow: boolean;
  9656. private _contactHardeningLightSizeUVRatio;
  9657. /**
  9658. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9659. * Using a ratio helps keeping shape stability independently of the map size.
  9660. *
  9661. * It does not account for the light projection as it was having too much
  9662. * instability during the light setup or during light position changes.
  9663. *
  9664. * Only valid if useContactHardeningShadow is true.
  9665. */
  9666. /**
  9667. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9668. * Using a ratio helps keeping shape stability independently of the map size.
  9669. *
  9670. * It does not account for the light projection as it was having too much
  9671. * instability during the light setup or during light position changes.
  9672. *
  9673. * Only valid if useContactHardeningShadow is true.
  9674. */
  9675. contactHardeningLightSizeUVRatio: number;
  9676. private _darkness;
  9677. /**
  9678. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9679. * 0 means strongest and 1 would means no shadow.
  9680. * @returns the darkness.
  9681. */
  9682. getDarkness(): number;
  9683. /**
  9684. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9685. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9686. * @returns the shadow generator allowing fluent coding.
  9687. */
  9688. setDarkness(darkness: number): ShadowGenerator;
  9689. private _transparencyShadow;
  9690. /**
  9691. * Sets the ability to have transparent shadow (boolean).
  9692. * @param transparent True if transparent else False
  9693. * @returns the shadow generator allowing fluent coding
  9694. */
  9695. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9696. private _shadowMap;
  9697. private _shadowMap2;
  9698. /**
  9699. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9700. * @returns The render target texture if present otherwise, null
  9701. */
  9702. getShadowMap(): Nullable<RenderTargetTexture>;
  9703. /**
  9704. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9705. * @returns The render target texture if the shadow map is present otherwise, null
  9706. */
  9707. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9708. /**
  9709. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9710. * @param mesh Mesh to add
  9711. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9712. * @returns the Shadow Generator itself
  9713. */
  9714. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9715. /**
  9716. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9717. * @param mesh Mesh to remove
  9718. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9719. * @returns the Shadow Generator itself
  9720. */
  9721. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9722. /**
  9723. * Controls the extent to which the shadows fade out at the edge of the frustum
  9724. * Used only by directionals and spots
  9725. */
  9726. frustumEdgeFalloff: number;
  9727. private _light;
  9728. /**
  9729. * Returns the associated light object.
  9730. * @returns the light generating the shadow
  9731. */
  9732. getLight(): IShadowLight;
  9733. /**
  9734. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9735. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9736. * It might on the other hand introduce peter panning.
  9737. */
  9738. forceBackFacesOnly: boolean;
  9739. private _scene;
  9740. private _lightDirection;
  9741. private _effect;
  9742. private _viewMatrix;
  9743. private _projectionMatrix;
  9744. private _transformMatrix;
  9745. private _cachedPosition;
  9746. private _cachedDirection;
  9747. private _cachedDefines;
  9748. private _currentRenderID;
  9749. private _boxBlurPostprocess;
  9750. private _kernelBlurXPostprocess;
  9751. private _kernelBlurYPostprocess;
  9752. private _blurPostProcesses;
  9753. private _mapSize;
  9754. private _currentFaceIndex;
  9755. private _currentFaceIndexCache;
  9756. private _textureType;
  9757. private _defaultTextureMatrix;
  9758. /** @hidden */
  9759. static _SceneComponentInitialization: (scene: Scene) => void;
  9760. /**
  9761. * Creates a ShadowGenerator object.
  9762. * A ShadowGenerator is the required tool to use the shadows.
  9763. * Each light casting shadows needs to use its own ShadowGenerator.
  9764. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9765. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9766. * @param light The light object generating the shadows.
  9767. * @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.
  9768. */
  9769. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9770. private _initializeGenerator;
  9771. private _initializeShadowMap;
  9772. private _initializeBlurRTTAndPostProcesses;
  9773. private _renderForShadowMap;
  9774. private _renderSubMeshForShadowMap;
  9775. private _applyFilterValues;
  9776. /**
  9777. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9778. * @param onCompiled Callback triggered at the and of the effects compilation
  9779. * @param options Sets of optional options forcing the compilation with different modes
  9780. */
  9781. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9782. useInstances: boolean;
  9783. }>): void;
  9784. /**
  9785. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9786. * @param options Sets of optional options forcing the compilation with different modes
  9787. * @returns A promise that resolves when the compilation completes
  9788. */
  9789. forceCompilationAsync(options?: Partial<{
  9790. useInstances: boolean;
  9791. }>): Promise<void>;
  9792. /**
  9793. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9794. * @param subMesh The submesh we want to render in the shadow map
  9795. * @param useInstances Defines wether will draw in the map using instances
  9796. * @returns true if ready otherwise, false
  9797. */
  9798. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9799. /**
  9800. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9801. * @param defines Defines of the material we want to update
  9802. * @param lightIndex Index of the light in the enabled light list of the material
  9803. */
  9804. prepareDefines(defines: any, lightIndex: number): void;
  9805. /**
  9806. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9807. * defined in the generator but impacting the effect).
  9808. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9809. * @param effect The effect we are binfing the information for
  9810. */
  9811. bindShadowLight(lightIndex: string, effect: Effect): void;
  9812. /**
  9813. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9814. * (eq to shadow prjection matrix * light transform matrix)
  9815. * @returns The transform matrix used to create the shadow map
  9816. */
  9817. getTransformMatrix(): Matrix;
  9818. /**
  9819. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9820. * Cube and 2D textures for instance.
  9821. */
  9822. recreateShadowMap(): void;
  9823. private _disposeBlurPostProcesses;
  9824. private _disposeRTTandPostProcesses;
  9825. /**
  9826. * Disposes the ShadowGenerator.
  9827. * Returns nothing.
  9828. */
  9829. dispose(): void;
  9830. /**
  9831. * Serializes the shadow generator setup to a json object.
  9832. * @returns The serialized JSON object
  9833. */
  9834. serialize(): any;
  9835. /**
  9836. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9837. * @param parsedShadowGenerator The JSON object to parse
  9838. * @param scene The scene to create the shadow map for
  9839. * @returns The parsed shadow generator
  9840. */
  9841. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9842. }
  9843. }
  9844. declare module "babylonjs/Lights/light" {
  9845. import { Nullable } from "babylonjs/types";
  9846. import { Scene } from "babylonjs/scene";
  9847. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9848. import { Node } from "babylonjs/node";
  9849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9850. import { Effect } from "babylonjs/Materials/effect";
  9851. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9852. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9853. /**
  9854. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9855. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9856. * 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.
  9857. */
  9858. export abstract class Light extends Node {
  9859. /**
  9860. * Falloff Default: light is falling off following the material specification:
  9861. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9862. */
  9863. static readonly FALLOFF_DEFAULT: number;
  9864. /**
  9865. * Falloff Physical: light is falling off following the inverse squared distance law.
  9866. */
  9867. static readonly FALLOFF_PHYSICAL: number;
  9868. /**
  9869. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9870. * to enhance interoperability with other engines.
  9871. */
  9872. static readonly FALLOFF_GLTF: number;
  9873. /**
  9874. * Falloff Standard: light is falling off like in the standard material
  9875. * to enhance interoperability with other materials.
  9876. */
  9877. static readonly FALLOFF_STANDARD: number;
  9878. /**
  9879. * If every light affecting the material is in this lightmapMode,
  9880. * material.lightmapTexture adds or multiplies
  9881. * (depends on material.useLightmapAsShadowmap)
  9882. * after every other light calculations.
  9883. */
  9884. static readonly LIGHTMAP_DEFAULT: number;
  9885. /**
  9886. * material.lightmapTexture as only diffuse lighting from this light
  9887. * adds only specular lighting from this light
  9888. * adds dynamic shadows
  9889. */
  9890. static readonly LIGHTMAP_SPECULAR: number;
  9891. /**
  9892. * material.lightmapTexture as only lighting
  9893. * no light calculation from this light
  9894. * only adds dynamic shadows from this light
  9895. */
  9896. static readonly LIGHTMAP_SHADOWSONLY: number;
  9897. /**
  9898. * Each light type uses the default quantity according to its type:
  9899. * point/spot lights use luminous intensity
  9900. * directional lights use illuminance
  9901. */
  9902. static readonly INTENSITYMODE_AUTOMATIC: number;
  9903. /**
  9904. * lumen (lm)
  9905. */
  9906. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9907. /**
  9908. * candela (lm/sr)
  9909. */
  9910. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9911. /**
  9912. * lux (lm/m^2)
  9913. */
  9914. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9915. /**
  9916. * nit (cd/m^2)
  9917. */
  9918. static readonly INTENSITYMODE_LUMINANCE: number;
  9919. /**
  9920. * Light type const id of the point light.
  9921. */
  9922. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9923. /**
  9924. * Light type const id of the directional light.
  9925. */
  9926. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9927. /**
  9928. * Light type const id of the spot light.
  9929. */
  9930. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9931. /**
  9932. * Light type const id of the hemispheric light.
  9933. */
  9934. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9935. /**
  9936. * Diffuse gives the basic color to an object.
  9937. */
  9938. diffuse: Color3;
  9939. /**
  9940. * Specular produces a highlight color on an object.
  9941. * Note: This is note affecting PBR materials.
  9942. */
  9943. specular: Color3;
  9944. /**
  9945. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9946. * falling off base on range or angle.
  9947. * This can be set to any values in Light.FALLOFF_x.
  9948. *
  9949. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9950. * other types of materials.
  9951. */
  9952. falloffType: number;
  9953. /**
  9954. * Strength of the light.
  9955. * Note: By default it is define in the framework own unit.
  9956. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9957. */
  9958. intensity: number;
  9959. private _range;
  9960. protected _inverseSquaredRange: number;
  9961. /**
  9962. * Defines how far from the source the light is impacting in scene units.
  9963. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9964. */
  9965. /**
  9966. * Defines how far from the source the light is impacting in scene units.
  9967. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9968. */
  9969. range: number;
  9970. /**
  9971. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9972. * of light.
  9973. */
  9974. private _photometricScale;
  9975. private _intensityMode;
  9976. /**
  9977. * Gets the photometric scale used to interpret the intensity.
  9978. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9979. */
  9980. /**
  9981. * Sets the photometric scale used to interpret the intensity.
  9982. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9983. */
  9984. intensityMode: number;
  9985. private _radius;
  9986. /**
  9987. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9988. */
  9989. /**
  9990. * sets the light radius used by PBR Materials to simulate soft area lights.
  9991. */
  9992. radius: number;
  9993. private _renderPriority;
  9994. /**
  9995. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9996. * exceeding the number allowed of the materials.
  9997. */
  9998. renderPriority: number;
  9999. private _shadowEnabled;
  10000. /**
  10001. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10002. * the current shadow generator.
  10003. */
  10004. /**
  10005. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10006. * the current shadow generator.
  10007. */
  10008. shadowEnabled: boolean;
  10009. private _includedOnlyMeshes;
  10010. /**
  10011. * Gets the only meshes impacted by this light.
  10012. */
  10013. /**
  10014. * Sets the only meshes impacted by this light.
  10015. */
  10016. includedOnlyMeshes: AbstractMesh[];
  10017. private _excludedMeshes;
  10018. /**
  10019. * Gets the meshes not impacted by this light.
  10020. */
  10021. /**
  10022. * Sets the meshes not impacted by this light.
  10023. */
  10024. excludedMeshes: AbstractMesh[];
  10025. private _excludeWithLayerMask;
  10026. /**
  10027. * Gets the layer id use to find what meshes are not impacted by the light.
  10028. * Inactive if 0
  10029. */
  10030. /**
  10031. * Sets the layer id use to find what meshes are not impacted by the light.
  10032. * Inactive if 0
  10033. */
  10034. excludeWithLayerMask: number;
  10035. private _includeOnlyWithLayerMask;
  10036. /**
  10037. * Gets the layer id use to find what meshes are impacted by the light.
  10038. * Inactive if 0
  10039. */
  10040. /**
  10041. * Sets the layer id use to find what meshes are impacted by the light.
  10042. * Inactive if 0
  10043. */
  10044. includeOnlyWithLayerMask: number;
  10045. private _lightmapMode;
  10046. /**
  10047. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10048. */
  10049. /**
  10050. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10051. */
  10052. lightmapMode: number;
  10053. /**
  10054. * Shadow generator associted to the light.
  10055. * @hidden Internal use only.
  10056. */
  10057. _shadowGenerator: Nullable<IShadowGenerator>;
  10058. /**
  10059. * @hidden Internal use only.
  10060. */
  10061. _excludedMeshesIds: string[];
  10062. /**
  10063. * @hidden Internal use only.
  10064. */
  10065. _includedOnlyMeshesIds: string[];
  10066. /**
  10067. * The current light unifom buffer.
  10068. * @hidden Internal use only.
  10069. */
  10070. _uniformBuffer: UniformBuffer;
  10071. /**
  10072. * Creates a Light object in the scene.
  10073. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10074. * @param name The firendly name of the light
  10075. * @param scene The scene the light belongs too
  10076. */
  10077. constructor(name: string, scene: Scene);
  10078. protected abstract _buildUniformLayout(): void;
  10079. /**
  10080. * Sets the passed Effect "effect" with the Light information.
  10081. * @param effect The effect to update
  10082. * @param lightIndex The index of the light in the effect to update
  10083. * @returns The light
  10084. */
  10085. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10086. /**
  10087. * Returns the string "Light".
  10088. * @returns the class name
  10089. */
  10090. getClassName(): string;
  10091. /** @hidden */
  10092. readonly _isLight: boolean;
  10093. /**
  10094. * Converts the light information to a readable string for debug purpose.
  10095. * @param fullDetails Supports for multiple levels of logging within scene loading
  10096. * @returns the human readable light info
  10097. */
  10098. toString(fullDetails?: boolean): string;
  10099. /** @hidden */
  10100. protected _syncParentEnabledState(): void;
  10101. /**
  10102. * Set the enabled state of this node.
  10103. * @param value - the new enabled state
  10104. */
  10105. setEnabled(value: boolean): void;
  10106. /**
  10107. * Returns the Light associated shadow generator if any.
  10108. * @return the associated shadow generator.
  10109. */
  10110. getShadowGenerator(): Nullable<IShadowGenerator>;
  10111. /**
  10112. * Returns a Vector3, the absolute light position in the World.
  10113. * @returns the world space position of the light
  10114. */
  10115. getAbsolutePosition(): Vector3;
  10116. /**
  10117. * Specifies if the light will affect the passed mesh.
  10118. * @param mesh The mesh to test against the light
  10119. * @return true the mesh is affected otherwise, false.
  10120. */
  10121. canAffectMesh(mesh: AbstractMesh): boolean;
  10122. /**
  10123. * Sort function to order lights for rendering.
  10124. * @param a First Light object to compare to second.
  10125. * @param b Second Light object to compare first.
  10126. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10127. */
  10128. static CompareLightsPriority(a: Light, b: Light): number;
  10129. /**
  10130. * Releases resources associated with this node.
  10131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10133. */
  10134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10135. /**
  10136. * Returns the light type ID (integer).
  10137. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10138. */
  10139. getTypeID(): number;
  10140. /**
  10141. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10142. * @returns the scaled intensity in intensity mode unit
  10143. */
  10144. getScaledIntensity(): number;
  10145. /**
  10146. * Returns a new Light object, named "name", from the current one.
  10147. * @param name The name of the cloned light
  10148. * @returns the new created light
  10149. */
  10150. clone(name: string): Nullable<Light>;
  10151. /**
  10152. * Serializes the current light into a Serialization object.
  10153. * @returns the serialized object.
  10154. */
  10155. serialize(): any;
  10156. /**
  10157. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10158. * This new light is named "name" and added to the passed scene.
  10159. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10160. * @param name The friendly name of the light
  10161. * @param scene The scene the new light will belong to
  10162. * @returns the constructor function
  10163. */
  10164. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10165. /**
  10166. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10167. * @param parsedLight The JSON representation of the light
  10168. * @param scene The scene to create the parsed light in
  10169. * @returns the created light after parsing
  10170. */
  10171. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10172. private _hookArrayForExcluded;
  10173. private _hookArrayForIncludedOnly;
  10174. private _resyncMeshes;
  10175. /**
  10176. * Forces the meshes to update their light related information in their rendering used effects
  10177. * @hidden Internal Use Only
  10178. */
  10179. _markMeshesAsLightDirty(): void;
  10180. /**
  10181. * Recomputes the cached photometric scale if needed.
  10182. */
  10183. private _computePhotometricScale;
  10184. /**
  10185. * Returns the Photometric Scale according to the light type and intensity mode.
  10186. */
  10187. private _getPhotometricScale;
  10188. /**
  10189. * Reorder the light in the scene according to their defined priority.
  10190. * @hidden Internal Use Only
  10191. */
  10192. _reorderLightsInScene(): void;
  10193. /**
  10194. * Prepares the list of defines specific to the light type.
  10195. * @param defines the list of defines
  10196. * @param lightIndex defines the index of the light for the effect
  10197. */
  10198. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10199. }
  10200. }
  10201. declare module "babylonjs/Actions/action" {
  10202. import { Observable } from "babylonjs/Misc/observable";
  10203. import { Condition } from "babylonjs/Actions/condition";
  10204. import { ActionManager } from "babylonjs/Actions/actionManager";
  10205. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10206. /**
  10207. * Interface used to define Action
  10208. */
  10209. export interface IAction {
  10210. /**
  10211. * Trigger for the action
  10212. */
  10213. trigger: number;
  10214. /** the trigger, with or without parameters, for the action */
  10215. triggerOptions: any;
  10216. /**
  10217. * Gets the trigger parameters
  10218. * @returns the trigger parameters
  10219. */
  10220. getTriggerParameter(): any;
  10221. /**
  10222. * Internal only - executes current action event
  10223. * @hidden
  10224. */
  10225. _executeCurrent(evt?: ActionEvent): void;
  10226. /**
  10227. * Serialize placeholder for child classes
  10228. * @param parent of child
  10229. * @returns the serialized object
  10230. */
  10231. serialize(parent: any): any;
  10232. }
  10233. /**
  10234. * The action to be carried out following a trigger
  10235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10236. */
  10237. export class Action implements IAction {
  10238. /** the trigger, with or without parameters, for the action */
  10239. triggerOptions: any;
  10240. /**
  10241. * Trigger for the action
  10242. */
  10243. trigger: number;
  10244. /**
  10245. * Internal only - manager for action
  10246. * @hidden
  10247. */
  10248. _actionManager: ActionManager;
  10249. private _nextActiveAction;
  10250. private _child;
  10251. private _condition?;
  10252. private _triggerParameter;
  10253. /**
  10254. * An event triggered prior to action being executed.
  10255. */
  10256. onBeforeExecuteObservable: Observable<Action>;
  10257. /**
  10258. * Creates a new Action
  10259. * @param triggerOptions the trigger, with or without parameters, for the action
  10260. * @param condition an optional determinant of action
  10261. */
  10262. constructor(
  10263. /** the trigger, with or without parameters, for the action */
  10264. triggerOptions: any, condition?: Condition);
  10265. /**
  10266. * Internal only
  10267. * @hidden
  10268. */
  10269. _prepare(): void;
  10270. /**
  10271. * Gets the trigger parameters
  10272. * @returns the trigger parameters
  10273. */
  10274. getTriggerParameter(): any;
  10275. /**
  10276. * Internal only - executes current action event
  10277. * @hidden
  10278. */
  10279. _executeCurrent(evt?: ActionEvent): void;
  10280. /**
  10281. * Execute placeholder for child classes
  10282. * @param evt optional action event
  10283. */
  10284. execute(evt?: ActionEvent): void;
  10285. /**
  10286. * Skips to next active action
  10287. */
  10288. skipToNextActiveAction(): void;
  10289. /**
  10290. * Adds action to chain of actions, may be a DoNothingAction
  10291. * @param action defines the next action to execute
  10292. * @returns The action passed in
  10293. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10294. */
  10295. then(action: Action): Action;
  10296. /**
  10297. * Internal only
  10298. * @hidden
  10299. */
  10300. _getProperty(propertyPath: string): string;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. _getEffectiveTarget(target: any, propertyPath: string): any;
  10306. /**
  10307. * Serialize placeholder for child classes
  10308. * @param parent of child
  10309. * @returns the serialized object
  10310. */
  10311. serialize(parent: any): any;
  10312. /**
  10313. * Internal only called by serialize
  10314. * @hidden
  10315. */
  10316. protected _serialize(serializedAction: any, parent?: any): any;
  10317. /**
  10318. * Internal only
  10319. * @hidden
  10320. */
  10321. static _SerializeValueAsString: (value: any) => string;
  10322. /**
  10323. * Internal only
  10324. * @hidden
  10325. */
  10326. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10327. name: string;
  10328. targetType: string;
  10329. value: string;
  10330. };
  10331. }
  10332. }
  10333. declare module "babylonjs/Actions/condition" {
  10334. import { ActionManager } from "babylonjs/Actions/actionManager";
  10335. /**
  10336. * A Condition applied to an Action
  10337. */
  10338. export class Condition {
  10339. /**
  10340. * Internal only - manager for action
  10341. * @hidden
  10342. */
  10343. _actionManager: ActionManager;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. _evaluationId: number;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. _currentResult: boolean;
  10354. /**
  10355. * Creates a new Condition
  10356. * @param actionManager the manager of the action the condition is applied to
  10357. */
  10358. constructor(actionManager: ActionManager);
  10359. /**
  10360. * Check if the current condition is valid
  10361. * @returns a boolean
  10362. */
  10363. isValid(): boolean;
  10364. /**
  10365. * Internal only
  10366. * @hidden
  10367. */
  10368. _getProperty(propertyPath: string): string;
  10369. /**
  10370. * Internal only
  10371. * @hidden
  10372. */
  10373. _getEffectiveTarget(target: any, propertyPath: string): any;
  10374. /**
  10375. * Serialize placeholder for child classes
  10376. * @returns the serialized object
  10377. */
  10378. serialize(): any;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. protected _serialize(serializedCondition: any): any;
  10384. }
  10385. /**
  10386. * Defines specific conditional operators as extensions of Condition
  10387. */
  10388. export class ValueCondition extends Condition {
  10389. /** path to specify the property of the target the conditional operator uses */
  10390. propertyPath: string;
  10391. /** the value compared by the conditional operator against the current value of the property */
  10392. value: any;
  10393. /** the conditional operator, default ValueCondition.IsEqual */
  10394. operator: number;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private static _IsEqual;
  10400. /**
  10401. * Internal only
  10402. * @hidden
  10403. */
  10404. private static _IsDifferent;
  10405. /**
  10406. * Internal only
  10407. * @hidden
  10408. */
  10409. private static _IsGreater;
  10410. /**
  10411. * Internal only
  10412. * @hidden
  10413. */
  10414. private static _IsLesser;
  10415. /**
  10416. * returns the number for IsEqual
  10417. */
  10418. static readonly IsEqual: number;
  10419. /**
  10420. * Returns the number for IsDifferent
  10421. */
  10422. static readonly IsDifferent: number;
  10423. /**
  10424. * Returns the number for IsGreater
  10425. */
  10426. static readonly IsGreater: number;
  10427. /**
  10428. * Returns the number for IsLesser
  10429. */
  10430. static readonly IsLesser: number;
  10431. /**
  10432. * Internal only The action manager for the condition
  10433. * @hidden
  10434. */
  10435. _actionManager: ActionManager;
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. private _target;
  10441. /**
  10442. * Internal only
  10443. * @hidden
  10444. */
  10445. private _effectiveTarget;
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. private _property;
  10451. /**
  10452. * Creates a new ValueCondition
  10453. * @param actionManager manager for the action the condition applies to
  10454. * @param target for the action
  10455. * @param propertyPath path to specify the property of the target the conditional operator uses
  10456. * @param value the value compared by the conditional operator against the current value of the property
  10457. * @param operator the conditional operator, default ValueCondition.IsEqual
  10458. */
  10459. constructor(actionManager: ActionManager, target: any,
  10460. /** path to specify the property of the target the conditional operator uses */
  10461. propertyPath: string,
  10462. /** the value compared by the conditional operator against the current value of the property */
  10463. value: any,
  10464. /** the conditional operator, default ValueCondition.IsEqual */
  10465. operator?: number);
  10466. /**
  10467. * Compares the given value with the property value for the specified conditional operator
  10468. * @returns the result of the comparison
  10469. */
  10470. isValid(): boolean;
  10471. /**
  10472. * Serialize the ValueCondition into a JSON compatible object
  10473. * @returns serialization object
  10474. */
  10475. serialize(): any;
  10476. /**
  10477. * Gets the name of the conditional operator for the ValueCondition
  10478. * @param operator the conditional operator
  10479. * @returns the name
  10480. */
  10481. static GetOperatorName(operator: number): string;
  10482. }
  10483. /**
  10484. * Defines a predicate condition as an extension of Condition
  10485. */
  10486. export class PredicateCondition extends Condition {
  10487. /** defines the predicate function used to validate the condition */
  10488. predicate: () => boolean;
  10489. /**
  10490. * Internal only - manager for action
  10491. * @hidden
  10492. */
  10493. _actionManager: ActionManager;
  10494. /**
  10495. * Creates a new PredicateCondition
  10496. * @param actionManager manager for the action the condition applies to
  10497. * @param predicate defines the predicate function used to validate the condition
  10498. */
  10499. constructor(actionManager: ActionManager,
  10500. /** defines the predicate function used to validate the condition */
  10501. predicate: () => boolean);
  10502. /**
  10503. * @returns the validity of the predicate condition
  10504. */
  10505. isValid(): boolean;
  10506. }
  10507. /**
  10508. * Defines a state condition as an extension of Condition
  10509. */
  10510. export class StateCondition extends Condition {
  10511. /** Value to compare with target state */
  10512. value: string;
  10513. /**
  10514. * Internal only - manager for action
  10515. * @hidden
  10516. */
  10517. _actionManager: ActionManager;
  10518. /**
  10519. * Internal only
  10520. * @hidden
  10521. */
  10522. private _target;
  10523. /**
  10524. * Creates a new StateCondition
  10525. * @param actionManager manager for the action the condition applies to
  10526. * @param target of the condition
  10527. * @param value to compare with target state
  10528. */
  10529. constructor(actionManager: ActionManager, target: any,
  10530. /** Value to compare with target state */
  10531. value: string);
  10532. /**
  10533. * Gets a boolean indicating if the current condition is met
  10534. * @returns the validity of the state
  10535. */
  10536. isValid(): boolean;
  10537. /**
  10538. * Serialize the StateCondition into a JSON compatible object
  10539. * @returns serialization object
  10540. */
  10541. serialize(): any;
  10542. }
  10543. }
  10544. declare module "babylonjs/Actions/directActions" {
  10545. import { Action } from "babylonjs/Actions/action";
  10546. import { Condition } from "babylonjs/Actions/condition";
  10547. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10548. /**
  10549. * This defines an action responsible to toggle a boolean once triggered.
  10550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10551. */
  10552. export class SwitchBooleanAction extends Action {
  10553. /**
  10554. * The path to the boolean property in the target object
  10555. */
  10556. propertyPath: string;
  10557. private _target;
  10558. private _effectiveTarget;
  10559. private _property;
  10560. /**
  10561. * Instantiate the action
  10562. * @param triggerOptions defines the trigger options
  10563. * @param target defines the object containing the boolean
  10564. * @param propertyPath defines the path to the boolean property in the target object
  10565. * @param condition defines the trigger related conditions
  10566. */
  10567. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10568. /** @hidden */
  10569. _prepare(): void;
  10570. /**
  10571. * Execute the action toggle the boolean value.
  10572. */
  10573. execute(): void;
  10574. /**
  10575. * Serializes the actions and its related information.
  10576. * @param parent defines the object to serialize in
  10577. * @returns the serialized object
  10578. */
  10579. serialize(parent: any): any;
  10580. }
  10581. /**
  10582. * This defines an action responsible to set a the state field of the target
  10583. * to a desired value once triggered.
  10584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10585. */
  10586. export class SetStateAction extends Action {
  10587. /**
  10588. * The value to store in the state field.
  10589. */
  10590. value: string;
  10591. private _target;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the state property
  10596. * @param value defines the value to store in the state field
  10597. * @param condition defines the trigger related conditions
  10598. */
  10599. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10600. /**
  10601. * Execute the action and store the value on the target state property.
  10602. */
  10603. execute(): void;
  10604. /**
  10605. * Serializes the actions and its related information.
  10606. * @param parent defines the object to serialize in
  10607. * @returns the serialized object
  10608. */
  10609. serialize(parent: any): any;
  10610. }
  10611. /**
  10612. * This defines an action responsible to set a property of the target
  10613. * to a desired value once triggered.
  10614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10615. */
  10616. export class SetValueAction extends Action {
  10617. /**
  10618. * The path of the property to set in the target.
  10619. */
  10620. propertyPath: string;
  10621. /**
  10622. * The value to set in the property
  10623. */
  10624. value: any;
  10625. private _target;
  10626. private _effectiveTarget;
  10627. private _property;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param target defines the object containing the property
  10632. * @param propertyPath defines the path of the property to set in the target
  10633. * @param value defines the value to set in the property
  10634. * @param condition defines the trigger related conditions
  10635. */
  10636. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10637. /** @hidden */
  10638. _prepare(): void;
  10639. /**
  10640. * Execute the action and set the targetted property to the desired value.
  10641. */
  10642. execute(): void;
  10643. /**
  10644. * Serializes the actions and its related information.
  10645. * @param parent defines the object to serialize in
  10646. * @returns the serialized object
  10647. */
  10648. serialize(parent: any): any;
  10649. }
  10650. /**
  10651. * This defines an action responsible to increment the target value
  10652. * to a desired value once triggered.
  10653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10654. */
  10655. export class IncrementValueAction extends Action {
  10656. /**
  10657. * The path of the property to increment in the target.
  10658. */
  10659. propertyPath: string;
  10660. /**
  10661. * The value we should increment the property by.
  10662. */
  10663. value: any;
  10664. private _target;
  10665. private _effectiveTarget;
  10666. private _property;
  10667. /**
  10668. * Instantiate the action
  10669. * @param triggerOptions defines the trigger options
  10670. * @param target defines the object containing the property
  10671. * @param propertyPath defines the path of the property to increment in the target
  10672. * @param value defines the value value we should increment the property by
  10673. * @param condition defines the trigger related conditions
  10674. */
  10675. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10676. /** @hidden */
  10677. _prepare(): void;
  10678. /**
  10679. * Execute the action and increment the target of the value amount.
  10680. */
  10681. execute(): void;
  10682. /**
  10683. * Serializes the actions and its related information.
  10684. * @param parent defines the object to serialize in
  10685. * @returns the serialized object
  10686. */
  10687. serialize(parent: any): any;
  10688. }
  10689. /**
  10690. * This defines an action responsible to start an animation once triggered.
  10691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10692. */
  10693. export class PlayAnimationAction extends Action {
  10694. /**
  10695. * Where the animation should start (animation frame)
  10696. */
  10697. from: number;
  10698. /**
  10699. * Where the animation should stop (animation frame)
  10700. */
  10701. to: number;
  10702. /**
  10703. * Define if the animation should loop or stop after the first play.
  10704. */
  10705. loop?: boolean;
  10706. private _target;
  10707. /**
  10708. * Instantiate the action
  10709. * @param triggerOptions defines the trigger options
  10710. * @param target defines the target animation or animation name
  10711. * @param from defines from where the animation should start (animation frame)
  10712. * @param end defines where the animation should stop (animation frame)
  10713. * @param loop defines if the animation should loop or stop after the first play
  10714. * @param condition defines the trigger related conditions
  10715. */
  10716. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10717. /** @hidden */
  10718. _prepare(): void;
  10719. /**
  10720. * Execute the action and play the animation.
  10721. */
  10722. execute(): void;
  10723. /**
  10724. * Serializes the actions and its related information.
  10725. * @param parent defines the object to serialize in
  10726. * @returns the serialized object
  10727. */
  10728. serialize(parent: any): any;
  10729. }
  10730. /**
  10731. * This defines an action responsible to stop an animation once triggered.
  10732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10733. */
  10734. export class StopAnimationAction extends Action {
  10735. private _target;
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param target defines the target animation or animation name
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, target: any, condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and stop the animation.
  10747. */
  10748. execute(): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible that does nothing once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class DoNothingAction extends Action {
  10761. /**
  10762. * Instantiate the action
  10763. * @param triggerOptions defines the trigger options
  10764. * @param condition defines the trigger related conditions
  10765. */
  10766. constructor(triggerOptions?: any, condition?: Condition);
  10767. /**
  10768. * Execute the action and do nothing.
  10769. */
  10770. execute(): void;
  10771. /**
  10772. * Serializes the actions and its related information.
  10773. * @param parent defines the object to serialize in
  10774. * @returns the serialized object
  10775. */
  10776. serialize(parent: any): any;
  10777. }
  10778. /**
  10779. * This defines an action responsible to trigger several actions once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class CombineAction extends Action {
  10783. /**
  10784. * The list of aggregated animations to run.
  10785. */
  10786. children: Action[];
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param children defines the list of aggregated animations to run
  10791. * @param condition defines the trigger related conditions
  10792. */
  10793. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10794. /** @hidden */
  10795. _prepare(): void;
  10796. /**
  10797. * Execute the action and executes all the aggregated actions.
  10798. */
  10799. execute(evt: ActionEvent): void;
  10800. /**
  10801. * Serializes the actions and its related information.
  10802. * @param parent defines the object to serialize in
  10803. * @returns the serialized object
  10804. */
  10805. serialize(parent: any): any;
  10806. }
  10807. /**
  10808. * This defines an action responsible to run code (external event) once triggered.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ExecuteCodeAction extends Action {
  10812. /**
  10813. * The callback function to run.
  10814. */
  10815. func: (evt: ActionEvent) => void;
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param func defines the callback function to run
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10823. /**
  10824. * Execute the action and run the attached code.
  10825. */
  10826. execute(evt: ActionEvent): void;
  10827. }
  10828. /**
  10829. * This defines an action responsible to set the parent property of the target once triggered.
  10830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10831. */
  10832. export class SetParentAction extends Action {
  10833. private _parent;
  10834. private _target;
  10835. /**
  10836. * Instantiate the action
  10837. * @param triggerOptions defines the trigger options
  10838. * @param target defines the target containing the parent property
  10839. * @param parent defines from where the animation should start (animation frame)
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10843. /** @hidden */
  10844. _prepare(): void;
  10845. /**
  10846. * Execute the action and set the parent property.
  10847. */
  10848. execute(): void;
  10849. /**
  10850. * Serializes the actions and its related information.
  10851. * @param parent defines the object to serialize in
  10852. * @returns the serialized object
  10853. */
  10854. serialize(parent: any): any;
  10855. }
  10856. }
  10857. declare module "babylonjs/Actions/abstractActionManager" {
  10858. import { IDisposable } from "babylonjs/scene";
  10859. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10860. import { IAction } from "babylonjs/Actions/action";
  10861. /**
  10862. * Abstract class used to decouple action Manager from scene and meshes.
  10863. * Do not instantiate.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export abstract class AbstractActionManager implements IDisposable {
  10867. /** Gets the list of active triggers */
  10868. static Triggers: {
  10869. [key: string]: number;
  10870. };
  10871. /** Gets the cursor to use when hovering items */
  10872. hoverCursor: string;
  10873. /** Gets the list of actions */
  10874. actions: IAction[];
  10875. /**
  10876. * Releases all associated resources
  10877. */
  10878. abstract dispose(): void;
  10879. /**
  10880. * Does this action manager has pointer triggers
  10881. */
  10882. abstract readonly hasPointerTriggers: boolean;
  10883. /**
  10884. * Does this action manager has pick triggers
  10885. */
  10886. abstract readonly hasPickTriggers: boolean;
  10887. /**
  10888. * Process a specific trigger
  10889. * @param trigger defines the trigger to process
  10890. * @param evt defines the event details to be processed
  10891. */
  10892. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10893. /**
  10894. * Does this action manager handles actions of any of the given triggers
  10895. * @param triggers defines the triggers to be tested
  10896. * @return a boolean indicating whether one (or more) of the triggers is handled
  10897. */
  10898. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10899. /**
  10900. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10901. * speed.
  10902. * @param triggerA defines the trigger to be tested
  10903. * @param triggerB defines the trigger to be tested
  10904. * @return a boolean indicating whether one (or more) of the triggers is handled
  10905. */
  10906. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10907. /**
  10908. * Does this action manager handles actions of a given trigger
  10909. * @param trigger defines the trigger to be tested
  10910. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10911. * @return whether the trigger is handled
  10912. */
  10913. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10914. /**
  10915. * Serialize this manager to a JSON object
  10916. * @param name defines the property name to store this manager
  10917. * @returns a JSON representation of this manager
  10918. */
  10919. abstract serialize(name: string): any;
  10920. /**
  10921. * Does exist one action manager with at least one trigger
  10922. **/
  10923. static readonly HasTriggers: boolean;
  10924. /**
  10925. * Does exist one action manager with at least one pick trigger
  10926. **/
  10927. static readonly HasPickTriggers: boolean;
  10928. /**
  10929. * Does exist one action manager that handles actions of a given trigger
  10930. * @param trigger defines the trigger to be tested
  10931. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10932. **/
  10933. static HasSpecificTrigger(trigger: number): boolean;
  10934. }
  10935. }
  10936. declare module "babylonjs/Actions/actionManager" {
  10937. import { Nullable } from "babylonjs/types";
  10938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Action } from "babylonjs/Actions/action";
  10941. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10942. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10943. /**
  10944. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10945. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class ActionManager extends AbstractActionManager {
  10949. /**
  10950. * Nothing
  10951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10952. */
  10953. static readonly NothingTrigger: number;
  10954. /**
  10955. * On pick
  10956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10957. */
  10958. static readonly OnPickTrigger: number;
  10959. /**
  10960. * On left pick
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10962. */
  10963. static readonly OnLeftPickTrigger: number;
  10964. /**
  10965. * On right pick
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10967. */
  10968. static readonly OnRightPickTrigger: number;
  10969. /**
  10970. * On center pick
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10972. */
  10973. static readonly OnCenterPickTrigger: number;
  10974. /**
  10975. * On pick down
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10977. */
  10978. static readonly OnPickDownTrigger: number;
  10979. /**
  10980. * On double pick
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10982. */
  10983. static readonly OnDoublePickTrigger: number;
  10984. /**
  10985. * On pick up
  10986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10987. */
  10988. static readonly OnPickUpTrigger: number;
  10989. /**
  10990. * On pick out.
  10991. * This trigger will only be raised if you also declared a OnPickDown
  10992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10993. */
  10994. static readonly OnPickOutTrigger: number;
  10995. /**
  10996. * On long press
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10998. */
  10999. static readonly OnLongPressTrigger: number;
  11000. /**
  11001. * On pointer over
  11002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11003. */
  11004. static readonly OnPointerOverTrigger: number;
  11005. /**
  11006. * On pointer out
  11007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11008. */
  11009. static readonly OnPointerOutTrigger: number;
  11010. /**
  11011. * On every frame
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11013. */
  11014. static readonly OnEveryFrameTrigger: number;
  11015. /**
  11016. * On intersection enter
  11017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11018. */
  11019. static readonly OnIntersectionEnterTrigger: number;
  11020. /**
  11021. * On intersection exit
  11022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11023. */
  11024. static readonly OnIntersectionExitTrigger: number;
  11025. /**
  11026. * On key down
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11028. */
  11029. static readonly OnKeyDownTrigger: number;
  11030. /**
  11031. * On key up
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly OnKeyUpTrigger: number;
  11035. private _scene;
  11036. /**
  11037. * Creates a new action manager
  11038. * @param scene defines the hosting scene
  11039. */
  11040. constructor(scene: Scene);
  11041. /**
  11042. * Releases all associated resources
  11043. */
  11044. dispose(): void;
  11045. /**
  11046. * Gets hosting scene
  11047. * @returns the hosting scene
  11048. */
  11049. getScene(): Scene;
  11050. /**
  11051. * Does this action manager handles actions of any of the given triggers
  11052. * @param triggers defines the triggers to be tested
  11053. * @return a boolean indicating whether one (or more) of the triggers is handled
  11054. */
  11055. hasSpecificTriggers(triggers: number[]): boolean;
  11056. /**
  11057. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11058. * speed.
  11059. * @param triggerA defines the trigger to be tested
  11060. * @param triggerB defines the trigger to be tested
  11061. * @return a boolean indicating whether one (or more) of the triggers is handled
  11062. */
  11063. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11064. /**
  11065. * Does this action manager handles actions of a given trigger
  11066. * @param trigger defines the trigger to be tested
  11067. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11068. * @return whether the trigger is handled
  11069. */
  11070. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11071. /**
  11072. * Does this action manager has pointer triggers
  11073. */
  11074. readonly hasPointerTriggers: boolean;
  11075. /**
  11076. * Does this action manager has pick triggers
  11077. */
  11078. readonly hasPickTriggers: boolean;
  11079. /**
  11080. * Registers an action to this action manager
  11081. * @param action defines the action to be registered
  11082. * @return the action amended (prepared) after registration
  11083. */
  11084. registerAction(action: Action): Nullable<Action>;
  11085. /**
  11086. * Unregisters an action to this action manager
  11087. * @param action defines the action to be unregistered
  11088. * @return a boolean indicating whether the action has been unregistered
  11089. */
  11090. unregisterAction(action: Action): Boolean;
  11091. /**
  11092. * Process a specific trigger
  11093. * @param trigger defines the trigger to process
  11094. * @param evt defines the event details to be processed
  11095. */
  11096. processTrigger(trigger: number, evt?: IActionEvent): void;
  11097. /** @hidden */
  11098. _getEffectiveTarget(target: any, propertyPath: string): any;
  11099. /** @hidden */
  11100. _getProperty(propertyPath: string): string;
  11101. /**
  11102. * Serialize this manager to a JSON object
  11103. * @param name defines the property name to store this manager
  11104. * @returns a JSON representation of this manager
  11105. */
  11106. serialize(name: string): any;
  11107. /**
  11108. * Creates a new ActionManager from a JSON data
  11109. * @param parsedActions defines the JSON data to read from
  11110. * @param object defines the hosting mesh
  11111. * @param scene defines the hosting scene
  11112. */
  11113. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11114. /**
  11115. * Get a trigger name by index
  11116. * @param trigger defines the trigger index
  11117. * @returns a trigger name
  11118. */
  11119. static GetTriggerName(trigger: number): string;
  11120. }
  11121. }
  11122. declare module "babylonjs/Culling/ray" {
  11123. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11124. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11126. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11127. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11128. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11129. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11130. /**
  11131. * Class representing a ray with position and direction
  11132. */
  11133. export class Ray {
  11134. /** origin point */
  11135. origin: Vector3;
  11136. /** direction */
  11137. direction: Vector3;
  11138. /** length of the ray */
  11139. length: number;
  11140. private static readonly TmpVector3;
  11141. private _tmpRay;
  11142. /**
  11143. * Creates a new ray
  11144. * @param origin origin point
  11145. * @param direction direction
  11146. * @param length length of the ray
  11147. */
  11148. constructor(
  11149. /** origin point */
  11150. origin: Vector3,
  11151. /** direction */
  11152. direction: Vector3,
  11153. /** length of the ray */
  11154. length?: number);
  11155. /**
  11156. * Checks if the ray intersects a box
  11157. * @param minimum bound of the box
  11158. * @param maximum bound of the box
  11159. * @param intersectionTreshold extra extend to be added to the box in all direction
  11160. * @returns if the box was hit
  11161. */
  11162. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11163. /**
  11164. * Checks if the ray intersects a box
  11165. * @param box the bounding box to check
  11166. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11167. * @returns if the box was hit
  11168. */
  11169. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11170. /**
  11171. * If the ray hits a sphere
  11172. * @param sphere the bounding sphere to check
  11173. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11174. * @returns true if it hits the sphere
  11175. */
  11176. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11177. /**
  11178. * If the ray hits a triange
  11179. * @param vertex0 triangle vertex
  11180. * @param vertex1 triangle vertex
  11181. * @param vertex2 triangle vertex
  11182. * @returns intersection information if hit
  11183. */
  11184. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11185. /**
  11186. * Checks if ray intersects a plane
  11187. * @param plane the plane to check
  11188. * @returns the distance away it was hit
  11189. */
  11190. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11191. /**
  11192. * Checks if ray intersects a mesh
  11193. * @param mesh the mesh to check
  11194. * @param fastCheck if only the bounding box should checked
  11195. * @returns picking info of the intersecton
  11196. */
  11197. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11198. /**
  11199. * Checks if ray intersects a mesh
  11200. * @param meshes the meshes to check
  11201. * @param fastCheck if only the bounding box should checked
  11202. * @param results array to store result in
  11203. * @returns Array of picking infos
  11204. */
  11205. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11206. private _comparePickingInfo;
  11207. private static smallnum;
  11208. private static rayl;
  11209. /**
  11210. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11211. * @param sega the first point of the segment to test the intersection against
  11212. * @param segb the second point of the segment to test the intersection against
  11213. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11214. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11215. */
  11216. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11217. /**
  11218. * Update the ray from viewport position
  11219. * @param x position
  11220. * @param y y position
  11221. * @param viewportWidth viewport width
  11222. * @param viewportHeight viewport height
  11223. * @param world world matrix
  11224. * @param view view matrix
  11225. * @param projection projection matrix
  11226. * @returns this ray updated
  11227. */
  11228. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11229. /**
  11230. * Creates a ray with origin and direction of 0,0,0
  11231. * @returns the new ray
  11232. */
  11233. static Zero(): Ray;
  11234. /**
  11235. * Creates a new ray from screen space and viewport
  11236. * @param x position
  11237. * @param y y position
  11238. * @param viewportWidth viewport width
  11239. * @param viewportHeight viewport height
  11240. * @param world world matrix
  11241. * @param view view matrix
  11242. * @param projection projection matrix
  11243. * @returns new ray
  11244. */
  11245. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * 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
  11248. * transformed to the given world matrix.
  11249. * @param origin The origin point
  11250. * @param end The end point
  11251. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11252. * @returns the new ray
  11253. */
  11254. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11255. /**
  11256. * Transforms a ray by a matrix
  11257. * @param ray ray to transform
  11258. * @param matrix matrix to apply
  11259. * @returns the resulting new ray
  11260. */
  11261. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11262. /**
  11263. * Transforms a ray by a matrix
  11264. * @param ray ray to transform
  11265. * @param matrix matrix to apply
  11266. * @param result ray to store result in
  11267. */
  11268. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11269. /**
  11270. * Unproject a ray from screen space to object space
  11271. * @param sourceX defines the screen space x coordinate to use
  11272. * @param sourceY defines the screen space y coordinate to use
  11273. * @param viewportWidth defines the current width of the viewport
  11274. * @param viewportHeight defines the current height of the viewport
  11275. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11276. * @param view defines the view matrix to use
  11277. * @param projection defines the projection matrix to use
  11278. */
  11279. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11280. }
  11281. module "babylonjs/scene" {
  11282. interface Scene {
  11283. /** @hidden */
  11284. _tempPickingRay: Nullable<Ray>;
  11285. /** @hidden */
  11286. _cachedRayForTransform: Ray;
  11287. /** @hidden */
  11288. _pickWithRayInverseMatrix: Matrix;
  11289. /** @hidden */
  11290. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11291. /** @hidden */
  11292. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11293. }
  11294. }
  11295. }
  11296. declare module "babylonjs/sceneComponent" {
  11297. import { Scene } from "babylonjs/scene";
  11298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11300. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11301. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11302. import { Nullable } from "babylonjs/types";
  11303. import { Camera } from "babylonjs/Cameras/camera";
  11304. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11305. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11306. import { AbstractScene } from "babylonjs/abstractScene";
  11307. /**
  11308. * Groups all the scene component constants in one place to ease maintenance.
  11309. * @hidden
  11310. */
  11311. export class SceneComponentConstants {
  11312. static readonly NAME_EFFECTLAYER: string;
  11313. static readonly NAME_LAYER: string;
  11314. static readonly NAME_LENSFLARESYSTEM: string;
  11315. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11316. static readonly NAME_PARTICLESYSTEM: string;
  11317. static readonly NAME_GAMEPAD: string;
  11318. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11319. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11320. static readonly NAME_DEPTHRENDERER: string;
  11321. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11322. static readonly NAME_SPRITE: string;
  11323. static readonly NAME_OUTLINERENDERER: string;
  11324. static readonly NAME_PROCEDURALTEXTURE: string;
  11325. static readonly NAME_SHADOWGENERATOR: string;
  11326. static readonly NAME_OCTREE: string;
  11327. static readonly NAME_PHYSICSENGINE: string;
  11328. static readonly NAME_AUDIO: string;
  11329. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11330. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11331. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11332. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11333. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11334. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11336. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11337. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11338. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11339. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11340. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11341. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11342. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11343. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11344. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11345. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11346. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11347. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11348. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11349. static readonly STEP_AFTERRENDER_AUDIO: number;
  11350. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11351. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11352. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11353. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11354. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11355. static readonly STEP_POINTERMOVE_SPRITE: number;
  11356. static readonly STEP_POINTERDOWN_SPRITE: number;
  11357. static readonly STEP_POINTERUP_SPRITE: number;
  11358. }
  11359. /**
  11360. * This represents a scene component.
  11361. *
  11362. * This is used to decouple the dependency the scene is having on the different workloads like
  11363. * layers, post processes...
  11364. */
  11365. export interface ISceneComponent {
  11366. /**
  11367. * The name of the component. Each component must have a unique name.
  11368. */
  11369. name: string;
  11370. /**
  11371. * The scene the component belongs to.
  11372. */
  11373. scene: Scene;
  11374. /**
  11375. * Register the component to one instance of a scene.
  11376. */
  11377. register(): void;
  11378. /**
  11379. * Rebuilds the elements related to this component in case of
  11380. * context lost for instance.
  11381. */
  11382. rebuild(): void;
  11383. /**
  11384. * Disposes the component and the associated ressources.
  11385. */
  11386. dispose(): void;
  11387. }
  11388. /**
  11389. * This represents a SERIALIZABLE scene component.
  11390. *
  11391. * This extends Scene Component to add Serialization methods on top.
  11392. */
  11393. export interface ISceneSerializableComponent extends ISceneComponent {
  11394. /**
  11395. * Adds all the element from the container to the scene
  11396. * @param container the container holding the elements
  11397. */
  11398. addFromContainer(container: AbstractScene): void;
  11399. /**
  11400. * Removes all the elements in the container from the scene
  11401. * @param container contains the elements to remove
  11402. */
  11403. removeFromContainer(container: AbstractScene): void;
  11404. /**
  11405. * Serializes the component data to the specified json object
  11406. * @param serializationObject The object to serialize to
  11407. */
  11408. serialize(serializationObject: any): void;
  11409. }
  11410. /**
  11411. * Strong typing of a Mesh related stage step action
  11412. */
  11413. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11414. /**
  11415. * Strong typing of a Evaluate Sub Mesh related stage step action
  11416. */
  11417. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11418. /**
  11419. * Strong typing of a Active Mesh related stage step action
  11420. */
  11421. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11422. /**
  11423. * Strong typing of a Camera related stage step action
  11424. */
  11425. export type CameraStageAction = (camera: Camera) => void;
  11426. /**
  11427. * Strong typing of a Render Target related stage step action
  11428. */
  11429. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11430. /**
  11431. * Strong typing of a RenderingGroup related stage step action
  11432. */
  11433. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11434. /**
  11435. * Strong typing of a Mesh Render related stage step action
  11436. */
  11437. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11438. /**
  11439. * Strong typing of a simple stage step action
  11440. */
  11441. export type SimpleStageAction = () => void;
  11442. /**
  11443. * Strong typing of a render target action.
  11444. */
  11445. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11446. /**
  11447. * Strong typing of a pointer move action.
  11448. */
  11449. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11450. /**
  11451. * Strong typing of a pointer up/down action.
  11452. */
  11453. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11454. /**
  11455. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11456. * @hidden
  11457. */
  11458. export class Stage<T extends Function> extends Array<{
  11459. index: number;
  11460. component: ISceneComponent;
  11461. action: T;
  11462. }> {
  11463. /**
  11464. * Hide ctor from the rest of the world.
  11465. * @param items The items to add.
  11466. */
  11467. private constructor();
  11468. /**
  11469. * Creates a new Stage.
  11470. * @returns A new instance of a Stage
  11471. */
  11472. static Create<T extends Function>(): Stage<T>;
  11473. /**
  11474. * Registers a step in an ordered way in the targeted stage.
  11475. * @param index Defines the position to register the step in
  11476. * @param component Defines the component attached to the step
  11477. * @param action Defines the action to launch during the step
  11478. */
  11479. registerStep(index: number, component: ISceneComponent, action: T): void;
  11480. /**
  11481. * Clears all the steps from the stage.
  11482. */
  11483. clear(): void;
  11484. }
  11485. }
  11486. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11487. import { Nullable } from "babylonjs/types";
  11488. import { Observable } from "babylonjs/Misc/observable";
  11489. import { Scene } from "babylonjs/scene";
  11490. import { Sprite } from "babylonjs/Sprites/sprite";
  11491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11492. import { Ray } from "babylonjs/Culling/ray";
  11493. import { Camera } from "babylonjs/Cameras/camera";
  11494. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11495. import { ISceneComponent } from "babylonjs/sceneComponent";
  11496. module "babylonjs/scene" {
  11497. interface Scene {
  11498. /** @hidden */
  11499. _pointerOverSprite: Nullable<Sprite>;
  11500. /** @hidden */
  11501. _pickedDownSprite: Nullable<Sprite>;
  11502. /** @hidden */
  11503. _tempSpritePickingRay: Nullable<Ray>;
  11504. /**
  11505. * All of the sprite managers added to this scene
  11506. * @see http://doc.babylonjs.com/babylon101/sprites
  11507. */
  11508. spriteManagers: Array<ISpriteManager>;
  11509. /**
  11510. * An event triggered when sprites rendering is about to start
  11511. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11512. */
  11513. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11514. /**
  11515. * An event triggered when sprites rendering is done
  11516. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11517. */
  11518. onAfterSpritesRenderingObservable: Observable<Scene>;
  11519. /** @hidden */
  11520. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11521. /** Launch a ray to try to pick a sprite in the scene
  11522. * @param x position on screen
  11523. * @param y position on screen
  11524. * @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
  11525. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11526. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11527. * @returns a PickingInfo
  11528. */
  11529. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11530. /** Use the given ray to pick a sprite in the scene
  11531. * @param ray The ray (in world space) to use to pick meshes
  11532. * @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
  11533. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11534. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11535. * @returns a PickingInfo
  11536. */
  11537. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11538. /**
  11539. * Force the sprite under the pointer
  11540. * @param sprite defines the sprite to use
  11541. */
  11542. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11543. /**
  11544. * Gets the sprite under the pointer
  11545. * @returns a Sprite or null if no sprite is under the pointer
  11546. */
  11547. getPointerOverSprite(): Nullable<Sprite>;
  11548. }
  11549. }
  11550. /**
  11551. * Defines the sprite scene component responsible to manage sprites
  11552. * in a given scene.
  11553. */
  11554. export class SpriteSceneComponent implements ISceneComponent {
  11555. /**
  11556. * The component name helpfull to identify the component in the list of scene components.
  11557. */
  11558. readonly name: string;
  11559. /**
  11560. * The scene the component belongs to.
  11561. */
  11562. scene: Scene;
  11563. /** @hidden */
  11564. private _spritePredicate;
  11565. /**
  11566. * Creates a new instance of the component for the given scene
  11567. * @param scene Defines the scene to register the component in
  11568. */
  11569. constructor(scene: Scene);
  11570. /**
  11571. * Registers the component in a given scene
  11572. */
  11573. register(): void;
  11574. /**
  11575. * Rebuilds the elements related to this component in case of
  11576. * context lost for instance.
  11577. */
  11578. rebuild(): void;
  11579. /**
  11580. * Disposes the component and the associated ressources.
  11581. */
  11582. dispose(): void;
  11583. private _pickSpriteButKeepRay;
  11584. private _pointerMove;
  11585. private _pointerDown;
  11586. private _pointerUp;
  11587. }
  11588. }
  11589. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11590. /** @hidden */
  11591. export var fogFragmentDeclaration: {
  11592. name: string;
  11593. shader: string;
  11594. };
  11595. }
  11596. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11597. /** @hidden */
  11598. export var fogFragment: {
  11599. name: string;
  11600. shader: string;
  11601. };
  11602. }
  11603. declare module "babylonjs/Shaders/sprites.fragment" {
  11604. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11605. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11606. /** @hidden */
  11607. export var spritesPixelShader: {
  11608. name: string;
  11609. shader: string;
  11610. };
  11611. }
  11612. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11613. /** @hidden */
  11614. export var fogVertexDeclaration: {
  11615. name: string;
  11616. shader: string;
  11617. };
  11618. }
  11619. declare module "babylonjs/Shaders/sprites.vertex" {
  11620. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11621. /** @hidden */
  11622. export var spritesVertexShader: {
  11623. name: string;
  11624. shader: string;
  11625. };
  11626. }
  11627. declare module "babylonjs/Sprites/spriteManager" {
  11628. import { IDisposable, Scene } from "babylonjs/scene";
  11629. import { Nullable } from "babylonjs/types";
  11630. import { Observable } from "babylonjs/Misc/observable";
  11631. import { Sprite } from "babylonjs/Sprites/sprite";
  11632. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11633. import { Camera } from "babylonjs/Cameras/camera";
  11634. import { Texture } from "babylonjs/Materials/Textures/texture";
  11635. import "babylonjs/Shaders/sprites.fragment";
  11636. import "babylonjs/Shaders/sprites.vertex";
  11637. import { Ray } from "babylonjs/Culling/ray";
  11638. /**
  11639. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11640. */
  11641. export interface ISpriteManager extends IDisposable {
  11642. /**
  11643. * Restricts the camera to viewing objects with the same layerMask.
  11644. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11645. */
  11646. layerMask: number;
  11647. /**
  11648. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11649. */
  11650. isPickable: boolean;
  11651. /**
  11652. * Specifies the rendering group id for this mesh (0 by default)
  11653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11654. */
  11655. renderingGroupId: number;
  11656. /**
  11657. * Defines the list of sprites managed by the manager.
  11658. */
  11659. sprites: Array<Sprite>;
  11660. /**
  11661. * Tests the intersection of a sprite with a specific ray.
  11662. * @param ray The ray we are sending to test the collision
  11663. * @param camera The camera space we are sending rays in
  11664. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11665. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11666. * @returns picking info or null.
  11667. */
  11668. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11669. /**
  11670. * Renders the list of sprites on screen.
  11671. */
  11672. render(): void;
  11673. }
  11674. /**
  11675. * Class used to manage multiple sprites on the same spritesheet
  11676. * @see http://doc.babylonjs.com/babylon101/sprites
  11677. */
  11678. export class SpriteManager implements ISpriteManager {
  11679. /** defines the manager's name */
  11680. name: string;
  11681. /** Gets the list of sprites */
  11682. sprites: Sprite[];
  11683. /** Gets or sets the rendering group id (0 by default) */
  11684. renderingGroupId: number;
  11685. /** Gets or sets camera layer mask */
  11686. layerMask: number;
  11687. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11688. fogEnabled: boolean;
  11689. /** Gets or sets a boolean indicating if the sprites are pickable */
  11690. isPickable: boolean;
  11691. /** Defines the default width of a cell in the spritesheet */
  11692. cellWidth: number;
  11693. /** Defines the default height of a cell in the spritesheet */
  11694. cellHeight: number;
  11695. /**
  11696. * An event triggered when the manager is disposed.
  11697. */
  11698. onDisposeObservable: Observable<SpriteManager>;
  11699. private _onDisposeObserver;
  11700. /**
  11701. * Callback called when the manager is disposed
  11702. */
  11703. onDispose: () => void;
  11704. private _capacity;
  11705. private _spriteTexture;
  11706. private _epsilon;
  11707. private _scene;
  11708. private _vertexData;
  11709. private _buffer;
  11710. private _vertexBuffers;
  11711. private _indexBuffer;
  11712. private _effectBase;
  11713. private _effectFog;
  11714. /**
  11715. * Gets or sets the spritesheet texture
  11716. */
  11717. texture: Texture;
  11718. /**
  11719. * Creates a new sprite manager
  11720. * @param name defines the manager's name
  11721. * @param imgUrl defines the sprite sheet url
  11722. * @param capacity defines the maximum allowed number of sprites
  11723. * @param cellSize defines the size of a sprite cell
  11724. * @param scene defines the hosting scene
  11725. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11726. * @param samplingMode defines the smapling mode to use with spritesheet
  11727. */
  11728. constructor(
  11729. /** defines the manager's name */
  11730. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11731. private _appendSpriteVertex;
  11732. /**
  11733. * Intersects the sprites with a ray
  11734. * @param ray defines the ray to intersect with
  11735. * @param camera defines the current active camera
  11736. * @param predicate defines a predicate used to select candidate sprites
  11737. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11738. * @returns null if no hit or a PickingInfo
  11739. */
  11740. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11741. /**
  11742. * Render all child sprites
  11743. */
  11744. render(): void;
  11745. /**
  11746. * Release associated resources
  11747. */
  11748. dispose(): void;
  11749. }
  11750. }
  11751. declare module "babylonjs/Sprites/sprite" {
  11752. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11753. import { Nullable } from "babylonjs/types";
  11754. import { ActionManager } from "babylonjs/Actions/actionManager";
  11755. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11756. /**
  11757. * Class used to represent a sprite
  11758. * @see http://doc.babylonjs.com/babylon101/sprites
  11759. */
  11760. export class Sprite {
  11761. /** defines the name */
  11762. name: string;
  11763. /** Gets or sets the current world position */
  11764. position: Vector3;
  11765. /** Gets or sets the main color */
  11766. color: Color4;
  11767. /** Gets or sets the width */
  11768. width: number;
  11769. /** Gets or sets the height */
  11770. height: number;
  11771. /** Gets or sets rotation angle */
  11772. angle: number;
  11773. /** Gets or sets the cell index in the sprite sheet */
  11774. cellIndex: number;
  11775. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11776. invertU: number;
  11777. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11778. invertV: number;
  11779. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11780. disposeWhenFinishedAnimating: boolean;
  11781. /** Gets the list of attached animations */
  11782. animations: Animation[];
  11783. /** Gets or sets a boolean indicating if the sprite can be picked */
  11784. isPickable: boolean;
  11785. /**
  11786. * Gets or sets the associated action manager
  11787. */
  11788. actionManager: Nullable<ActionManager>;
  11789. private _animationStarted;
  11790. private _loopAnimation;
  11791. private _fromIndex;
  11792. private _toIndex;
  11793. private _delay;
  11794. private _direction;
  11795. private _manager;
  11796. private _time;
  11797. private _onAnimationEnd;
  11798. /**
  11799. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11800. */
  11801. isVisible: boolean;
  11802. /**
  11803. * Gets or sets the sprite size
  11804. */
  11805. size: number;
  11806. /**
  11807. * Creates a new Sprite
  11808. * @param name defines the name
  11809. * @param manager defines the manager
  11810. */
  11811. constructor(
  11812. /** defines the name */
  11813. name: string, manager: ISpriteManager);
  11814. /**
  11815. * Starts an animation
  11816. * @param from defines the initial key
  11817. * @param to defines the end key
  11818. * @param loop defines if the animation must loop
  11819. * @param delay defines the start delay (in ms)
  11820. * @param onAnimationEnd defines a callback to call when animation ends
  11821. */
  11822. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11823. /** Stops current animation (if any) */
  11824. stopAnimation(): void;
  11825. /** @hidden */
  11826. _animate(deltaTime: number): void;
  11827. /** Release associated resources */
  11828. dispose(): void;
  11829. }
  11830. }
  11831. declare module "babylonjs/Collisions/pickingInfo" {
  11832. import { Nullable } from "babylonjs/types";
  11833. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11835. import { Sprite } from "babylonjs/Sprites/sprite";
  11836. import { Ray } from "babylonjs/Culling/ray";
  11837. /**
  11838. * Information about the result of picking within a scene
  11839. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11840. */
  11841. export class PickingInfo {
  11842. /** @hidden */
  11843. _pickingUnavailable: boolean;
  11844. /**
  11845. * If the pick collided with an object
  11846. */
  11847. hit: boolean;
  11848. /**
  11849. * Distance away where the pick collided
  11850. */
  11851. distance: number;
  11852. /**
  11853. * The location of pick collision
  11854. */
  11855. pickedPoint: Nullable<Vector3>;
  11856. /**
  11857. * The mesh corresponding the the pick collision
  11858. */
  11859. pickedMesh: Nullable<AbstractMesh>;
  11860. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11861. bu: number;
  11862. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11863. bv: number;
  11864. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11865. faceId: number;
  11866. /** Id of the the submesh that was picked */
  11867. subMeshId: number;
  11868. /** If a sprite was picked, this will be the sprite the pick collided with */
  11869. pickedSprite: Nullable<Sprite>;
  11870. /**
  11871. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11872. */
  11873. originMesh: Nullable<AbstractMesh>;
  11874. /**
  11875. * The ray that was used to perform the picking.
  11876. */
  11877. ray: Nullable<Ray>;
  11878. /**
  11879. * Gets the normal correspodning to the face the pick collided with
  11880. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11881. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11882. * @returns The normal correspodning to the face the pick collided with
  11883. */
  11884. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11885. /**
  11886. * Gets the texture coordinates of where the pick occured
  11887. * @returns the vector containing the coordnates of the texture
  11888. */
  11889. getTextureCoordinates(): Nullable<Vector2>;
  11890. }
  11891. }
  11892. declare module "babylonjs/Events/pointerEvents" {
  11893. import { Nullable } from "babylonjs/types";
  11894. import { Vector2 } from "babylonjs/Maths/math";
  11895. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11896. import { Ray } from "babylonjs/Culling/ray";
  11897. /**
  11898. * Gather the list of pointer event types as constants.
  11899. */
  11900. export class PointerEventTypes {
  11901. /**
  11902. * 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.
  11903. */
  11904. static readonly POINTERDOWN: number;
  11905. /**
  11906. * The pointerup event is fired when a pointer is no longer active.
  11907. */
  11908. static readonly POINTERUP: number;
  11909. /**
  11910. * The pointermove event is fired when a pointer changes coordinates.
  11911. */
  11912. static readonly POINTERMOVE: number;
  11913. /**
  11914. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11915. */
  11916. static readonly POINTERWHEEL: number;
  11917. /**
  11918. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11919. */
  11920. static readonly POINTERPICK: number;
  11921. /**
  11922. * The pointertap event is fired when a the object has been touched and released without drag.
  11923. */
  11924. static readonly POINTERTAP: number;
  11925. /**
  11926. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11927. */
  11928. static readonly POINTERDOUBLETAP: number;
  11929. }
  11930. /**
  11931. * Base class of pointer info types.
  11932. */
  11933. export class PointerInfoBase {
  11934. /**
  11935. * Defines the type of event (PointerEventTypes)
  11936. */
  11937. type: number;
  11938. /**
  11939. * Defines the related dom event
  11940. */
  11941. event: PointerEvent | MouseWheelEvent;
  11942. /**
  11943. * Instantiates the base class of pointers info.
  11944. * @param type Defines the type of event (PointerEventTypes)
  11945. * @param event Defines the related dom event
  11946. */
  11947. constructor(
  11948. /**
  11949. * Defines the type of event (PointerEventTypes)
  11950. */
  11951. type: number,
  11952. /**
  11953. * Defines the related dom event
  11954. */
  11955. event: PointerEvent | MouseWheelEvent);
  11956. }
  11957. /**
  11958. * This class is used to store pointer related info for the onPrePointerObservable event.
  11959. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11960. */
  11961. export class PointerInfoPre extends PointerInfoBase {
  11962. /**
  11963. * Ray from a pointer if availible (eg. 6dof controller)
  11964. */
  11965. ray: Nullable<Ray>;
  11966. /**
  11967. * Defines the local position of the pointer on the canvas.
  11968. */
  11969. localPosition: Vector2;
  11970. /**
  11971. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11972. */
  11973. skipOnPointerObservable: boolean;
  11974. /**
  11975. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11976. * @param type Defines the type of event (PointerEventTypes)
  11977. * @param event Defines the related dom event
  11978. * @param localX Defines the local x coordinates of the pointer when the event occured
  11979. * @param localY Defines the local y coordinates of the pointer when the event occured
  11980. */
  11981. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11982. }
  11983. /**
  11984. * This type contains all the data related to a pointer event in Babylon.js.
  11985. * 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.
  11986. */
  11987. export class PointerInfo extends PointerInfoBase {
  11988. /**
  11989. * Defines the picking info associated to the info (if any)\
  11990. */
  11991. pickInfo: Nullable<PickingInfo>;
  11992. /**
  11993. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11994. * @param type Defines the type of event (PointerEventTypes)
  11995. * @param event Defines the related dom event
  11996. * @param pickInfo Defines the picking info associated to the info (if any)\
  11997. */
  11998. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11999. /**
  12000. * Defines the picking info associated to the info (if any)\
  12001. */
  12002. pickInfo: Nullable<PickingInfo>);
  12003. }
  12004. }
  12005. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12006. import { Nullable } from "babylonjs/types";
  12007. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12008. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12009. /**
  12010. * Manage the mouse inputs to control the movement of a free camera.
  12011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12012. */
  12013. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12014. /**
  12015. * Define if touch is enabled in the mouse input
  12016. */
  12017. touchEnabled: boolean;
  12018. /**
  12019. * Defines the camera the input is attached to.
  12020. */
  12021. camera: FreeCamera;
  12022. /**
  12023. * Defines the buttons associated with the input to handle camera move.
  12024. */
  12025. buttons: number[];
  12026. /**
  12027. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12028. */
  12029. angularSensibility: number;
  12030. private _pointerInput;
  12031. private _onMouseMove;
  12032. private _observer;
  12033. private previousPosition;
  12034. /**
  12035. * Manage the mouse inputs to control the movement of a free camera.
  12036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12037. * @param touchEnabled Defines if touch is enabled or not
  12038. */
  12039. constructor(
  12040. /**
  12041. * Define if touch is enabled in the mouse input
  12042. */
  12043. touchEnabled?: boolean);
  12044. /**
  12045. * Attach the input controls to a specific dom element to get the input from.
  12046. * @param element Defines the element the controls should be listened from
  12047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12048. */
  12049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12050. /**
  12051. * Detach the current controls from the specified dom element.
  12052. * @param element Defines the element to stop listening the inputs from
  12053. */
  12054. detachControl(element: Nullable<HTMLElement>): void;
  12055. /**
  12056. * Gets the class name of the current intput.
  12057. * @returns the class name
  12058. */
  12059. getClassName(): string;
  12060. /**
  12061. * Get the friendly name associated with the input class.
  12062. * @returns the input friendly name
  12063. */
  12064. getSimpleName(): string;
  12065. }
  12066. }
  12067. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the touch inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Defines the camera the input is attached to.
  12078. */
  12079. camera: FreeCamera;
  12080. /**
  12081. * Defines the touch sensibility for rotation.
  12082. * The higher the faster.
  12083. */
  12084. touchAngularSensibility: number;
  12085. /**
  12086. * Defines the touch sensibility for move.
  12087. * The higher the faster.
  12088. */
  12089. touchMoveSensibility: number;
  12090. private _offsetX;
  12091. private _offsetY;
  12092. private _pointerPressed;
  12093. private _pointerInput;
  12094. private _observer;
  12095. private _onLostFocus;
  12096. /**
  12097. * Attach the input controls to a specific dom element to get the input from.
  12098. * @param element Defines the element the controls should be listened from
  12099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12100. */
  12101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12102. /**
  12103. * Detach the current controls from the specified dom element.
  12104. * @param element Defines the element to stop listening the inputs from
  12105. */
  12106. detachControl(element: Nullable<HTMLElement>): void;
  12107. /**
  12108. * Update the current camera state depending on the inputs that have been used this frame.
  12109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12110. */
  12111. checkInputs(): void;
  12112. /**
  12113. * Gets the class name of the current intput.
  12114. * @returns the class name
  12115. */
  12116. getClassName(): string;
  12117. /**
  12118. * Get the friendly name associated with the input class.
  12119. * @returns the input friendly name
  12120. */
  12121. getSimpleName(): string;
  12122. }
  12123. }
  12124. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12126. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12127. /**
  12128. * Default Inputs manager for the FreeCamera.
  12129. * It groups all the default supported inputs for ease of use.
  12130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12131. */
  12132. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12133. /**
  12134. * Instantiates a new FreeCameraInputsManager.
  12135. * @param camera Defines the camera the inputs belong to
  12136. */
  12137. constructor(camera: FreeCamera);
  12138. /**
  12139. * Add keyboard input support to the input manager.
  12140. * @returns the current input manager
  12141. */
  12142. addKeyboard(): FreeCameraInputsManager;
  12143. /**
  12144. * Add mouse input support to the input manager.
  12145. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12146. * @returns the current input manager
  12147. */
  12148. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12149. /**
  12150. * Add touch input support to the input manager.
  12151. * @returns the current input manager
  12152. */
  12153. addTouch(): FreeCameraInputsManager;
  12154. }
  12155. }
  12156. declare module "babylonjs/Cameras/freeCamera" {
  12157. import { Vector3 } from "babylonjs/Maths/math";
  12158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12159. import { Scene } from "babylonjs/scene";
  12160. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12161. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12162. /**
  12163. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12164. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12165. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12166. */
  12167. export class FreeCamera extends TargetCamera {
  12168. /**
  12169. * Define the collision ellipsoid of the camera.
  12170. * This is helpful to simulate a camera body like the player body around the camera
  12171. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12172. */
  12173. ellipsoid: Vector3;
  12174. /**
  12175. * Define an offset for the position of the ellipsoid around the camera.
  12176. * This can be helpful to determine the center of the body near the gravity center of the body
  12177. * instead of its head.
  12178. */
  12179. ellipsoidOffset: Vector3;
  12180. /**
  12181. * Enable or disable collisions of the camera with the rest of the scene objects.
  12182. */
  12183. checkCollisions: boolean;
  12184. /**
  12185. * Enable or disable gravity on the camera.
  12186. */
  12187. applyGravity: boolean;
  12188. /**
  12189. * Define the input manager associated to the camera.
  12190. */
  12191. inputs: FreeCameraInputsManager;
  12192. /**
  12193. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12194. * Higher values reduce sensitivity.
  12195. */
  12196. /**
  12197. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12198. * Higher values reduce sensitivity.
  12199. */
  12200. angularSensibility: number;
  12201. /**
  12202. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12203. */
  12204. keysUp: number[];
  12205. /**
  12206. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12207. */
  12208. keysDown: number[];
  12209. /**
  12210. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12211. */
  12212. keysLeft: number[];
  12213. /**
  12214. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12215. */
  12216. keysRight: number[];
  12217. /**
  12218. * Event raised when the camera collide with a mesh in the scene.
  12219. */
  12220. onCollide: (collidedMesh: AbstractMesh) => void;
  12221. private _collider;
  12222. private _needMoveForGravity;
  12223. private _oldPosition;
  12224. private _diffPosition;
  12225. private _newPosition;
  12226. /** @hidden */
  12227. _localDirection: Vector3;
  12228. /** @hidden */
  12229. _transformedDirection: Vector3;
  12230. /**
  12231. * Instantiates a Free Camera.
  12232. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12233. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12235. * @param name Define the name of the camera in the scene
  12236. * @param position Define the start position of the camera in the scene
  12237. * @param scene Define the scene the camera belongs to
  12238. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12239. */
  12240. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12241. /**
  12242. * Attached controls to the current camera.
  12243. * @param element Defines the element the controls should be listened from
  12244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12245. */
  12246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12247. /**
  12248. * Detach the current controls from the camera.
  12249. * The camera will stop reacting to inputs.
  12250. * @param element Defines the element to stop listening the inputs from
  12251. */
  12252. detachControl(element: HTMLElement): void;
  12253. private _collisionMask;
  12254. /**
  12255. * Define a collision mask to limit the list of object the camera can collide with
  12256. */
  12257. collisionMask: number;
  12258. /** @hidden */
  12259. _collideWithWorld(displacement: Vector3): void;
  12260. private _onCollisionPositionChange;
  12261. /** @hidden */
  12262. _checkInputs(): void;
  12263. /** @hidden */
  12264. _decideIfNeedsToMove(): boolean;
  12265. /** @hidden */
  12266. _updatePosition(): void;
  12267. /**
  12268. * Destroy the camera and release the current resources hold by it.
  12269. */
  12270. dispose(): void;
  12271. /**
  12272. * Gets the current object class name.
  12273. * @return the class name
  12274. */
  12275. getClassName(): string;
  12276. }
  12277. }
  12278. declare module "babylonjs/Gamepads/gamepad" {
  12279. import { Observable } from "babylonjs/Misc/observable";
  12280. /**
  12281. * Represents a gamepad control stick position
  12282. */
  12283. export class StickValues {
  12284. /**
  12285. * The x component of the control stick
  12286. */
  12287. x: number;
  12288. /**
  12289. * The y component of the control stick
  12290. */
  12291. y: number;
  12292. /**
  12293. * Initializes the gamepad x and y control stick values
  12294. * @param x The x component of the gamepad control stick value
  12295. * @param y The y component of the gamepad control stick value
  12296. */
  12297. constructor(
  12298. /**
  12299. * The x component of the control stick
  12300. */
  12301. x: number,
  12302. /**
  12303. * The y component of the control stick
  12304. */
  12305. y: number);
  12306. }
  12307. /**
  12308. * An interface which manages callbacks for gamepad button changes
  12309. */
  12310. export interface GamepadButtonChanges {
  12311. /**
  12312. * Called when a gamepad has been changed
  12313. */
  12314. changed: boolean;
  12315. /**
  12316. * Called when a gamepad press event has been triggered
  12317. */
  12318. pressChanged: boolean;
  12319. /**
  12320. * Called when a touch event has been triggered
  12321. */
  12322. touchChanged: boolean;
  12323. /**
  12324. * Called when a value has changed
  12325. */
  12326. valueChanged: boolean;
  12327. }
  12328. /**
  12329. * Represents a gamepad
  12330. */
  12331. export class Gamepad {
  12332. /**
  12333. * The id of the gamepad
  12334. */
  12335. id: string;
  12336. /**
  12337. * The index of the gamepad
  12338. */
  12339. index: number;
  12340. /**
  12341. * The browser gamepad
  12342. */
  12343. browserGamepad: any;
  12344. /**
  12345. * Specifies what type of gamepad this represents
  12346. */
  12347. type: number;
  12348. private _leftStick;
  12349. private _rightStick;
  12350. /** @hidden */
  12351. _isConnected: boolean;
  12352. private _leftStickAxisX;
  12353. private _leftStickAxisY;
  12354. private _rightStickAxisX;
  12355. private _rightStickAxisY;
  12356. /**
  12357. * Triggered when the left control stick has been changed
  12358. */
  12359. private _onleftstickchanged;
  12360. /**
  12361. * Triggered when the right control stick has been changed
  12362. */
  12363. private _onrightstickchanged;
  12364. /**
  12365. * Represents a gamepad controller
  12366. */
  12367. static GAMEPAD: number;
  12368. /**
  12369. * Represents a generic controller
  12370. */
  12371. static GENERIC: number;
  12372. /**
  12373. * Represents an XBox controller
  12374. */
  12375. static XBOX: number;
  12376. /**
  12377. * Represents a pose-enabled controller
  12378. */
  12379. static POSE_ENABLED: number;
  12380. /**
  12381. * Specifies whether the left control stick should be Y-inverted
  12382. */
  12383. protected _invertLeftStickY: boolean;
  12384. /**
  12385. * Specifies if the gamepad has been connected
  12386. */
  12387. readonly isConnected: boolean;
  12388. /**
  12389. * Initializes the gamepad
  12390. * @param id The id of the gamepad
  12391. * @param index The index of the gamepad
  12392. * @param browserGamepad The browser gamepad
  12393. * @param leftStickX The x component of the left joystick
  12394. * @param leftStickY The y component of the left joystick
  12395. * @param rightStickX The x component of the right joystick
  12396. * @param rightStickY The y component of the right joystick
  12397. */
  12398. constructor(
  12399. /**
  12400. * The id of the gamepad
  12401. */
  12402. id: string,
  12403. /**
  12404. * The index of the gamepad
  12405. */
  12406. index: number,
  12407. /**
  12408. * The browser gamepad
  12409. */
  12410. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12411. /**
  12412. * Callback triggered when the left joystick has changed
  12413. * @param callback
  12414. */
  12415. onleftstickchanged(callback: (values: StickValues) => void): void;
  12416. /**
  12417. * Callback triggered when the right joystick has changed
  12418. * @param callback
  12419. */
  12420. onrightstickchanged(callback: (values: StickValues) => void): void;
  12421. /**
  12422. * Gets the left joystick
  12423. */
  12424. /**
  12425. * Sets the left joystick values
  12426. */
  12427. leftStick: StickValues;
  12428. /**
  12429. * Gets the right joystick
  12430. */
  12431. /**
  12432. * Sets the right joystick value
  12433. */
  12434. rightStick: StickValues;
  12435. /**
  12436. * Updates the gamepad joystick positions
  12437. */
  12438. update(): void;
  12439. /**
  12440. * Disposes the gamepad
  12441. */
  12442. dispose(): void;
  12443. }
  12444. /**
  12445. * Represents a generic gamepad
  12446. */
  12447. export class GenericPad extends Gamepad {
  12448. private _buttons;
  12449. private _onbuttondown;
  12450. private _onbuttonup;
  12451. /**
  12452. * Observable triggered when a button has been pressed
  12453. */
  12454. onButtonDownObservable: Observable<number>;
  12455. /**
  12456. * Observable triggered when a button has been released
  12457. */
  12458. onButtonUpObservable: Observable<number>;
  12459. /**
  12460. * Callback triggered when a button has been pressed
  12461. * @param callback Called when a button has been pressed
  12462. */
  12463. onbuttondown(callback: (buttonPressed: number) => void): void;
  12464. /**
  12465. * Callback triggered when a button has been released
  12466. * @param callback Called when a button has been released
  12467. */
  12468. onbuttonup(callback: (buttonReleased: number) => void): void;
  12469. /**
  12470. * Initializes the generic gamepad
  12471. * @param id The id of the generic gamepad
  12472. * @param index The index of the generic gamepad
  12473. * @param browserGamepad The browser gamepad
  12474. */
  12475. constructor(id: string, index: number, browserGamepad: any);
  12476. private _setButtonValue;
  12477. /**
  12478. * Updates the generic gamepad
  12479. */
  12480. update(): void;
  12481. /**
  12482. * Disposes the generic gamepad
  12483. */
  12484. dispose(): void;
  12485. }
  12486. }
  12487. declare module "babylonjs/Meshes/transformNode" {
  12488. import { DeepImmutable } from "babylonjs/types";
  12489. import { Observable } from "babylonjs/Misc/observable";
  12490. import { Nullable } from "babylonjs/types";
  12491. import { Camera } from "babylonjs/Cameras/camera";
  12492. import { Scene } from "babylonjs/scene";
  12493. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  12494. import { Node } from "babylonjs/node";
  12495. import { Bone } from "babylonjs/Bones/bone";
  12496. /**
  12497. * 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.
  12498. * @see https://doc.babylonjs.com/how_to/transformnode
  12499. */
  12500. export class TransformNode extends Node {
  12501. /**
  12502. * Object will not rotate to face the camera
  12503. */
  12504. static BILLBOARDMODE_NONE: number;
  12505. /**
  12506. * Object will rotate to face the camera but only on the x axis
  12507. */
  12508. static BILLBOARDMODE_X: number;
  12509. /**
  12510. * Object will rotate to face the camera but only on the y axis
  12511. */
  12512. static BILLBOARDMODE_Y: number;
  12513. /**
  12514. * Object will rotate to face the camera but only on the z axis
  12515. */
  12516. static BILLBOARDMODE_Z: number;
  12517. /**
  12518. * Object will rotate to face the camera
  12519. */
  12520. static BILLBOARDMODE_ALL: number;
  12521. private _forward;
  12522. private _forwardInverted;
  12523. private _up;
  12524. private _right;
  12525. private _rightInverted;
  12526. private _position;
  12527. private _rotation;
  12528. private _rotationQuaternion;
  12529. protected _scaling: Vector3;
  12530. protected _isDirty: boolean;
  12531. private _transformToBoneReferal;
  12532. /**
  12533. * Set the billboard mode. Default is 0.
  12534. *
  12535. * | Value | Type | Description |
  12536. * | --- | --- | --- |
  12537. * | 0 | BILLBOARDMODE_NONE | |
  12538. * | 1 | BILLBOARDMODE_X | |
  12539. * | 2 | BILLBOARDMODE_Y | |
  12540. * | 4 | BILLBOARDMODE_Z | |
  12541. * | 7 | BILLBOARDMODE_ALL | |
  12542. *
  12543. */
  12544. billboardMode: number;
  12545. /**
  12546. * 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
  12547. */
  12548. scalingDeterminant: number;
  12549. /**
  12550. * Sets the distance of the object to max, often used by skybox
  12551. */
  12552. infiniteDistance: boolean;
  12553. /**
  12554. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12555. * By default the system will update normals to compensate
  12556. */
  12557. ignoreNonUniformScaling: boolean;
  12558. /** @hidden */
  12559. _poseMatrix: Matrix;
  12560. /** @hidden */
  12561. _localMatrix: Matrix;
  12562. private _absolutePosition;
  12563. private _pivotMatrix;
  12564. private _pivotMatrixInverse;
  12565. protected _postMultiplyPivotMatrix: boolean;
  12566. protected _isWorldMatrixFrozen: boolean;
  12567. /** @hidden */
  12568. _indexInSceneTransformNodesArray: number;
  12569. /**
  12570. * An event triggered after the world matrix is updated
  12571. */
  12572. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12573. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12574. /**
  12575. * Gets a string identifying the name of the class
  12576. * @returns "TransformNode" string
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12581. */
  12582. position: Vector3;
  12583. /**
  12584. * 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)).
  12585. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12586. */
  12587. rotation: Vector3;
  12588. /**
  12589. * 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)).
  12590. */
  12591. scaling: Vector3;
  12592. /**
  12593. * 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).
  12594. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12595. */
  12596. rotationQuaternion: Nullable<Quaternion>;
  12597. /**
  12598. * The forward direction of that transform in world space.
  12599. */
  12600. readonly forward: Vector3;
  12601. /**
  12602. * The up direction of that transform in world space.
  12603. */
  12604. readonly up: Vector3;
  12605. /**
  12606. * The right direction of that transform in world space.
  12607. */
  12608. readonly right: Vector3;
  12609. /**
  12610. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12611. * @param matrix the matrix to copy the pose from
  12612. * @returns this TransformNode.
  12613. */
  12614. updatePoseMatrix(matrix: Matrix): TransformNode;
  12615. /**
  12616. * Returns the mesh Pose matrix.
  12617. * @returns the pose matrix
  12618. */
  12619. getPoseMatrix(): Matrix;
  12620. /** @hidden */
  12621. _isSynchronized(): boolean;
  12622. /** @hidden */
  12623. _initCache(): void;
  12624. /**
  12625. * Flag the transform node as dirty (Forcing it to update everything)
  12626. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12627. * @returns this transform node
  12628. */
  12629. markAsDirty(property: string): TransformNode;
  12630. /**
  12631. * Returns the current mesh absolute position.
  12632. * Returns a Vector3.
  12633. */
  12634. readonly absolutePosition: Vector3;
  12635. /**
  12636. * Sets a new matrix to apply before all other transformation
  12637. * @param matrix defines the transform matrix
  12638. * @returns the current TransformNode
  12639. */
  12640. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12641. /**
  12642. * Sets a new pivot matrix to the current node
  12643. * @param matrix defines the new pivot matrix to use
  12644. * @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
  12645. * @returns the current TransformNode
  12646. */
  12647. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12648. /**
  12649. * Returns the mesh pivot matrix.
  12650. * Default : Identity.
  12651. * @returns the matrix
  12652. */
  12653. getPivotMatrix(): Matrix;
  12654. /**
  12655. * Prevents the World matrix to be computed any longer.
  12656. * @returns the TransformNode.
  12657. */
  12658. freezeWorldMatrix(): TransformNode;
  12659. /**
  12660. * Allows back the World matrix computation.
  12661. * @returns the TransformNode.
  12662. */
  12663. unfreezeWorldMatrix(): this;
  12664. /**
  12665. * True if the World matrix has been frozen.
  12666. */
  12667. readonly isWorldMatrixFrozen: boolean;
  12668. /**
  12669. * Retuns the mesh absolute position in the World.
  12670. * @returns a Vector3.
  12671. */
  12672. getAbsolutePosition(): Vector3;
  12673. /**
  12674. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12675. * @param absolutePosition the absolute position to set
  12676. * @returns the TransformNode.
  12677. */
  12678. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12679. /**
  12680. * Sets the mesh position in its local space.
  12681. * @param vector3 the position to set in localspace
  12682. * @returns the TransformNode.
  12683. */
  12684. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12685. /**
  12686. * Returns the mesh position in the local space from the current World matrix values.
  12687. * @returns a new Vector3.
  12688. */
  12689. getPositionExpressedInLocalSpace(): Vector3;
  12690. /**
  12691. * Translates the mesh along the passed Vector3 in its local space.
  12692. * @param vector3 the distance to translate in localspace
  12693. * @returns the TransformNode.
  12694. */
  12695. locallyTranslate(vector3: Vector3): TransformNode;
  12696. private static _lookAtVectorCache;
  12697. /**
  12698. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12699. * @param targetPoint the position (must be in same space as current mesh) to look at
  12700. * @param yawCor optional yaw (y-axis) correction in radians
  12701. * @param pitchCor optional pitch (x-axis) correction in radians
  12702. * @param rollCor optional roll (z-axis) correction in radians
  12703. * @param space the choosen space of the target
  12704. * @returns the TransformNode.
  12705. */
  12706. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12707. /**
  12708. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12709. * This Vector3 is expressed in the World space.
  12710. * @param localAxis axis to rotate
  12711. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12712. */
  12713. getDirection(localAxis: Vector3): Vector3;
  12714. /**
  12715. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12716. * localAxis is expressed in the mesh local space.
  12717. * result is computed in the Wordl space from the mesh World matrix.
  12718. * @param localAxis axis to rotate
  12719. * @param result the resulting transformnode
  12720. * @returns this TransformNode.
  12721. */
  12722. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12723. /**
  12724. * Sets this transform node rotation to the given local axis.
  12725. * @param localAxis the axis in local space
  12726. * @param yawCor optional yaw (y-axis) correction in radians
  12727. * @param pitchCor optional pitch (x-axis) correction in radians
  12728. * @param rollCor optional roll (z-axis) correction in radians
  12729. * @returns this TransformNode
  12730. */
  12731. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12732. /**
  12733. * Sets a new pivot point to the current node
  12734. * @param point defines the new pivot point to use
  12735. * @param space defines if the point is in world or local space (local by default)
  12736. * @returns the current TransformNode
  12737. */
  12738. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12739. /**
  12740. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12741. * @returns the pivot point
  12742. */
  12743. getPivotPoint(): Vector3;
  12744. /**
  12745. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12746. * @param result the vector3 to store the result
  12747. * @returns this TransformNode.
  12748. */
  12749. getPivotPointToRef(result: Vector3): TransformNode;
  12750. /**
  12751. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12752. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12753. */
  12754. getAbsolutePivotPoint(): Vector3;
  12755. /**
  12756. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12757. * @param result vector3 to store the result
  12758. * @returns this TransformNode.
  12759. */
  12760. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12761. /**
  12762. * Defines the passed node as the parent of the current node.
  12763. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12764. * @param node the node ot set as the parent
  12765. * @returns this TransformNode.
  12766. */
  12767. setParent(node: Nullable<Node>): TransformNode;
  12768. private _nonUniformScaling;
  12769. /**
  12770. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12771. */
  12772. readonly nonUniformScaling: boolean;
  12773. /** @hidden */
  12774. _updateNonUniformScalingState(value: boolean): boolean;
  12775. /**
  12776. * Attach the current TransformNode to another TransformNode associated with a bone
  12777. * @param bone Bone affecting the TransformNode
  12778. * @param affectedTransformNode TransformNode associated with the bone
  12779. * @returns this object
  12780. */
  12781. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12782. /**
  12783. * Detach the transform node if its associated with a bone
  12784. * @returns this object
  12785. */
  12786. detachFromBone(): TransformNode;
  12787. private static _rotationAxisCache;
  12788. /**
  12789. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12790. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12791. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12792. * The passed axis is also normalized.
  12793. * @param axis the axis to rotate around
  12794. * @param amount the amount to rotate in radians
  12795. * @param space Space to rotate in (Default: local)
  12796. * @returns the TransformNode.
  12797. */
  12798. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12799. /**
  12800. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12801. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12802. * The passed axis is also normalized. .
  12803. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12804. * @param point the point to rotate around
  12805. * @param axis the axis to rotate around
  12806. * @param amount the amount to rotate in radians
  12807. * @returns the TransformNode
  12808. */
  12809. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12810. /**
  12811. * Translates the mesh along the axis vector for the passed distance in the given space.
  12812. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12813. * @param axis the axis to translate in
  12814. * @param distance the distance to translate
  12815. * @param space Space to rotate in (Default: local)
  12816. * @returns the TransformNode.
  12817. */
  12818. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12819. /**
  12820. * Adds a rotation step to the mesh current rotation.
  12821. * x, y, z are Euler angles expressed in radians.
  12822. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12823. * This means this rotation is made in the mesh local space only.
  12824. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12825. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12826. * ```javascript
  12827. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12828. * ```
  12829. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12830. * 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.
  12831. * @param x Rotation to add
  12832. * @param y Rotation to add
  12833. * @param z Rotation to add
  12834. * @returns the TransformNode.
  12835. */
  12836. addRotation(x: number, y: number, z: number): TransformNode;
  12837. /**
  12838. * Computes the world matrix of the node
  12839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12840. * @returns the world matrix
  12841. */
  12842. computeWorldMatrix(force?: boolean): Matrix;
  12843. protected _afterComputeWorldMatrix(): void;
  12844. /**
  12845. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12846. * @param func callback function to add
  12847. *
  12848. * @returns the TransformNode.
  12849. */
  12850. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12851. /**
  12852. * Removes a registered callback function.
  12853. * @param func callback function to remove
  12854. * @returns the TransformNode.
  12855. */
  12856. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12857. /**
  12858. * Gets the position of the current mesh in camera space
  12859. * @param camera defines the camera to use
  12860. * @returns a position
  12861. */
  12862. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12863. /**
  12864. * Returns the distance from the mesh to the active camera
  12865. * @param camera defines the camera to use
  12866. * @returns the distance
  12867. */
  12868. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12869. /**
  12870. * Clone the current transform node
  12871. * @param name Name of the new clone
  12872. * @param newParent New parent for the clone
  12873. * @param doNotCloneChildren Do not clone children hierarchy
  12874. * @returns the new transform node
  12875. */
  12876. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12877. /**
  12878. * Serializes the objects information.
  12879. * @param currentSerializationObject defines the object to serialize in
  12880. * @returns the serialized object
  12881. */
  12882. serialize(currentSerializationObject?: any): any;
  12883. /**
  12884. * Returns a new TransformNode object parsed from the source provided.
  12885. * @param parsedTransformNode is the source.
  12886. * @param scene the scne the object belongs to
  12887. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12888. * @returns a new TransformNode object parsed from the source provided.
  12889. */
  12890. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12891. /**
  12892. * Get all child-transformNodes of this node
  12893. * @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
  12894. * @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
  12895. * @returns an array of TransformNode
  12896. */
  12897. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12898. /**
  12899. * Releases resources associated with this transform node.
  12900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12902. */
  12903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12904. }
  12905. }
  12906. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12907. import { Observable } from "babylonjs/Misc/observable";
  12908. import { Nullable } from "babylonjs/types";
  12909. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12910. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12912. import { Ray } from "babylonjs/Culling/ray";
  12913. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12914. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12915. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12916. /**
  12917. * Defines the types of pose enabled controllers that are supported
  12918. */
  12919. export enum PoseEnabledControllerType {
  12920. /**
  12921. * HTC Vive
  12922. */
  12923. VIVE = 0,
  12924. /**
  12925. * Oculus Rift
  12926. */
  12927. OCULUS = 1,
  12928. /**
  12929. * Windows mixed reality
  12930. */
  12931. WINDOWS = 2,
  12932. /**
  12933. * Samsung gear VR
  12934. */
  12935. GEAR_VR = 3,
  12936. /**
  12937. * Google Daydream
  12938. */
  12939. DAYDREAM = 4,
  12940. /**
  12941. * Generic
  12942. */
  12943. GENERIC = 5
  12944. }
  12945. /**
  12946. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12947. */
  12948. export interface MutableGamepadButton {
  12949. /**
  12950. * Value of the button/trigger
  12951. */
  12952. value: number;
  12953. /**
  12954. * If the button/trigger is currently touched
  12955. */
  12956. touched: boolean;
  12957. /**
  12958. * If the button/trigger is currently pressed
  12959. */
  12960. pressed: boolean;
  12961. }
  12962. /**
  12963. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12964. * @hidden
  12965. */
  12966. export interface ExtendedGamepadButton extends GamepadButton {
  12967. /**
  12968. * If the button/trigger is currently pressed
  12969. */
  12970. readonly pressed: boolean;
  12971. /**
  12972. * If the button/trigger is currently touched
  12973. */
  12974. readonly touched: boolean;
  12975. /**
  12976. * Value of the button/trigger
  12977. */
  12978. readonly value: number;
  12979. }
  12980. /** @hidden */
  12981. export interface _GamePadFactory {
  12982. /**
  12983. * Returns wether or not the current gamepad can be created for this type of controller.
  12984. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12985. * @returns true if it can be created, otherwise false
  12986. */
  12987. canCreate(gamepadInfo: any): boolean;
  12988. /**
  12989. * Creates a new instance of the Gamepad.
  12990. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12991. * @returns the new gamepad instance
  12992. */
  12993. create(gamepadInfo: any): Gamepad;
  12994. }
  12995. /**
  12996. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12997. */
  12998. export class PoseEnabledControllerHelper {
  12999. /** @hidden */
  13000. static _ControllerFactories: _GamePadFactory[];
  13001. /** @hidden */
  13002. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13003. /**
  13004. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13005. * @param vrGamepad the gamepad to initialized
  13006. * @returns a vr controller of the type the gamepad identified as
  13007. */
  13008. static InitiateController(vrGamepad: any): Gamepad;
  13009. }
  13010. /**
  13011. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13012. */
  13013. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13014. private _deviceRoomPosition;
  13015. private _deviceRoomRotationQuaternion;
  13016. /**
  13017. * The device position in babylon space
  13018. */
  13019. devicePosition: Vector3;
  13020. /**
  13021. * The device rotation in babylon space
  13022. */
  13023. deviceRotationQuaternion: Quaternion;
  13024. /**
  13025. * The scale factor of the device in babylon space
  13026. */
  13027. deviceScaleFactor: number;
  13028. /**
  13029. * (Likely devicePosition should be used instead) The device position in its room space
  13030. */
  13031. position: Vector3;
  13032. /**
  13033. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13034. */
  13035. rotationQuaternion: Quaternion;
  13036. /**
  13037. * The type of controller (Eg. Windows mixed reality)
  13038. */
  13039. controllerType: PoseEnabledControllerType;
  13040. protected _calculatedPosition: Vector3;
  13041. private _calculatedRotation;
  13042. /**
  13043. * The raw pose from the device
  13044. */
  13045. rawPose: DevicePose;
  13046. private _trackPosition;
  13047. private _maxRotationDistFromHeadset;
  13048. private _draggedRoomRotation;
  13049. /**
  13050. * @hidden
  13051. */
  13052. _disableTrackPosition(fixedPosition: Vector3): void;
  13053. /**
  13054. * Internal, the mesh attached to the controller
  13055. * @hidden
  13056. */
  13057. _mesh: Nullable<AbstractMesh>;
  13058. private _poseControlledCamera;
  13059. private _leftHandSystemQuaternion;
  13060. /**
  13061. * Internal, matrix used to convert room space to babylon space
  13062. * @hidden
  13063. */
  13064. _deviceToWorld: Matrix;
  13065. /**
  13066. * Node to be used when casting a ray from the controller
  13067. * @hidden
  13068. */
  13069. _pointingPoseNode: Nullable<TransformNode>;
  13070. /**
  13071. * Name of the child mesh that can be used to cast a ray from the controller
  13072. */
  13073. static readonly POINTING_POSE: string;
  13074. /**
  13075. * Creates a new PoseEnabledController from a gamepad
  13076. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13077. */
  13078. constructor(browserGamepad: any);
  13079. private _workingMatrix;
  13080. /**
  13081. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13082. */
  13083. update(): void;
  13084. /**
  13085. * Updates only the pose device and mesh without doing any button event checking
  13086. */
  13087. protected _updatePoseAndMesh(): void;
  13088. /**
  13089. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13090. * @param poseData raw pose fromthe device
  13091. */
  13092. updateFromDevice(poseData: DevicePose): void;
  13093. /**
  13094. * @hidden
  13095. */
  13096. _meshAttachedObservable: Observable<AbstractMesh>;
  13097. /**
  13098. * Attaches a mesh to the controller
  13099. * @param mesh the mesh to be attached
  13100. */
  13101. attachToMesh(mesh: AbstractMesh): void;
  13102. /**
  13103. * Attaches the controllers mesh to a camera
  13104. * @param camera the camera the mesh should be attached to
  13105. */
  13106. attachToPoseControlledCamera(camera: TargetCamera): void;
  13107. /**
  13108. * Disposes of the controller
  13109. */
  13110. dispose(): void;
  13111. /**
  13112. * The mesh that is attached to the controller
  13113. */
  13114. readonly mesh: Nullable<AbstractMesh>;
  13115. /**
  13116. * Gets the ray of the controller in the direction the controller is pointing
  13117. * @param length the length the resulting ray should be
  13118. * @returns a ray in the direction the controller is pointing
  13119. */
  13120. getForwardRay(length?: number): Ray;
  13121. }
  13122. }
  13123. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13124. import { Observable } from "babylonjs/Misc/observable";
  13125. import { Scene } from "babylonjs/scene";
  13126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13127. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13128. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13129. /**
  13130. * Defines the WebVRController object that represents controllers tracked in 3D space
  13131. */
  13132. export abstract class WebVRController extends PoseEnabledController {
  13133. /**
  13134. * Internal, the default controller model for the controller
  13135. */
  13136. protected _defaultModel: AbstractMesh;
  13137. /**
  13138. * Fired when the trigger state has changed
  13139. */
  13140. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13141. /**
  13142. * Fired when the main button state has changed
  13143. */
  13144. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13145. /**
  13146. * Fired when the secondary button state has changed
  13147. */
  13148. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13149. /**
  13150. * Fired when the pad state has changed
  13151. */
  13152. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13153. /**
  13154. * Fired when controllers stick values have changed
  13155. */
  13156. onPadValuesChangedObservable: Observable<StickValues>;
  13157. /**
  13158. * Array of button availible on the controller
  13159. */
  13160. protected _buttons: Array<MutableGamepadButton>;
  13161. private _onButtonStateChange;
  13162. /**
  13163. * Fired when a controller button's state has changed
  13164. * @param callback the callback containing the button that was modified
  13165. */
  13166. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13167. /**
  13168. * X and Y axis corrisponding to the controllers joystick
  13169. */
  13170. pad: StickValues;
  13171. /**
  13172. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13173. */
  13174. hand: string;
  13175. /**
  13176. * The default controller model for the controller
  13177. */
  13178. readonly defaultModel: AbstractMesh;
  13179. /**
  13180. * Creates a new WebVRController from a gamepad
  13181. * @param vrGamepad the gamepad that the WebVRController should be created from
  13182. */
  13183. constructor(vrGamepad: any);
  13184. /**
  13185. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13186. */
  13187. update(): void;
  13188. /**
  13189. * Function to be called when a button is modified
  13190. */
  13191. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13192. /**
  13193. * Loads a mesh and attaches it to the controller
  13194. * @param scene the scene the mesh should be added to
  13195. * @param meshLoaded callback for when the mesh has been loaded
  13196. */
  13197. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13198. private _setButtonValue;
  13199. private _changes;
  13200. private _checkChanges;
  13201. /**
  13202. * Disposes of th webVRCOntroller
  13203. */
  13204. dispose(): void;
  13205. }
  13206. }
  13207. declare module "babylonjs/Lights/hemisphericLight" {
  13208. import { Nullable } from "babylonjs/types";
  13209. import { Scene } from "babylonjs/scene";
  13210. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13211. import { Effect } from "babylonjs/Materials/effect";
  13212. import { Light } from "babylonjs/Lights/light";
  13213. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13214. /**
  13215. * The HemisphericLight simulates the ambient environment light,
  13216. * so the passed direction is the light reflection direction, not the incoming direction.
  13217. */
  13218. export class HemisphericLight extends Light {
  13219. /**
  13220. * The groundColor is the light in the opposite direction to the one specified during creation.
  13221. * 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.
  13222. */
  13223. groundColor: Color3;
  13224. /**
  13225. * The light reflection direction, not the incoming direction.
  13226. */
  13227. direction: Vector3;
  13228. /**
  13229. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13230. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13231. * The HemisphericLight can't cast shadows.
  13232. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13233. * @param name The friendly name of the light
  13234. * @param direction The direction of the light reflection
  13235. * @param scene The scene the light belongs to
  13236. */
  13237. constructor(name: string, direction: Vector3, scene: Scene);
  13238. protected _buildUniformLayout(): void;
  13239. /**
  13240. * Returns the string "HemisphericLight".
  13241. * @return The class name
  13242. */
  13243. getClassName(): string;
  13244. /**
  13245. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13246. * Returns the updated direction.
  13247. * @param target The target the direction should point to
  13248. * @return The computed direction
  13249. */
  13250. setDirectionToTarget(target: Vector3): Vector3;
  13251. /**
  13252. * Returns the shadow generator associated to the light.
  13253. * @returns Always null for hemispheric lights because it does not support shadows.
  13254. */
  13255. getShadowGenerator(): Nullable<IShadowGenerator>;
  13256. /**
  13257. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13258. * @param effect The effect to update
  13259. * @param lightIndex The index of the light in the effect to update
  13260. * @returns The hemispheric light
  13261. */
  13262. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13263. /**
  13264. * Computes the world matrix of the node
  13265. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13266. * @param useWasUpdatedFlag defines a reserved property
  13267. * @returns the world matrix
  13268. */
  13269. computeWorldMatrix(): Matrix;
  13270. /**
  13271. * Returns the integer 3.
  13272. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13273. */
  13274. getTypeID(): number;
  13275. /**
  13276. * Prepares the list of defines specific to the light type.
  13277. * @param defines the list of defines
  13278. * @param lightIndex defines the index of the light for the effect
  13279. */
  13280. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13281. }
  13282. }
  13283. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13284. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13285. import { Nullable } from "babylonjs/types";
  13286. import { Observable } from "babylonjs/Misc/observable";
  13287. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13288. import { Scene } from "babylonjs/scene";
  13289. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13290. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13291. import { Node } from "babylonjs/node";
  13292. import { Ray } from "babylonjs/Culling/ray";
  13293. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13294. /**
  13295. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13296. * IMPORTANT!! The data is right-hand data.
  13297. * @export
  13298. * @interface DevicePose
  13299. */
  13300. export interface DevicePose {
  13301. /**
  13302. * The position of the device, values in array are [x,y,z].
  13303. */
  13304. readonly position: Nullable<Float32Array>;
  13305. /**
  13306. * The linearVelocity of the device, values in array are [x,y,z].
  13307. */
  13308. readonly linearVelocity: Nullable<Float32Array>;
  13309. /**
  13310. * The linearAcceleration of the device, values in array are [x,y,z].
  13311. */
  13312. readonly linearAcceleration: Nullable<Float32Array>;
  13313. /**
  13314. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13315. */
  13316. readonly orientation: Nullable<Float32Array>;
  13317. /**
  13318. * The angularVelocity of the device, values in array are [x,y,z].
  13319. */
  13320. readonly angularVelocity: Nullable<Float32Array>;
  13321. /**
  13322. * The angularAcceleration of the device, values in array are [x,y,z].
  13323. */
  13324. readonly angularAcceleration: Nullable<Float32Array>;
  13325. }
  13326. /**
  13327. * Interface representing a pose controlled object in Babylon.
  13328. * A pose controlled object has both regular pose values as well as pose values
  13329. * from an external device such as a VR head mounted display
  13330. */
  13331. export interface PoseControlled {
  13332. /**
  13333. * The position of the object in babylon space.
  13334. */
  13335. position: Vector3;
  13336. /**
  13337. * The rotation quaternion of the object in babylon space.
  13338. */
  13339. rotationQuaternion: Quaternion;
  13340. /**
  13341. * The position of the device in babylon space.
  13342. */
  13343. devicePosition?: Vector3;
  13344. /**
  13345. * The rotation quaternion of the device in babylon space.
  13346. */
  13347. deviceRotationQuaternion: Quaternion;
  13348. /**
  13349. * The raw pose coming from the device.
  13350. */
  13351. rawPose: Nullable<DevicePose>;
  13352. /**
  13353. * The scale of the device to be used when translating from device space to babylon space.
  13354. */
  13355. deviceScaleFactor: number;
  13356. /**
  13357. * Updates the poseControlled values based on the input device pose.
  13358. * @param poseData the pose data to update the object with
  13359. */
  13360. updateFromDevice(poseData: DevicePose): void;
  13361. }
  13362. /**
  13363. * Set of options to customize the webVRCamera
  13364. */
  13365. export interface WebVROptions {
  13366. /**
  13367. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13368. */
  13369. trackPosition?: boolean;
  13370. /**
  13371. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13372. */
  13373. positionScale?: number;
  13374. /**
  13375. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13376. */
  13377. displayName?: string;
  13378. /**
  13379. * Should the native controller meshes be initialized. (default: true)
  13380. */
  13381. controllerMeshes?: boolean;
  13382. /**
  13383. * Creating a default HemiLight only on controllers. (default: true)
  13384. */
  13385. defaultLightingOnControllers?: boolean;
  13386. /**
  13387. * If you don't want to use the default VR button of the helper. (default: false)
  13388. */
  13389. useCustomVRButton?: boolean;
  13390. /**
  13391. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13392. */
  13393. customVRButton?: HTMLButtonElement;
  13394. /**
  13395. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13396. */
  13397. rayLength?: number;
  13398. /**
  13399. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13400. */
  13401. defaultHeight?: number;
  13402. }
  13403. /**
  13404. * This represents a WebVR camera.
  13405. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13406. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13407. */
  13408. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13409. private webVROptions;
  13410. /**
  13411. * @hidden
  13412. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13413. */
  13414. _vrDevice: any;
  13415. /**
  13416. * The rawPose of the vrDevice.
  13417. */
  13418. rawPose: Nullable<DevicePose>;
  13419. private _onVREnabled;
  13420. private _specsVersion;
  13421. private _attached;
  13422. private _frameData;
  13423. protected _descendants: Array<Node>;
  13424. private _deviceRoomPosition;
  13425. /** @hidden */
  13426. _deviceRoomRotationQuaternion: Quaternion;
  13427. private _standingMatrix;
  13428. /**
  13429. * Represents device position in babylon space.
  13430. */
  13431. devicePosition: Vector3;
  13432. /**
  13433. * Represents device rotation in babylon space.
  13434. */
  13435. deviceRotationQuaternion: Quaternion;
  13436. /**
  13437. * The scale of the device to be used when translating from device space to babylon space.
  13438. */
  13439. deviceScaleFactor: number;
  13440. private _deviceToWorld;
  13441. private _worldToDevice;
  13442. /**
  13443. * References to the webVR controllers for the vrDevice.
  13444. */
  13445. controllers: Array<WebVRController>;
  13446. /**
  13447. * Emits an event when a controller is attached.
  13448. */
  13449. onControllersAttachedObservable: Observable<WebVRController[]>;
  13450. /**
  13451. * Emits an event when a controller's mesh has been loaded;
  13452. */
  13453. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13454. /**
  13455. * Emits an event when the HMD's pose has been updated.
  13456. */
  13457. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13458. private _poseSet;
  13459. /**
  13460. * If the rig cameras be used as parent instead of this camera.
  13461. */
  13462. rigParenting: boolean;
  13463. private _lightOnControllers;
  13464. private _defaultHeight?;
  13465. /**
  13466. * Instantiates a WebVRFreeCamera.
  13467. * @param name The name of the WebVRFreeCamera
  13468. * @param position The starting anchor position for the camera
  13469. * @param scene The scene the camera belongs to
  13470. * @param webVROptions a set of customizable options for the webVRCamera
  13471. */
  13472. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13473. /**
  13474. * Gets the device distance from the ground in meters.
  13475. * @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.
  13476. */
  13477. deviceDistanceToRoomGround(): number;
  13478. /**
  13479. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13480. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13481. */
  13482. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13483. /**
  13484. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13485. * @returns A promise with a boolean set to if the standing matrix is supported.
  13486. */
  13487. useStandingMatrixAsync(): Promise<boolean>;
  13488. /**
  13489. * Disposes the camera
  13490. */
  13491. dispose(): void;
  13492. /**
  13493. * Gets a vrController by name.
  13494. * @param name The name of the controller to retreive
  13495. * @returns the controller matching the name specified or null if not found
  13496. */
  13497. getControllerByName(name: string): Nullable<WebVRController>;
  13498. private _leftController;
  13499. /**
  13500. * The controller corrisponding to the users left hand.
  13501. */
  13502. readonly leftController: Nullable<WebVRController>;
  13503. private _rightController;
  13504. /**
  13505. * The controller corrisponding to the users right hand.
  13506. */
  13507. readonly rightController: Nullable<WebVRController>;
  13508. /**
  13509. * Casts a ray forward from the vrCamera's gaze.
  13510. * @param length Length of the ray (default: 100)
  13511. * @returns the ray corrisponding to the gaze
  13512. */
  13513. getForwardRay(length?: number): Ray;
  13514. /**
  13515. * @hidden
  13516. * Updates the camera based on device's frame data
  13517. */
  13518. _checkInputs(): void;
  13519. /**
  13520. * Updates the poseControlled values based on the input device pose.
  13521. * @param poseData Pose coming from the device
  13522. */
  13523. updateFromDevice(poseData: DevicePose): void;
  13524. private _htmlElementAttached;
  13525. private _detachIfAttached;
  13526. /**
  13527. * WebVR's attach control will start broadcasting frames to the device.
  13528. * Note that in certain browsers (chrome for example) this function must be called
  13529. * within a user-interaction callback. Example:
  13530. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13531. *
  13532. * @param element html element to attach the vrDevice to
  13533. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13534. */
  13535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13536. /**
  13537. * Detaches the camera from the html element and disables VR
  13538. *
  13539. * @param element html element to detach from
  13540. */
  13541. detachControl(element: HTMLElement): void;
  13542. /**
  13543. * @returns the name of this class
  13544. */
  13545. getClassName(): string;
  13546. /**
  13547. * Calls resetPose on the vrDisplay
  13548. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13549. */
  13550. resetToCurrentRotation(): void;
  13551. /**
  13552. * @hidden
  13553. * Updates the rig cameras (left and right eye)
  13554. */
  13555. _updateRigCameras(): void;
  13556. private _workingVector;
  13557. private _oneVector;
  13558. private _workingMatrix;
  13559. private updateCacheCalled;
  13560. private _correctPositionIfNotTrackPosition;
  13561. /**
  13562. * @hidden
  13563. * Updates the cached values of the camera
  13564. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13565. */
  13566. _updateCache(ignoreParentClass?: boolean): void;
  13567. /**
  13568. * @hidden
  13569. * Get current device position in babylon world
  13570. */
  13571. _computeDevicePosition(): void;
  13572. /**
  13573. * Updates the current device position and rotation in the babylon world
  13574. */
  13575. update(): void;
  13576. /**
  13577. * @hidden
  13578. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13579. * @returns an identity matrix
  13580. */
  13581. _getViewMatrix(): Matrix;
  13582. private _tmpMatrix;
  13583. /**
  13584. * This function is called by the two RIG cameras.
  13585. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13586. * @hidden
  13587. */
  13588. _getWebVRViewMatrix(): Matrix;
  13589. /** @hidden */
  13590. _getWebVRProjectionMatrix(): Matrix;
  13591. private _onGamepadConnectedObserver;
  13592. private _onGamepadDisconnectedObserver;
  13593. private _updateCacheWhenTrackingDisabledObserver;
  13594. /**
  13595. * Initializes the controllers and their meshes
  13596. */
  13597. initControllers(): void;
  13598. }
  13599. }
  13600. declare module "babylonjs/PostProcesses/postProcess" {
  13601. import { Nullable } from "babylonjs/types";
  13602. import { SmartArray } from "babylonjs/Misc/smartArray";
  13603. import { Observable } from "babylonjs/Misc/observable";
  13604. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13605. import { Camera } from "babylonjs/Cameras/camera";
  13606. import { Effect } from "babylonjs/Materials/effect";
  13607. import "babylonjs/Shaders/postprocess.vertex";
  13608. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13609. import { Engine } from "babylonjs/Engines/engine";
  13610. /**
  13611. * Size options for a post process
  13612. */
  13613. export type PostProcessOptions = {
  13614. width: number;
  13615. height: number;
  13616. };
  13617. /**
  13618. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13619. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13620. */
  13621. export class PostProcess {
  13622. /** Name of the PostProcess. */
  13623. name: string;
  13624. /**
  13625. * Gets or sets the unique id of the post process
  13626. */
  13627. uniqueId: number;
  13628. /**
  13629. * Width of the texture to apply the post process on
  13630. */
  13631. width: number;
  13632. /**
  13633. * Height of the texture to apply the post process on
  13634. */
  13635. height: number;
  13636. /**
  13637. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13638. * @hidden
  13639. */
  13640. _outputTexture: Nullable<InternalTexture>;
  13641. /**
  13642. * Sampling mode used by the shader
  13643. * See https://doc.babylonjs.com/classes/3.1/texture
  13644. */
  13645. renderTargetSamplingMode: number;
  13646. /**
  13647. * Clear color to use when screen clearing
  13648. */
  13649. clearColor: Color4;
  13650. /**
  13651. * If the buffer needs to be cleared before applying the post process. (default: true)
  13652. * Should be set to false if shader will overwrite all previous pixels.
  13653. */
  13654. autoClear: boolean;
  13655. /**
  13656. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13657. */
  13658. alphaMode: number;
  13659. /**
  13660. * Sets the setAlphaBlendConstants of the babylon engine
  13661. */
  13662. alphaConstants: Color4;
  13663. /**
  13664. * Animations to be used for the post processing
  13665. */
  13666. animations: import("babylonjs/Animations/animation").Animation[];
  13667. /**
  13668. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13669. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13670. */
  13671. enablePixelPerfectMode: boolean;
  13672. /**
  13673. * Force the postprocess to be applied without taking in account viewport
  13674. */
  13675. forceFullscreenViewport: boolean;
  13676. /**
  13677. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13678. *
  13679. * | Value | Type | Description |
  13680. * | ----- | ----------------------------------- | ----------- |
  13681. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13682. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13683. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13684. *
  13685. */
  13686. scaleMode: number;
  13687. /**
  13688. * Force textures to be a power of two (default: false)
  13689. */
  13690. alwaysForcePOT: boolean;
  13691. private _samples;
  13692. /**
  13693. * Number of sample textures (default: 1)
  13694. */
  13695. samples: number;
  13696. /**
  13697. * Modify the scale of the post process to be the same as the viewport (default: false)
  13698. */
  13699. adaptScaleToCurrentViewport: boolean;
  13700. private _camera;
  13701. private _scene;
  13702. private _engine;
  13703. private _options;
  13704. private _reusable;
  13705. private _textureType;
  13706. /**
  13707. * Smart array of input and output textures for the post process.
  13708. * @hidden
  13709. */
  13710. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13711. /**
  13712. * The index in _textures that corresponds to the output texture.
  13713. * @hidden
  13714. */
  13715. _currentRenderTextureInd: number;
  13716. private _effect;
  13717. private _samplers;
  13718. private _fragmentUrl;
  13719. private _vertexUrl;
  13720. private _parameters;
  13721. private _scaleRatio;
  13722. protected _indexParameters: any;
  13723. private _shareOutputWithPostProcess;
  13724. private _texelSize;
  13725. private _forcedOutputTexture;
  13726. /**
  13727. * Returns the fragment url or shader name used in the post process.
  13728. * @returns the fragment url or name in the shader store.
  13729. */
  13730. getEffectName(): string;
  13731. /**
  13732. * An event triggered when the postprocess is activated.
  13733. */
  13734. onActivateObservable: Observable<Camera>;
  13735. private _onActivateObserver;
  13736. /**
  13737. * A function that is added to the onActivateObservable
  13738. */
  13739. onActivate: Nullable<(camera: Camera) => void>;
  13740. /**
  13741. * An event triggered when the postprocess changes its size.
  13742. */
  13743. onSizeChangedObservable: Observable<PostProcess>;
  13744. private _onSizeChangedObserver;
  13745. /**
  13746. * A function that is added to the onSizeChangedObservable
  13747. */
  13748. onSizeChanged: (postProcess: PostProcess) => void;
  13749. /**
  13750. * An event triggered when the postprocess applies its effect.
  13751. */
  13752. onApplyObservable: Observable<Effect>;
  13753. private _onApplyObserver;
  13754. /**
  13755. * A function that is added to the onApplyObservable
  13756. */
  13757. onApply: (effect: Effect) => void;
  13758. /**
  13759. * An event triggered before rendering the postprocess
  13760. */
  13761. onBeforeRenderObservable: Observable<Effect>;
  13762. private _onBeforeRenderObserver;
  13763. /**
  13764. * A function that is added to the onBeforeRenderObservable
  13765. */
  13766. onBeforeRender: (effect: Effect) => void;
  13767. /**
  13768. * An event triggered after rendering the postprocess
  13769. */
  13770. onAfterRenderObservable: Observable<Effect>;
  13771. private _onAfterRenderObserver;
  13772. /**
  13773. * A function that is added to the onAfterRenderObservable
  13774. */
  13775. onAfterRender: (efect: Effect) => void;
  13776. /**
  13777. * 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
  13778. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13779. */
  13780. inputTexture: InternalTexture;
  13781. /**
  13782. * Gets the camera which post process is applied to.
  13783. * @returns The camera the post process is applied to.
  13784. */
  13785. getCamera(): Camera;
  13786. /**
  13787. * Gets the texel size of the postprocess.
  13788. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13789. */
  13790. readonly texelSize: Vector2;
  13791. /**
  13792. * Creates a new instance PostProcess
  13793. * @param name The name of the PostProcess.
  13794. * @param fragmentUrl The url of the fragment shader to be used.
  13795. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13796. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13797. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13798. * @param camera The camera to apply the render pass to.
  13799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13800. * @param engine The engine which the post process will be applied. (default: current engine)
  13801. * @param reusable If the post process can be reused on the same frame. (default: false)
  13802. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13803. * @param textureType Type of textures used when performing the post process. (default: 0)
  13804. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13805. * @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
  13806. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13807. */
  13808. constructor(
  13809. /** Name of the PostProcess. */
  13810. 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);
  13811. /**
  13812. * Gets a string idenfifying the name of the class
  13813. * @returns "PostProcess" string
  13814. */
  13815. getClassName(): string;
  13816. /**
  13817. * Gets the engine which this post process belongs to.
  13818. * @returns The engine the post process was enabled with.
  13819. */
  13820. getEngine(): Engine;
  13821. /**
  13822. * The effect that is created when initializing the post process.
  13823. * @returns The created effect corrisponding the the postprocess.
  13824. */
  13825. getEffect(): Effect;
  13826. /**
  13827. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13828. * @param postProcess The post process to share the output with.
  13829. * @returns This post process.
  13830. */
  13831. shareOutputWith(postProcess: PostProcess): PostProcess;
  13832. /**
  13833. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13834. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13835. */
  13836. useOwnOutput(): void;
  13837. /**
  13838. * Updates the effect with the current post process compile time values and recompiles the shader.
  13839. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13840. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13841. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13842. * @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
  13843. * @param onCompiled Called when the shader has been compiled.
  13844. * @param onError Called if there is an error when compiling a shader.
  13845. */
  13846. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13847. /**
  13848. * The post process is reusable if it can be used multiple times within one frame.
  13849. * @returns If the post process is reusable
  13850. */
  13851. isReusable(): boolean;
  13852. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13853. markTextureDirty(): void;
  13854. /**
  13855. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13856. * 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.
  13857. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13858. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13859. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13860. * @returns The target texture that was bound to be written to.
  13861. */
  13862. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13863. /**
  13864. * If the post process is supported.
  13865. */
  13866. readonly isSupported: boolean;
  13867. /**
  13868. * The aspect ratio of the output texture.
  13869. */
  13870. readonly aspectRatio: number;
  13871. /**
  13872. * Get a value indicating if the post-process is ready to be used
  13873. * @returns true if the post-process is ready (shader is compiled)
  13874. */
  13875. isReady(): boolean;
  13876. /**
  13877. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13878. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13879. */
  13880. apply(): Nullable<Effect>;
  13881. private _disposeTextures;
  13882. /**
  13883. * Disposes the post process.
  13884. * @param camera The camera to dispose the post process on.
  13885. */
  13886. dispose(camera?: Camera): void;
  13887. }
  13888. }
  13889. declare module "babylonjs/PostProcesses/postProcessManager" {
  13890. import { Nullable } from "babylonjs/types";
  13891. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13892. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13893. import { Scene } from "babylonjs/scene";
  13894. /**
  13895. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13896. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13897. */
  13898. export class PostProcessManager {
  13899. private _scene;
  13900. private _indexBuffer;
  13901. private _vertexBuffers;
  13902. /**
  13903. * Creates a new instance PostProcess
  13904. * @param scene The scene that the post process is associated with.
  13905. */
  13906. constructor(scene: Scene);
  13907. private _prepareBuffers;
  13908. private _buildIndexBuffer;
  13909. /**
  13910. * Rebuilds the vertex buffers of the manager.
  13911. * @hidden
  13912. */
  13913. _rebuild(): void;
  13914. /**
  13915. * Prepares a frame to be run through a post process.
  13916. * @param sourceTexture The input texture to the post procesess. (default: null)
  13917. * @param postProcesses An array of post processes to be run. (default: null)
  13918. * @returns True if the post processes were able to be run.
  13919. * @hidden
  13920. */
  13921. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13922. /**
  13923. * Manually render a set of post processes to a texture.
  13924. * @param postProcesses An array of post processes to be run.
  13925. * @param targetTexture The target texture to render to.
  13926. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13927. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13928. * @param lodLevel defines which lod of the texture to render to
  13929. */
  13930. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13931. /**
  13932. * Finalize the result of the output of the postprocesses.
  13933. * @param doNotPresent If true the result will not be displayed to the screen.
  13934. * @param targetTexture The target texture to render to.
  13935. * @param faceIndex The index of the face to bind the target texture to.
  13936. * @param postProcesses The array of post processes to render.
  13937. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13938. * @hidden
  13939. */
  13940. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13941. /**
  13942. * Disposes of the post process manager.
  13943. */
  13944. dispose(): void;
  13945. }
  13946. }
  13947. declare module "babylonjs/Materials/Textures/rawTexture" {
  13948. import { Scene } from "babylonjs/scene";
  13949. import { Texture } from "babylonjs/Materials/Textures/texture";
  13950. /**
  13951. * Raw texture can help creating a texture directly from an array of data.
  13952. * This can be super useful if you either get the data from an uncompressed source or
  13953. * if you wish to create your texture pixel by pixel.
  13954. */
  13955. export class RawTexture extends Texture {
  13956. /**
  13957. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13958. */
  13959. format: number;
  13960. private _engine;
  13961. /**
  13962. * Instantiates a new RawTexture.
  13963. * Raw texture can help creating a texture directly from an array of data.
  13964. * This can be super useful if you either get the data from an uncompressed source or
  13965. * if you wish to create your texture pixel by pixel.
  13966. * @param data define the array of data to use to create the texture
  13967. * @param width define the width of the texture
  13968. * @param height define the height of the texture
  13969. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13970. * @param scene define the scene the texture belongs to
  13971. * @param generateMipMaps define whether mip maps should be generated or not
  13972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13975. */
  13976. constructor(data: ArrayBufferView, width: number, height: number,
  13977. /**
  13978. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13979. */
  13980. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13981. /**
  13982. * Updates the texture underlying data.
  13983. * @param data Define the new data of the texture
  13984. */
  13985. update(data: ArrayBufferView): void;
  13986. /**
  13987. * Creates a luminance texture from some data.
  13988. * @param data Define the texture data
  13989. * @param width Define the width of the texture
  13990. * @param height Define the height of the texture
  13991. * @param scene Define the scene the texture belongs to
  13992. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13993. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13994. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13995. * @returns the luminance texture
  13996. */
  13997. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13998. /**
  13999. * Creates a luminance alpha texture from some data.
  14000. * @param data Define the texture data
  14001. * @param width Define the width of the texture
  14002. * @param height Define the height of the texture
  14003. * @param scene Define the scene the texture belongs to
  14004. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14007. * @returns the luminance alpha texture
  14008. */
  14009. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14010. /**
  14011. * Creates an alpha texture from some data.
  14012. * @param data Define the texture data
  14013. * @param width Define the width of the texture
  14014. * @param height Define the height of the texture
  14015. * @param scene Define the scene the texture belongs to
  14016. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14017. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14018. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14019. * @returns the alpha texture
  14020. */
  14021. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14022. /**
  14023. * Creates a RGB texture from some data.
  14024. * @param data Define the texture data
  14025. * @param width Define the width of the texture
  14026. * @param height Define the height of the texture
  14027. * @param scene Define the scene the texture belongs to
  14028. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14032. * @returns the RGB alpha texture
  14033. */
  14034. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14035. /**
  14036. * Creates a RGBA texture from some data.
  14037. * @param data Define the texture data
  14038. * @param width Define the width of the texture
  14039. * @param height Define the height of the texture
  14040. * @param scene Define the scene the texture belongs to
  14041. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14044. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14045. * @returns the RGBA texture
  14046. */
  14047. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14048. /**
  14049. * Creates a R texture from some data.
  14050. * @param data Define the texture data
  14051. * @param width Define the width of the texture
  14052. * @param height Define the height of the texture
  14053. * @param scene Define the scene the texture belongs to
  14054. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14055. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14056. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14057. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14058. * @returns the R texture
  14059. */
  14060. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14061. }
  14062. }
  14063. declare module "babylonjs/Layers/layerSceneComponent" {
  14064. import { Scene } from "babylonjs/scene";
  14065. import { ISceneComponent } from "babylonjs/sceneComponent";
  14066. import { Layer } from "babylonjs/Layers/layer";
  14067. module "babylonjs/abstractScene" {
  14068. interface AbstractScene {
  14069. /**
  14070. * The list of layers (background and foreground) of the scene
  14071. */
  14072. layers: Array<Layer>;
  14073. }
  14074. }
  14075. /**
  14076. * Defines the layer scene component responsible to manage any layers
  14077. * in a given scene.
  14078. */
  14079. export class LayerSceneComponent implements ISceneComponent {
  14080. /**
  14081. * The component name helpfull to identify the component in the list of scene components.
  14082. */
  14083. readonly name: string;
  14084. /**
  14085. * The scene the component belongs to.
  14086. */
  14087. scene: Scene;
  14088. private _engine;
  14089. /**
  14090. * Creates a new instance of the component for the given scene
  14091. * @param scene Defines the scene to register the component in
  14092. */
  14093. constructor(scene: Scene);
  14094. /**
  14095. * Registers the component in a given scene
  14096. */
  14097. register(): void;
  14098. /**
  14099. * Rebuilds the elements related to this component in case of
  14100. * context lost for instance.
  14101. */
  14102. rebuild(): void;
  14103. /**
  14104. * Disposes the component and the associated ressources.
  14105. */
  14106. dispose(): void;
  14107. private _draw;
  14108. private _drawCameraPredicate;
  14109. private _drawCameraBackground;
  14110. private _drawCameraForeground;
  14111. private _drawRenderTargetPredicate;
  14112. private _drawRenderTargetBackground;
  14113. private _drawRenderTargetForeground;
  14114. }
  14115. }
  14116. declare module "babylonjs/Shaders/layer.fragment" {
  14117. /** @hidden */
  14118. export var layerPixelShader: {
  14119. name: string;
  14120. shader: string;
  14121. };
  14122. }
  14123. declare module "babylonjs/Shaders/layer.vertex" {
  14124. /** @hidden */
  14125. export var layerVertexShader: {
  14126. name: string;
  14127. shader: string;
  14128. };
  14129. }
  14130. declare module "babylonjs/Layers/layer" {
  14131. import { Observable } from "babylonjs/Misc/observable";
  14132. import { Nullable } from "babylonjs/types";
  14133. import { Scene } from "babylonjs/scene";
  14134. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14135. import { Texture } from "babylonjs/Materials/Textures/texture";
  14136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14137. import "babylonjs/Shaders/layer.fragment";
  14138. import "babylonjs/Shaders/layer.vertex";
  14139. /**
  14140. * This represents a full screen 2d layer.
  14141. * This can be useful to display a picture in the background of your scene for instance.
  14142. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14143. */
  14144. export class Layer {
  14145. /**
  14146. * Define the name of the layer.
  14147. */
  14148. name: string;
  14149. /**
  14150. * Define the texture the layer should display.
  14151. */
  14152. texture: Nullable<Texture>;
  14153. /**
  14154. * Is the layer in background or foreground.
  14155. */
  14156. isBackground: boolean;
  14157. /**
  14158. * Define the color of the layer (instead of texture).
  14159. */
  14160. color: Color4;
  14161. /**
  14162. * Define the scale of the layer in order to zoom in out of the texture.
  14163. */
  14164. scale: Vector2;
  14165. /**
  14166. * Define an offset for the layer in order to shift the texture.
  14167. */
  14168. offset: Vector2;
  14169. /**
  14170. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14171. */
  14172. alphaBlendingMode: number;
  14173. /**
  14174. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14175. * Alpha test will not mix with the background color in case of transparency.
  14176. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14177. */
  14178. alphaTest: boolean;
  14179. /**
  14180. * Define a mask to restrict the layer to only some of the scene cameras.
  14181. */
  14182. layerMask: number;
  14183. /**
  14184. * Define the list of render target the layer is visible into.
  14185. */
  14186. renderTargetTextures: RenderTargetTexture[];
  14187. /**
  14188. * Define if the layer is only used in renderTarget or if it also
  14189. * renders in the main frame buffer of the canvas.
  14190. */
  14191. renderOnlyInRenderTargetTextures: boolean;
  14192. private _scene;
  14193. private _vertexBuffers;
  14194. private _indexBuffer;
  14195. private _effect;
  14196. private _alphaTestEffect;
  14197. /**
  14198. * An event triggered when the layer is disposed.
  14199. */
  14200. onDisposeObservable: Observable<Layer>;
  14201. private _onDisposeObserver;
  14202. /**
  14203. * Back compatibility with callback before the onDisposeObservable existed.
  14204. * The set callback will be triggered when the layer has been disposed.
  14205. */
  14206. onDispose: () => void;
  14207. /**
  14208. * An event triggered before rendering the scene
  14209. */
  14210. onBeforeRenderObservable: Observable<Layer>;
  14211. private _onBeforeRenderObserver;
  14212. /**
  14213. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14214. * The set callback will be triggered just before rendering the layer.
  14215. */
  14216. onBeforeRender: () => void;
  14217. /**
  14218. * An event triggered after rendering the scene
  14219. */
  14220. onAfterRenderObservable: Observable<Layer>;
  14221. private _onAfterRenderObserver;
  14222. /**
  14223. * Back compatibility with callback before the onAfterRenderObservable existed.
  14224. * The set callback will be triggered just after rendering the layer.
  14225. */
  14226. onAfterRender: () => void;
  14227. /**
  14228. * Instantiates a new layer.
  14229. * This represents a full screen 2d layer.
  14230. * This can be useful to display a picture in the background of your scene for instance.
  14231. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14232. * @param name Define the name of the layer in the scene
  14233. * @param imgUrl Define the url of the texture to display in the layer
  14234. * @param scene Define the scene the layer belongs to
  14235. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14236. * @param color Defines a color for the layer
  14237. */
  14238. constructor(
  14239. /**
  14240. * Define the name of the layer.
  14241. */
  14242. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14243. private _createIndexBuffer;
  14244. /** @hidden */
  14245. _rebuild(): void;
  14246. /**
  14247. * Renders the layer in the scene.
  14248. */
  14249. render(): void;
  14250. /**
  14251. * Disposes and releases the associated ressources.
  14252. */
  14253. dispose(): void;
  14254. }
  14255. }
  14256. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14257. import { Scene } from "babylonjs/scene";
  14258. import { ISceneComponent } from "babylonjs/sceneComponent";
  14259. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14260. module "babylonjs/abstractScene" {
  14261. interface AbstractScene {
  14262. /**
  14263. * The list of procedural textures added to the scene
  14264. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14265. */
  14266. proceduralTextures: Array<ProceduralTexture>;
  14267. }
  14268. }
  14269. /**
  14270. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14271. * in a given scene.
  14272. */
  14273. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14274. /**
  14275. * The component name helpfull to identify the component in the list of scene components.
  14276. */
  14277. readonly name: string;
  14278. /**
  14279. * The scene the component belongs to.
  14280. */
  14281. scene: Scene;
  14282. /**
  14283. * Creates a new instance of the component for the given scene
  14284. * @param scene Defines the scene to register the component in
  14285. */
  14286. constructor(scene: Scene);
  14287. /**
  14288. * Registers the component in a given scene
  14289. */
  14290. register(): void;
  14291. /**
  14292. * Rebuilds the elements related to this component in case of
  14293. * context lost for instance.
  14294. */
  14295. rebuild(): void;
  14296. /**
  14297. * Disposes the component and the associated ressources.
  14298. */
  14299. dispose(): void;
  14300. private _beforeClear;
  14301. }
  14302. }
  14303. declare module "babylonjs/Shaders/procedural.vertex" {
  14304. /** @hidden */
  14305. export var proceduralVertexShader: {
  14306. name: string;
  14307. shader: string;
  14308. };
  14309. }
  14310. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14311. import { Observable } from "babylonjs/Misc/observable";
  14312. import { Nullable } from "babylonjs/types";
  14313. import { Scene } from "babylonjs/scene";
  14314. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14315. import { Effect } from "babylonjs/Materials/effect";
  14316. import { Texture } from "babylonjs/Materials/Textures/texture";
  14317. import "babylonjs/Shaders/procedural.vertex";
  14318. /**
  14319. * 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.
  14320. * This is the base class of any Procedural texture and contains most of the shareable code.
  14321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14322. */
  14323. export class ProceduralTexture extends Texture {
  14324. isCube: boolean;
  14325. /**
  14326. * Define if the texture is enabled or not (disabled texture will not render)
  14327. */
  14328. isEnabled: boolean;
  14329. /**
  14330. * Define if the texture must be cleared before rendering (default is true)
  14331. */
  14332. autoClear: boolean;
  14333. /**
  14334. * Callback called when the texture is generated
  14335. */
  14336. onGenerated: () => void;
  14337. /**
  14338. * Event raised when the texture is generated
  14339. */
  14340. onGeneratedObservable: Observable<ProceduralTexture>;
  14341. /** @hidden */
  14342. _generateMipMaps: boolean;
  14343. /** @hidden **/
  14344. _effect: Effect;
  14345. /** @hidden */
  14346. _textures: {
  14347. [key: string]: Texture;
  14348. };
  14349. private _size;
  14350. private _currentRefreshId;
  14351. private _refreshRate;
  14352. private _vertexBuffers;
  14353. private _indexBuffer;
  14354. private _uniforms;
  14355. private _samplers;
  14356. private _fragment;
  14357. private _floats;
  14358. private _ints;
  14359. private _floatsArrays;
  14360. private _colors3;
  14361. private _colors4;
  14362. private _vectors2;
  14363. private _vectors3;
  14364. private _matrices;
  14365. private _fallbackTexture;
  14366. private _fallbackTextureUsed;
  14367. private _engine;
  14368. private _cachedDefines;
  14369. private _contentUpdateId;
  14370. private _contentData;
  14371. /**
  14372. * Instantiates a new procedural texture.
  14373. * 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.
  14374. * This is the base class of any Procedural texture and contains most of the shareable code.
  14375. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14376. * @param name Define the name of the texture
  14377. * @param size Define the size of the texture to create
  14378. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14379. * @param scene Define the scene the texture belongs to
  14380. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14381. * @param generateMipMaps Define if the texture should creates mip maps or not
  14382. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14383. */
  14384. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14385. /**
  14386. * The effect that is created when initializing the post process.
  14387. * @returns The created effect corrisponding the the postprocess.
  14388. */
  14389. getEffect(): Effect;
  14390. /**
  14391. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14392. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14393. */
  14394. getContent(): Nullable<ArrayBufferView>;
  14395. private _createIndexBuffer;
  14396. /** @hidden */
  14397. _rebuild(): void;
  14398. /**
  14399. * Resets the texture in order to recreate its associated resources.
  14400. * This can be called in case of context loss
  14401. */
  14402. reset(): void;
  14403. protected _getDefines(): string;
  14404. /**
  14405. * Is the texture ready to be used ? (rendered at least once)
  14406. * @returns true if ready, otherwise, false.
  14407. */
  14408. isReady(): boolean;
  14409. /**
  14410. * Resets the refresh counter of the texture and start bak from scratch.
  14411. * Could be useful to regenerate the texture if it is setup to render only once.
  14412. */
  14413. resetRefreshCounter(): void;
  14414. /**
  14415. * Set the fragment shader to use in order to render the texture.
  14416. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14417. */
  14418. setFragment(fragment: any): void;
  14419. /**
  14420. * Define the refresh rate of the texture or the rendering frequency.
  14421. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14422. */
  14423. refreshRate: number;
  14424. /** @hidden */
  14425. _shouldRender(): boolean;
  14426. /**
  14427. * Get the size the texture is rendering at.
  14428. * @returns the size (texture is always squared)
  14429. */
  14430. getRenderSize(): number;
  14431. /**
  14432. * Resize the texture to new value.
  14433. * @param size Define the new size the texture should have
  14434. * @param generateMipMaps Define whether the new texture should create mip maps
  14435. */
  14436. resize(size: number, generateMipMaps: boolean): void;
  14437. private _checkUniform;
  14438. /**
  14439. * Set a texture in the shader program used to render.
  14440. * @param name Define the name of the uniform samplers as defined in the shader
  14441. * @param texture Define the texture to bind to this sampler
  14442. * @return the texture itself allowing "fluent" like uniform updates
  14443. */
  14444. setTexture(name: string, texture: Texture): ProceduralTexture;
  14445. /**
  14446. * Set a float in the shader.
  14447. * @param name Define the name of the uniform as defined in the shader
  14448. * @param value Define the value to give to the uniform
  14449. * @return the texture itself allowing "fluent" like uniform updates
  14450. */
  14451. setFloat(name: string, value: number): ProceduralTexture;
  14452. /**
  14453. * Set a int in the shader.
  14454. * @param name Define the name of the uniform as defined in the shader
  14455. * @param value Define the value to give to the uniform
  14456. * @return the texture itself allowing "fluent" like uniform updates
  14457. */
  14458. setInt(name: string, value: number): ProceduralTexture;
  14459. /**
  14460. * Set an array of floats in the shader.
  14461. * @param name Define the name of the uniform as defined in the shader
  14462. * @param value Define the value to give to the uniform
  14463. * @return the texture itself allowing "fluent" like uniform updates
  14464. */
  14465. setFloats(name: string, value: number[]): ProceduralTexture;
  14466. /**
  14467. * Set a vec3 in the shader from a Color3.
  14468. * @param name Define the name of the uniform as defined in the shader
  14469. * @param value Define the value to give to the uniform
  14470. * @return the texture itself allowing "fluent" like uniform updates
  14471. */
  14472. setColor3(name: string, value: Color3): ProceduralTexture;
  14473. /**
  14474. * Set a vec4 in the shader from a Color4.
  14475. * @param name Define the name of the uniform as defined in the shader
  14476. * @param value Define the value to give to the uniform
  14477. * @return the texture itself allowing "fluent" like uniform updates
  14478. */
  14479. setColor4(name: string, value: Color4): ProceduralTexture;
  14480. /**
  14481. * Set a vec2 in the shader from a Vector2.
  14482. * @param name Define the name of the uniform as defined in the shader
  14483. * @param value Define the value to give to the uniform
  14484. * @return the texture itself allowing "fluent" like uniform updates
  14485. */
  14486. setVector2(name: string, value: Vector2): ProceduralTexture;
  14487. /**
  14488. * Set a vec3 in the shader from a Vector3.
  14489. * @param name Define the name of the uniform as defined in the shader
  14490. * @param value Define the value to give to the uniform
  14491. * @return the texture itself allowing "fluent" like uniform updates
  14492. */
  14493. setVector3(name: string, value: Vector3): ProceduralTexture;
  14494. /**
  14495. * Set a mat4 in the shader from a MAtrix.
  14496. * @param name Define the name of the uniform as defined in the shader
  14497. * @param value Define the value to give to the uniform
  14498. * @return the texture itself allowing "fluent" like uniform updates
  14499. */
  14500. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14501. /**
  14502. * Render the texture to its associated render target.
  14503. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14504. */
  14505. render(useCameraPostProcess?: boolean): void;
  14506. /**
  14507. * Clone the texture.
  14508. * @returns the cloned texture
  14509. */
  14510. clone(): ProceduralTexture;
  14511. /**
  14512. * Dispose the texture and release its asoociated resources.
  14513. */
  14514. dispose(): void;
  14515. }
  14516. }
  14517. declare module "babylonjs/Particles/baseParticleSystem" {
  14518. import { Nullable } from "babylonjs/types";
  14519. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14521. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14522. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14523. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14524. import { Scene } from "babylonjs/scene";
  14525. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14526. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14527. import { Texture } from "babylonjs/Materials/Textures/texture";
  14528. import { Animation } from "babylonjs/Animations/animation";
  14529. /**
  14530. * This represents the base class for particle system in Babylon.
  14531. * 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.
  14532. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14533. * @example https://doc.babylonjs.com/babylon101/particles
  14534. */
  14535. export class BaseParticleSystem {
  14536. /**
  14537. * Source color is added to the destination color without alpha affecting the result
  14538. */
  14539. static BLENDMODE_ONEONE: number;
  14540. /**
  14541. * Blend current color and particle color using particle’s alpha
  14542. */
  14543. static BLENDMODE_STANDARD: number;
  14544. /**
  14545. * Add current color and particle color multiplied by particle’s alpha
  14546. */
  14547. static BLENDMODE_ADD: number;
  14548. /**
  14549. * Multiply current color with particle color
  14550. */
  14551. static BLENDMODE_MULTIPLY: number;
  14552. /**
  14553. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14554. */
  14555. static BLENDMODE_MULTIPLYADD: number;
  14556. /**
  14557. * List of animations used by the particle system.
  14558. */
  14559. animations: Animation[];
  14560. /**
  14561. * The id of the Particle system.
  14562. */
  14563. id: string;
  14564. /**
  14565. * The friendly name of the Particle system.
  14566. */
  14567. name: string;
  14568. /**
  14569. * The rendering group used by the Particle system to chose when to render.
  14570. */
  14571. renderingGroupId: number;
  14572. /**
  14573. * The emitter represents the Mesh or position we are attaching the particle system to.
  14574. */
  14575. emitter: Nullable<AbstractMesh | Vector3>;
  14576. /**
  14577. * The maximum number of particles to emit per frame
  14578. */
  14579. emitRate: number;
  14580. /**
  14581. * If you want to launch only a few particles at once, that can be done, as well.
  14582. */
  14583. manualEmitCount: number;
  14584. /**
  14585. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14586. */
  14587. updateSpeed: number;
  14588. /**
  14589. * The amount of time the particle system is running (depends of the overall update speed).
  14590. */
  14591. targetStopDuration: number;
  14592. /**
  14593. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14594. */
  14595. disposeOnStop: boolean;
  14596. /**
  14597. * Minimum power of emitting particles.
  14598. */
  14599. minEmitPower: number;
  14600. /**
  14601. * Maximum power of emitting particles.
  14602. */
  14603. maxEmitPower: number;
  14604. /**
  14605. * Minimum life time of emitting particles.
  14606. */
  14607. minLifeTime: number;
  14608. /**
  14609. * Maximum life time of emitting particles.
  14610. */
  14611. maxLifeTime: number;
  14612. /**
  14613. * Minimum Size of emitting particles.
  14614. */
  14615. minSize: number;
  14616. /**
  14617. * Maximum Size of emitting particles.
  14618. */
  14619. maxSize: number;
  14620. /**
  14621. * Minimum scale of emitting particles on X axis.
  14622. */
  14623. minScaleX: number;
  14624. /**
  14625. * Maximum scale of emitting particles on X axis.
  14626. */
  14627. maxScaleX: number;
  14628. /**
  14629. * Minimum scale of emitting particles on Y axis.
  14630. */
  14631. minScaleY: number;
  14632. /**
  14633. * Maximum scale of emitting particles on Y axis.
  14634. */
  14635. maxScaleY: number;
  14636. /**
  14637. * Gets or sets the minimal initial rotation in radians.
  14638. */
  14639. minInitialRotation: number;
  14640. /**
  14641. * Gets or sets the maximal initial rotation in radians.
  14642. */
  14643. maxInitialRotation: number;
  14644. /**
  14645. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14646. */
  14647. minAngularSpeed: number;
  14648. /**
  14649. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14650. */
  14651. maxAngularSpeed: number;
  14652. /**
  14653. * The texture used to render each particle. (this can be a spritesheet)
  14654. */
  14655. particleTexture: Nullable<Texture>;
  14656. /**
  14657. * The layer mask we are rendering the particles through.
  14658. */
  14659. layerMask: number;
  14660. /**
  14661. * This can help using your own shader to render the particle system.
  14662. * The according effect will be created
  14663. */
  14664. customShader: any;
  14665. /**
  14666. * By default particle system starts as soon as they are created. This prevents the
  14667. * automatic start to happen and let you decide when to start emitting particles.
  14668. */
  14669. preventAutoStart: boolean;
  14670. private _noiseTexture;
  14671. /**
  14672. * Gets or sets a texture used to add random noise to particle positions
  14673. */
  14674. noiseTexture: Nullable<ProceduralTexture>;
  14675. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14676. noiseStrength: Vector3;
  14677. /**
  14678. * Callback triggered when the particle animation is ending.
  14679. */
  14680. onAnimationEnd: Nullable<() => void>;
  14681. /**
  14682. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14683. */
  14684. blendMode: number;
  14685. /**
  14686. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14687. * to override the particles.
  14688. */
  14689. forceDepthWrite: boolean;
  14690. /** 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 */
  14691. preWarmCycles: number;
  14692. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14693. preWarmStepOffset: number;
  14694. /**
  14695. * 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)
  14696. */
  14697. spriteCellChangeSpeed: number;
  14698. /**
  14699. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14700. */
  14701. startSpriteCellID: number;
  14702. /**
  14703. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14704. */
  14705. endSpriteCellID: number;
  14706. /**
  14707. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14708. */
  14709. spriteCellWidth: number;
  14710. /**
  14711. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14712. */
  14713. spriteCellHeight: number;
  14714. /**
  14715. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14716. */
  14717. spriteRandomStartCell: boolean;
  14718. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14719. translationPivot: Vector2;
  14720. /** @hidden */
  14721. protected _isAnimationSheetEnabled: boolean;
  14722. /**
  14723. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14724. */
  14725. beginAnimationOnStart: boolean;
  14726. /**
  14727. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14728. */
  14729. beginAnimationFrom: number;
  14730. /**
  14731. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14732. */
  14733. beginAnimationTo: number;
  14734. /**
  14735. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14736. */
  14737. beginAnimationLoop: boolean;
  14738. /**
  14739. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14740. */
  14741. isAnimationSheetEnabled: boolean;
  14742. /**
  14743. * Get hosting scene
  14744. * @returns the scene
  14745. */
  14746. getScene(): Scene;
  14747. /**
  14748. * You can use gravity if you want to give an orientation to your particles.
  14749. */
  14750. gravity: Vector3;
  14751. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14752. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14753. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14754. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14755. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14756. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14757. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14758. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14759. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14760. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14761. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14762. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14763. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14764. /**
  14765. * Defines the delay in milliseconds before starting the system (0 by default)
  14766. */
  14767. startDelay: number;
  14768. /**
  14769. * Gets the current list of drag gradients.
  14770. * You must use addDragGradient and removeDragGradient to udpate this list
  14771. * @returns the list of drag gradients
  14772. */
  14773. getDragGradients(): Nullable<Array<FactorGradient>>;
  14774. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14775. limitVelocityDamping: number;
  14776. /**
  14777. * Gets the current list of limit velocity gradients.
  14778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14779. * @returns the list of limit velocity gradients
  14780. */
  14781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14782. /**
  14783. * Gets the current list of color gradients.
  14784. * You must use addColorGradient and removeColorGradient to udpate this list
  14785. * @returns the list of color gradients
  14786. */
  14787. getColorGradients(): Nullable<Array<ColorGradient>>;
  14788. /**
  14789. * Gets the current list of size gradients.
  14790. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14791. * @returns the list of size gradients
  14792. */
  14793. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14794. /**
  14795. * Gets the current list of color remap gradients.
  14796. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14797. * @returns the list of color remap gradients
  14798. */
  14799. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14800. /**
  14801. * Gets the current list of alpha remap gradients.
  14802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14803. * @returns the list of alpha remap gradients
  14804. */
  14805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14806. /**
  14807. * Gets the current list of life time gradients.
  14808. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14809. * @returns the list of life time gradients
  14810. */
  14811. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14812. /**
  14813. * Gets the current list of angular speed gradients.
  14814. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14815. * @returns the list of angular speed gradients
  14816. */
  14817. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14818. /**
  14819. * Gets the current list of velocity gradients.
  14820. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14821. * @returns the list of velocity gradients
  14822. */
  14823. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14824. /**
  14825. * Gets the current list of start size gradients.
  14826. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14827. * @returns the list of start size gradients
  14828. */
  14829. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14830. /**
  14831. * Gets the current list of emit rate gradients.
  14832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14833. * @returns the list of emit rate gradients
  14834. */
  14835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14836. /**
  14837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14838. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14839. */
  14840. direction1: Vector3;
  14841. /**
  14842. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14843. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14844. */
  14845. direction2: Vector3;
  14846. /**
  14847. * 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.
  14848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14849. */
  14850. minEmitBox: Vector3;
  14851. /**
  14852. * 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.
  14853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14854. */
  14855. maxEmitBox: Vector3;
  14856. /**
  14857. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14858. */
  14859. color1: Color4;
  14860. /**
  14861. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14862. */
  14863. color2: Color4;
  14864. /**
  14865. * Color the particle will have at the end of its lifetime
  14866. */
  14867. colorDead: Color4;
  14868. /**
  14869. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14870. */
  14871. textureMask: Color4;
  14872. /**
  14873. * The particle emitter type defines the emitter used by the particle system.
  14874. * It can be for example box, sphere, or cone...
  14875. */
  14876. particleEmitterType: IParticleEmitterType;
  14877. /** @hidden */
  14878. _isSubEmitter: boolean;
  14879. /**
  14880. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14881. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14882. */
  14883. billboardMode: number;
  14884. protected _isBillboardBased: boolean;
  14885. /**
  14886. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14887. */
  14888. isBillboardBased: boolean;
  14889. /**
  14890. * The scene the particle system belongs to.
  14891. */
  14892. protected _scene: Scene;
  14893. /**
  14894. * Local cache of defines for image processing.
  14895. */
  14896. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14897. /**
  14898. * Default configuration related to image processing available in the standard Material.
  14899. */
  14900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14901. /**
  14902. * Gets the image processing configuration used either in this material.
  14903. */
  14904. /**
  14905. * Sets the Default image processing configuration used either in the this material.
  14906. *
  14907. * If sets to null, the scene one is in use.
  14908. */
  14909. imageProcessingConfiguration: ImageProcessingConfiguration;
  14910. /**
  14911. * Attaches a new image processing configuration to the Standard Material.
  14912. * @param configuration
  14913. */
  14914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14915. /** @hidden */
  14916. protected _reset(): void;
  14917. /** @hidden */
  14918. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14919. /**
  14920. * Instantiates a particle system.
  14921. * 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.
  14922. * @param name The name of the particle system
  14923. */
  14924. constructor(name: string);
  14925. /**
  14926. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14927. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14928. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14929. * @returns the emitter
  14930. */
  14931. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14932. /**
  14933. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14934. * @param radius The radius of the hemisphere to emit from
  14935. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14936. * @returns the emitter
  14937. */
  14938. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14939. /**
  14940. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14941. * @param radius The radius of the sphere to emit from
  14942. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14943. * @returns the emitter
  14944. */
  14945. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14946. /**
  14947. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14948. * @param radius The radius of the sphere to emit from
  14949. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14950. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14951. * @returns the emitter
  14952. */
  14953. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14954. /**
  14955. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14956. * @param radius The radius of the emission cylinder
  14957. * @param height The height of the emission cylinder
  14958. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14959. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14960. * @returns the emitter
  14961. */
  14962. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14963. /**
  14964. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14965. * @param radius The radius of the cylinder to emit from
  14966. * @param height The height of the emission cylinder
  14967. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14970. * @returns the emitter
  14971. */
  14972. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14973. /**
  14974. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14975. * @param radius The radius of the cone to emit from
  14976. * @param angle The base angle of the cone
  14977. * @returns the emitter
  14978. */
  14979. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14980. /**
  14981. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14984. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14985. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14986. * @returns the emitter
  14987. */
  14988. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14989. }
  14990. }
  14991. declare module "babylonjs/Particles/subEmitter" {
  14992. import { Scene } from "babylonjs/scene";
  14993. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14994. /**
  14995. * Type of sub emitter
  14996. */
  14997. export enum SubEmitterType {
  14998. /**
  14999. * Attached to the particle over it's lifetime
  15000. */
  15001. ATTACHED = 0,
  15002. /**
  15003. * Created when the particle dies
  15004. */
  15005. END = 1
  15006. }
  15007. /**
  15008. * Sub emitter class used to emit particles from an existing particle
  15009. */
  15010. export class SubEmitter {
  15011. /**
  15012. * the particle system to be used by the sub emitter
  15013. */
  15014. particleSystem: ParticleSystem;
  15015. /**
  15016. * Type of the submitter (Default: END)
  15017. */
  15018. type: SubEmitterType;
  15019. /**
  15020. * 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)
  15021. * Note: This only is supported when using an emitter of type Mesh
  15022. */
  15023. inheritDirection: boolean;
  15024. /**
  15025. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15026. */
  15027. inheritedVelocityAmount: number;
  15028. /**
  15029. * Creates a sub emitter
  15030. * @param particleSystem the particle system to be used by the sub emitter
  15031. */
  15032. constructor(
  15033. /**
  15034. * the particle system to be used by the sub emitter
  15035. */
  15036. particleSystem: ParticleSystem);
  15037. /**
  15038. * Clones the sub emitter
  15039. * @returns the cloned sub emitter
  15040. */
  15041. clone(): SubEmitter;
  15042. /**
  15043. * Serialize current object to a JSON object
  15044. * @returns the serialized object
  15045. */
  15046. serialize(): any;
  15047. /** @hidden */
  15048. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15049. /**
  15050. * Creates a new SubEmitter from a serialized JSON version
  15051. * @param serializationObject defines the JSON object to read from
  15052. * @param scene defines the hosting scene
  15053. * @param rootUrl defines the rootUrl for data loading
  15054. * @returns a new SubEmitter
  15055. */
  15056. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15057. /** Release associated resources */
  15058. dispose(): void;
  15059. }
  15060. }
  15061. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15062. /** @hidden */
  15063. export var clipPlaneFragmentDeclaration: {
  15064. name: string;
  15065. shader: string;
  15066. };
  15067. }
  15068. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15069. /** @hidden */
  15070. export var imageProcessingDeclaration: {
  15071. name: string;
  15072. shader: string;
  15073. };
  15074. }
  15075. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15076. /** @hidden */
  15077. export var imageProcessingFunctions: {
  15078. name: string;
  15079. shader: string;
  15080. };
  15081. }
  15082. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15083. /** @hidden */
  15084. export var clipPlaneFragment: {
  15085. name: string;
  15086. shader: string;
  15087. };
  15088. }
  15089. declare module "babylonjs/Shaders/particles.fragment" {
  15090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15091. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15093. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15094. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15095. /** @hidden */
  15096. export var particlesPixelShader: {
  15097. name: string;
  15098. shader: string;
  15099. };
  15100. }
  15101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15102. /** @hidden */
  15103. export var clipPlaneVertexDeclaration: {
  15104. name: string;
  15105. shader: string;
  15106. };
  15107. }
  15108. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15109. /** @hidden */
  15110. export var clipPlaneVertex: {
  15111. name: string;
  15112. shader: string;
  15113. };
  15114. }
  15115. declare module "babylonjs/Shaders/particles.vertex" {
  15116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15117. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15118. /** @hidden */
  15119. export var particlesVertexShader: {
  15120. name: string;
  15121. shader: string;
  15122. };
  15123. }
  15124. declare module "babylonjs/Particles/particleSystem" {
  15125. import { Nullable } from "babylonjs/types";
  15126. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15127. import { Observable } from "babylonjs/Misc/observable";
  15128. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15129. import { Effect } from "babylonjs/Materials/effect";
  15130. import { Scene, IDisposable } from "babylonjs/scene";
  15131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15132. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15133. import { Particle } from "babylonjs/Particles/particle";
  15134. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15135. import "babylonjs/Shaders/particles.fragment";
  15136. import "babylonjs/Shaders/particles.vertex";
  15137. /**
  15138. * This represents a particle system in Babylon.
  15139. * 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.
  15140. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15141. * @example https://doc.babylonjs.com/babylon101/particles
  15142. */
  15143. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15144. /**
  15145. * Billboard mode will only apply to Y axis
  15146. */
  15147. static readonly BILLBOARDMODE_Y: number;
  15148. /**
  15149. * Billboard mode will apply to all axes
  15150. */
  15151. static readonly BILLBOARDMODE_ALL: number;
  15152. /**
  15153. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15154. */
  15155. static readonly BILLBOARDMODE_STRETCHED: number;
  15156. /**
  15157. * This function can be defined to provide custom update for active particles.
  15158. * This function will be called instead of regular update (age, position, color, etc.).
  15159. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15160. */
  15161. updateFunction: (particles: Particle[]) => void;
  15162. private _emitterWorldMatrix;
  15163. /**
  15164. * This function can be defined to specify initial direction for every new particle.
  15165. * It by default use the emitterType defined function
  15166. */
  15167. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15168. /**
  15169. * This function can be defined to specify initial position for every new particle.
  15170. * It by default use the emitterType defined function
  15171. */
  15172. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15173. /**
  15174. * @hidden
  15175. */
  15176. _inheritedVelocityOffset: Vector3;
  15177. /**
  15178. * An event triggered when the system is disposed
  15179. */
  15180. onDisposeObservable: Observable<ParticleSystem>;
  15181. private _onDisposeObserver;
  15182. /**
  15183. * Sets a callback that will be triggered when the system is disposed
  15184. */
  15185. onDispose: () => void;
  15186. private _particles;
  15187. private _epsilon;
  15188. private _capacity;
  15189. private _stockParticles;
  15190. private _newPartsExcess;
  15191. private _vertexData;
  15192. private _vertexBuffer;
  15193. private _vertexBuffers;
  15194. private _spriteBuffer;
  15195. private _indexBuffer;
  15196. private _effect;
  15197. private _customEffect;
  15198. private _cachedDefines;
  15199. private _scaledColorStep;
  15200. private _colorDiff;
  15201. private _scaledDirection;
  15202. private _scaledGravity;
  15203. private _currentRenderId;
  15204. private _alive;
  15205. private _useInstancing;
  15206. private _started;
  15207. private _stopped;
  15208. private _actualFrame;
  15209. private _scaledUpdateSpeed;
  15210. private _vertexBufferSize;
  15211. /** @hidden */
  15212. _currentEmitRateGradient: Nullable<FactorGradient>;
  15213. /** @hidden */
  15214. _currentEmitRate1: number;
  15215. /** @hidden */
  15216. _currentEmitRate2: number;
  15217. /** @hidden */
  15218. _currentStartSizeGradient: Nullable<FactorGradient>;
  15219. /** @hidden */
  15220. _currentStartSize1: number;
  15221. /** @hidden */
  15222. _currentStartSize2: number;
  15223. private readonly _rawTextureWidth;
  15224. private _rampGradientsTexture;
  15225. private _useRampGradients;
  15226. /** Gets or sets a boolean indicating that ramp gradients must be used
  15227. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15228. */
  15229. useRampGradients: boolean;
  15230. /**
  15231. * 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.
  15232. * 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: [])
  15233. */
  15234. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15235. private _subEmitters;
  15236. /**
  15237. * @hidden
  15238. * If the particle systems emitter should be disposed when the particle system is disposed
  15239. */
  15240. _disposeEmitterOnDispose: boolean;
  15241. /**
  15242. * The current active Sub-systems, this property is used by the root particle system only.
  15243. */
  15244. activeSubSystems: Array<ParticleSystem>;
  15245. private _rootParticleSystem;
  15246. /**
  15247. * Gets the current list of active particles
  15248. */
  15249. readonly particles: Particle[];
  15250. /**
  15251. * Returns the string "ParticleSystem"
  15252. * @returns a string containing the class name
  15253. */
  15254. getClassName(): string;
  15255. /**
  15256. * Instantiates a particle system.
  15257. * 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.
  15258. * @param name The name of the particle system
  15259. * @param capacity The max number of particles alive at the same time
  15260. * @param scene The scene the particle system belongs to
  15261. * @param customEffect a custom effect used to change the way particles are rendered by default
  15262. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15263. * @param epsilon Offset used to render the particles
  15264. */
  15265. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15266. private _addFactorGradient;
  15267. private _removeFactorGradient;
  15268. /**
  15269. * Adds a new life time gradient
  15270. * @param gradient defines the gradient to use (between 0 and 1)
  15271. * @param factor defines the life time factor to affect to the specified gradient
  15272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15273. * @returns the current particle system
  15274. */
  15275. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15276. /**
  15277. * Remove a specific life time gradient
  15278. * @param gradient defines the gradient to remove
  15279. * @returns the current particle system
  15280. */
  15281. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15282. /**
  15283. * Adds a new size gradient
  15284. * @param gradient defines the gradient to use (between 0 and 1)
  15285. * @param factor defines the size factor to affect to the specified gradient
  15286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15287. * @returns the current particle system
  15288. */
  15289. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15290. /**
  15291. * Remove a specific size gradient
  15292. * @param gradient defines the gradient to remove
  15293. * @returns the current particle system
  15294. */
  15295. removeSizeGradient(gradient: number): IParticleSystem;
  15296. /**
  15297. * Adds a new color remap gradient
  15298. * @param gradient defines the gradient to use (between 0 and 1)
  15299. * @param min defines the color remap minimal range
  15300. * @param max defines the color remap maximal range
  15301. * @returns the current particle system
  15302. */
  15303. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15304. /**
  15305. * Remove a specific color remap gradient
  15306. * @param gradient defines the gradient to remove
  15307. * @returns the current particle system
  15308. */
  15309. removeColorRemapGradient(gradient: number): IParticleSystem;
  15310. /**
  15311. * Adds a new alpha remap gradient
  15312. * @param gradient defines the gradient to use (between 0 and 1)
  15313. * @param min defines the alpha remap minimal range
  15314. * @param max defines the alpha remap maximal range
  15315. * @returns the current particle system
  15316. */
  15317. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15318. /**
  15319. * Remove a specific alpha remap gradient
  15320. * @param gradient defines the gradient to remove
  15321. * @returns the current particle system
  15322. */
  15323. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15324. /**
  15325. * Adds a new angular speed gradient
  15326. * @param gradient defines the gradient to use (between 0 and 1)
  15327. * @param factor defines the angular speed to affect to the specified gradient
  15328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15329. * @returns the current particle system
  15330. */
  15331. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15332. /**
  15333. * Remove a specific angular speed gradient
  15334. * @param gradient defines the gradient to remove
  15335. * @returns the current particle system
  15336. */
  15337. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15338. /**
  15339. * Adds a new velocity gradient
  15340. * @param gradient defines the gradient to use (between 0 and 1)
  15341. * @param factor defines the velocity to affect to the specified gradient
  15342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15343. * @returns the current particle system
  15344. */
  15345. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15346. /**
  15347. * Remove a specific velocity gradient
  15348. * @param gradient defines the gradient to remove
  15349. * @returns the current particle system
  15350. */
  15351. removeVelocityGradient(gradient: number): IParticleSystem;
  15352. /**
  15353. * Adds a new limit velocity gradient
  15354. * @param gradient defines the gradient to use (between 0 and 1)
  15355. * @param factor defines the limit velocity value to affect to the specified gradient
  15356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15357. * @returns the current particle system
  15358. */
  15359. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15360. /**
  15361. * Remove a specific limit velocity gradient
  15362. * @param gradient defines the gradient to remove
  15363. * @returns the current particle system
  15364. */
  15365. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15366. /**
  15367. * Adds a new drag gradient
  15368. * @param gradient defines the gradient to use (between 0 and 1)
  15369. * @param factor defines the drag value to affect to the specified gradient
  15370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15371. * @returns the current particle system
  15372. */
  15373. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15374. /**
  15375. * Remove a specific drag gradient
  15376. * @param gradient defines the gradient to remove
  15377. * @returns the current particle system
  15378. */
  15379. removeDragGradient(gradient: number): IParticleSystem;
  15380. /**
  15381. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15382. * @param gradient defines the gradient to use (between 0 and 1)
  15383. * @param factor defines the emit rate value to affect to the specified gradient
  15384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15385. * @returns the current particle system
  15386. */
  15387. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15388. /**
  15389. * Remove a specific emit rate gradient
  15390. * @param gradient defines the gradient to remove
  15391. * @returns the current particle system
  15392. */
  15393. removeEmitRateGradient(gradient: number): IParticleSystem;
  15394. /**
  15395. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15396. * @param gradient defines the gradient to use (between 0 and 1)
  15397. * @param factor defines the start size value to affect to the specified gradient
  15398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15399. * @returns the current particle system
  15400. */
  15401. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15402. /**
  15403. * Remove a specific start size gradient
  15404. * @param gradient defines the gradient to remove
  15405. * @returns the current particle system
  15406. */
  15407. removeStartSizeGradient(gradient: number): IParticleSystem;
  15408. private _createRampGradientTexture;
  15409. /**
  15410. * Gets the current list of ramp gradients.
  15411. * You must use addRampGradient and removeRampGradient to udpate this list
  15412. * @returns the list of ramp gradients
  15413. */
  15414. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15415. /**
  15416. * Adds a new ramp gradient used to remap particle colors
  15417. * @param gradient defines the gradient to use (between 0 and 1)
  15418. * @param color defines the color to affect to the specified gradient
  15419. * @returns the current particle system
  15420. */
  15421. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15422. /**
  15423. * Remove a specific ramp gradient
  15424. * @param gradient defines the gradient to remove
  15425. * @returns the current particle system
  15426. */
  15427. removeRampGradient(gradient: number): ParticleSystem;
  15428. /**
  15429. * Adds a new color gradient
  15430. * @param gradient defines the gradient to use (between 0 and 1)
  15431. * @param color1 defines the color to affect to the specified gradient
  15432. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15433. * @returns this particle system
  15434. */
  15435. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15436. /**
  15437. * Remove a specific color gradient
  15438. * @param gradient defines the gradient to remove
  15439. * @returns this particle system
  15440. */
  15441. removeColorGradient(gradient: number): IParticleSystem;
  15442. private _fetchR;
  15443. protected _reset(): void;
  15444. private _resetEffect;
  15445. private _createVertexBuffers;
  15446. private _createIndexBuffer;
  15447. /**
  15448. * Gets the maximum number of particles active at the same time.
  15449. * @returns The max number of active particles.
  15450. */
  15451. getCapacity(): number;
  15452. /**
  15453. * Gets whether there are still active particles in the system.
  15454. * @returns True if it is alive, otherwise false.
  15455. */
  15456. isAlive(): boolean;
  15457. /**
  15458. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15459. * @returns True if it has been started, otherwise false.
  15460. */
  15461. isStarted(): boolean;
  15462. private _prepareSubEmitterInternalArray;
  15463. /**
  15464. * Starts the particle system and begins to emit
  15465. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15466. */
  15467. start(delay?: number): void;
  15468. /**
  15469. * Stops the particle system.
  15470. * @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.
  15471. */
  15472. stop(stopSubEmitters?: boolean): void;
  15473. /**
  15474. * Remove all active particles
  15475. */
  15476. reset(): void;
  15477. /**
  15478. * @hidden (for internal use only)
  15479. */
  15480. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15481. /**
  15482. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15483. * Its lifetime will start back at 0.
  15484. */
  15485. recycleParticle: (particle: Particle) => void;
  15486. private _stopSubEmitters;
  15487. private _createParticle;
  15488. private _removeFromRoot;
  15489. private _emitFromParticle;
  15490. private _update;
  15491. /** @hidden */
  15492. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15493. /** @hidden */
  15494. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15495. /** @hidden */
  15496. private _getEffect;
  15497. /**
  15498. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15499. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15500. */
  15501. animate(preWarmOnly?: boolean): void;
  15502. private _appendParticleVertices;
  15503. /**
  15504. * Rebuilds the particle system.
  15505. */
  15506. rebuild(): void;
  15507. /**
  15508. * Is this system ready to be used/rendered
  15509. * @return true if the system is ready
  15510. */
  15511. isReady(): boolean;
  15512. private _render;
  15513. /**
  15514. * Renders the particle system in its current state.
  15515. * @returns the current number of particles
  15516. */
  15517. render(): number;
  15518. /**
  15519. * Disposes the particle system and free the associated resources
  15520. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15521. */
  15522. dispose(disposeTexture?: boolean): void;
  15523. /**
  15524. * Clones the particle system.
  15525. * @param name The name of the cloned object
  15526. * @param newEmitter The new emitter to use
  15527. * @returns the cloned particle system
  15528. */
  15529. clone(name: string, newEmitter: any): ParticleSystem;
  15530. /**
  15531. * Serializes the particle system to a JSON object.
  15532. * @returns the JSON object
  15533. */
  15534. serialize(): any;
  15535. /** @hidden */
  15536. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15537. /** @hidden */
  15538. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15539. /**
  15540. * Parses a JSON object to create a particle system.
  15541. * @param parsedParticleSystem The JSON object to parse
  15542. * @param scene The scene to create the particle system in
  15543. * @param rootUrl The root url to use to load external dependencies like texture
  15544. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15545. * @returns the Parsed particle system
  15546. */
  15547. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15548. }
  15549. }
  15550. declare module "babylonjs/Particles/particle" {
  15551. import { Nullable } from "babylonjs/types";
  15552. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15553. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15554. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15555. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15556. /**
  15557. * A particle represents one of the element emitted by a particle system.
  15558. * This is mainly define by its coordinates, direction, velocity and age.
  15559. */
  15560. export class Particle {
  15561. /**
  15562. * The particle system the particle belongs to.
  15563. */
  15564. particleSystem: ParticleSystem;
  15565. private static _Count;
  15566. /**
  15567. * Unique ID of the particle
  15568. */
  15569. id: number;
  15570. /**
  15571. * The world position of the particle in the scene.
  15572. */
  15573. position: Vector3;
  15574. /**
  15575. * The world direction of the particle in the scene.
  15576. */
  15577. direction: Vector3;
  15578. /**
  15579. * The color of the particle.
  15580. */
  15581. color: Color4;
  15582. /**
  15583. * The color change of the particle per step.
  15584. */
  15585. colorStep: Color4;
  15586. /**
  15587. * Defines how long will the life of the particle be.
  15588. */
  15589. lifeTime: number;
  15590. /**
  15591. * The current age of the particle.
  15592. */
  15593. age: number;
  15594. /**
  15595. * The current size of the particle.
  15596. */
  15597. size: number;
  15598. /**
  15599. * The current scale of the particle.
  15600. */
  15601. scale: Vector2;
  15602. /**
  15603. * The current angle of the particle.
  15604. */
  15605. angle: number;
  15606. /**
  15607. * Defines how fast is the angle changing.
  15608. */
  15609. angularSpeed: number;
  15610. /**
  15611. * Defines the cell index used by the particle to be rendered from a sprite.
  15612. */
  15613. cellIndex: number;
  15614. /**
  15615. * The information required to support color remapping
  15616. */
  15617. remapData: Vector4;
  15618. /** @hidden */
  15619. _randomCellOffset?: number;
  15620. /** @hidden */
  15621. _initialDirection: Nullable<Vector3>;
  15622. /** @hidden */
  15623. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15624. /** @hidden */
  15625. _initialStartSpriteCellID: number;
  15626. /** @hidden */
  15627. _initialEndSpriteCellID: number;
  15628. /** @hidden */
  15629. _currentColorGradient: Nullable<ColorGradient>;
  15630. /** @hidden */
  15631. _currentColor1: Color4;
  15632. /** @hidden */
  15633. _currentColor2: Color4;
  15634. /** @hidden */
  15635. _currentSizeGradient: Nullable<FactorGradient>;
  15636. /** @hidden */
  15637. _currentSize1: number;
  15638. /** @hidden */
  15639. _currentSize2: number;
  15640. /** @hidden */
  15641. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15642. /** @hidden */
  15643. _currentAngularSpeed1: number;
  15644. /** @hidden */
  15645. _currentAngularSpeed2: number;
  15646. /** @hidden */
  15647. _currentVelocityGradient: Nullable<FactorGradient>;
  15648. /** @hidden */
  15649. _currentVelocity1: number;
  15650. /** @hidden */
  15651. _currentVelocity2: number;
  15652. /** @hidden */
  15653. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15654. /** @hidden */
  15655. _currentLimitVelocity1: number;
  15656. /** @hidden */
  15657. _currentLimitVelocity2: number;
  15658. /** @hidden */
  15659. _currentDragGradient: Nullable<FactorGradient>;
  15660. /** @hidden */
  15661. _currentDrag1: number;
  15662. /** @hidden */
  15663. _currentDrag2: number;
  15664. /** @hidden */
  15665. _randomNoiseCoordinates1: Vector3;
  15666. /** @hidden */
  15667. _randomNoiseCoordinates2: Vector3;
  15668. /**
  15669. * Creates a new instance Particle
  15670. * @param particleSystem the particle system the particle belongs to
  15671. */
  15672. constructor(
  15673. /**
  15674. * The particle system the particle belongs to.
  15675. */
  15676. particleSystem: ParticleSystem);
  15677. private updateCellInfoFromSystem;
  15678. /**
  15679. * Defines how the sprite cell index is updated for the particle
  15680. */
  15681. updateCellIndex(): void;
  15682. /** @hidden */
  15683. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15684. /** @hidden */
  15685. _inheritParticleInfoToSubEmitters(): void;
  15686. /** @hidden */
  15687. _reset(): void;
  15688. /**
  15689. * Copy the properties of particle to another one.
  15690. * @param other the particle to copy the information to.
  15691. */
  15692. copyTo(other: Particle): void;
  15693. }
  15694. }
  15695. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15696. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15697. import { Effect } from "babylonjs/Materials/effect";
  15698. import { Particle } from "babylonjs/Particles/particle";
  15699. /**
  15700. * Particle emitter represents a volume emitting particles.
  15701. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15702. */
  15703. export interface IParticleEmitterType {
  15704. /**
  15705. * Called by the particle System when the direction is computed for the created particle.
  15706. * @param worldMatrix is the world matrix of the particle system
  15707. * @param directionToUpdate is the direction vector to update with the result
  15708. * @param particle is the particle we are computed the direction for
  15709. */
  15710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15711. /**
  15712. * Called by the particle System when the position is computed for the created particle.
  15713. * @param worldMatrix is the world matrix of the particle system
  15714. * @param positionToUpdate is the position vector to update with the result
  15715. * @param particle is the particle we are computed the position for
  15716. */
  15717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15718. /**
  15719. * Clones the current emitter and returns a copy of it
  15720. * @returns the new emitter
  15721. */
  15722. clone(): IParticleEmitterType;
  15723. /**
  15724. * Called by the GPUParticleSystem to setup the update shader
  15725. * @param effect defines the update shader
  15726. */
  15727. applyToShader(effect: Effect): void;
  15728. /**
  15729. * Returns a string to use to update the GPU particles update shader
  15730. * @returns the effect defines string
  15731. */
  15732. getEffectDefines(): string;
  15733. /**
  15734. * Returns a string representing the class name
  15735. * @returns a string containing the class name
  15736. */
  15737. getClassName(): string;
  15738. /**
  15739. * Serializes the particle system to a JSON object.
  15740. * @returns the JSON object
  15741. */
  15742. serialize(): any;
  15743. /**
  15744. * Parse properties from a JSON object
  15745. * @param serializationObject defines the JSON object
  15746. */
  15747. parse(serializationObject: any): void;
  15748. }
  15749. }
  15750. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15751. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15752. import { Effect } from "babylonjs/Materials/effect";
  15753. import { Particle } from "babylonjs/Particles/particle";
  15754. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15755. /**
  15756. * Particle emitter emitting particles from the inside of a box.
  15757. * It emits the particles randomly between 2 given directions.
  15758. */
  15759. export class BoxParticleEmitter implements IParticleEmitterType {
  15760. /**
  15761. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15762. */
  15763. direction1: Vector3;
  15764. /**
  15765. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15766. */
  15767. direction2: Vector3;
  15768. /**
  15769. * 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.
  15770. */
  15771. minEmitBox: Vector3;
  15772. /**
  15773. * 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.
  15774. */
  15775. maxEmitBox: Vector3;
  15776. /**
  15777. * Creates a new instance BoxParticleEmitter
  15778. */
  15779. constructor();
  15780. /**
  15781. * Called by the particle System when the direction is computed for the created particle.
  15782. * @param worldMatrix is the world matrix of the particle system
  15783. * @param directionToUpdate is the direction vector to update with the result
  15784. * @param particle is the particle we are computed the direction for
  15785. */
  15786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15787. /**
  15788. * Called by the particle System when the position is computed for the created particle.
  15789. * @param worldMatrix is the world matrix of the particle system
  15790. * @param positionToUpdate is the position vector to update with the result
  15791. * @param particle is the particle we are computed the position for
  15792. */
  15793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15794. /**
  15795. * Clones the current emitter and returns a copy of it
  15796. * @returns the new emitter
  15797. */
  15798. clone(): BoxParticleEmitter;
  15799. /**
  15800. * Called by the GPUParticleSystem to setup the update shader
  15801. * @param effect defines the update shader
  15802. */
  15803. applyToShader(effect: Effect): void;
  15804. /**
  15805. * Returns a string to use to update the GPU particles update shader
  15806. * @returns a string containng the defines string
  15807. */
  15808. getEffectDefines(): string;
  15809. /**
  15810. * Returns the string "BoxParticleEmitter"
  15811. * @returns a string containing the class name
  15812. */
  15813. getClassName(): string;
  15814. /**
  15815. * Serializes the particle system to a JSON object.
  15816. * @returns the JSON object
  15817. */
  15818. serialize(): any;
  15819. /**
  15820. * Parse properties from a JSON object
  15821. * @param serializationObject defines the JSON object
  15822. */
  15823. parse(serializationObject: any): void;
  15824. }
  15825. }
  15826. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15827. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15828. import { Effect } from "babylonjs/Materials/effect";
  15829. import { Particle } from "babylonjs/Particles/particle";
  15830. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15831. /**
  15832. * Particle emitter emitting particles from the inside of a cone.
  15833. * It emits the particles alongside the cone volume from the base to the particle.
  15834. * The emission direction might be randomized.
  15835. */
  15836. export class ConeParticleEmitter implements IParticleEmitterType {
  15837. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15838. directionRandomizer: number;
  15839. private _radius;
  15840. private _angle;
  15841. private _height;
  15842. /**
  15843. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15844. */
  15845. radiusRange: number;
  15846. /**
  15847. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15848. */
  15849. heightRange: number;
  15850. /**
  15851. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15852. */
  15853. emitFromSpawnPointOnly: boolean;
  15854. /**
  15855. * Gets or sets the radius of the emission cone
  15856. */
  15857. radius: number;
  15858. /**
  15859. * Gets or sets the angle of the emission cone
  15860. */
  15861. angle: number;
  15862. private _buildHeight;
  15863. /**
  15864. * Creates a new instance ConeParticleEmitter
  15865. * @param radius the radius of the emission cone (1 by default)
  15866. * @param angle the cone base angle (PI by default)
  15867. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15868. */
  15869. constructor(radius?: number, angle?: number,
  15870. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15871. directionRandomizer?: number);
  15872. /**
  15873. * Called by the particle System when the direction is computed for the created particle.
  15874. * @param worldMatrix is the world matrix of the particle system
  15875. * @param directionToUpdate is the direction vector to update with the result
  15876. * @param particle is the particle we are computed the direction for
  15877. */
  15878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15879. /**
  15880. * Called by the particle System when the position is computed for the created particle.
  15881. * @param worldMatrix is the world matrix of the particle system
  15882. * @param positionToUpdate is the position vector to update with the result
  15883. * @param particle is the particle we are computed the position for
  15884. */
  15885. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15886. /**
  15887. * Clones the current emitter and returns a copy of it
  15888. * @returns the new emitter
  15889. */
  15890. clone(): ConeParticleEmitter;
  15891. /**
  15892. * Called by the GPUParticleSystem to setup the update shader
  15893. * @param effect defines the update shader
  15894. */
  15895. applyToShader(effect: Effect): void;
  15896. /**
  15897. * Returns a string to use to update the GPU particles update shader
  15898. * @returns a string containng the defines string
  15899. */
  15900. getEffectDefines(): string;
  15901. /**
  15902. * Returns the string "ConeParticleEmitter"
  15903. * @returns a string containing the class name
  15904. */
  15905. getClassName(): string;
  15906. /**
  15907. * Serializes the particle system to a JSON object.
  15908. * @returns the JSON object
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Parse properties from a JSON object
  15913. * @param serializationObject defines the JSON object
  15914. */
  15915. parse(serializationObject: any): void;
  15916. }
  15917. }
  15918. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15919. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15920. import { Effect } from "babylonjs/Materials/effect";
  15921. import { Particle } from "babylonjs/Particles/particle";
  15922. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15923. /**
  15924. * Particle emitter emitting particles from the inside of a cylinder.
  15925. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15926. */
  15927. export class CylinderParticleEmitter implements IParticleEmitterType {
  15928. /**
  15929. * The radius of the emission cylinder.
  15930. */
  15931. radius: number;
  15932. /**
  15933. * The height of the emission cylinder.
  15934. */
  15935. height: number;
  15936. /**
  15937. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15938. */
  15939. radiusRange: number;
  15940. /**
  15941. * How much to randomize the particle direction [0-1].
  15942. */
  15943. directionRandomizer: number;
  15944. /**
  15945. * Creates a new instance CylinderParticleEmitter
  15946. * @param radius the radius of the emission cylinder (1 by default)
  15947. * @param height the height of the emission cylinder (1 by default)
  15948. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15949. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15950. */
  15951. constructor(
  15952. /**
  15953. * The radius of the emission cylinder.
  15954. */
  15955. radius?: number,
  15956. /**
  15957. * The height of the emission cylinder.
  15958. */
  15959. height?: number,
  15960. /**
  15961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15962. */
  15963. radiusRange?: number,
  15964. /**
  15965. * How much to randomize the particle direction [0-1].
  15966. */
  15967. directionRandomizer?: number);
  15968. /**
  15969. * Called by the particle System when the direction is computed for the created particle.
  15970. * @param worldMatrix is the world matrix of the particle system
  15971. * @param directionToUpdate is the direction vector to update with the result
  15972. * @param particle is the particle we are computed the direction for
  15973. */
  15974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15975. /**
  15976. * Called by the particle System when the position is computed for the created particle.
  15977. * @param worldMatrix is the world matrix of the particle system
  15978. * @param positionToUpdate is the position vector to update with the result
  15979. * @param particle is the particle we are computed the position for
  15980. */
  15981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15982. /**
  15983. * Clones the current emitter and returns a copy of it
  15984. * @returns the new emitter
  15985. */
  15986. clone(): CylinderParticleEmitter;
  15987. /**
  15988. * Called by the GPUParticleSystem to setup the update shader
  15989. * @param effect defines the update shader
  15990. */
  15991. applyToShader(effect: Effect): void;
  15992. /**
  15993. * Returns a string to use to update the GPU particles update shader
  15994. * @returns a string containng the defines string
  15995. */
  15996. getEffectDefines(): string;
  15997. /**
  15998. * Returns the string "CylinderParticleEmitter"
  15999. * @returns a string containing the class name
  16000. */
  16001. getClassName(): string;
  16002. /**
  16003. * Serializes the particle system to a JSON object.
  16004. * @returns the JSON object
  16005. */
  16006. serialize(): any;
  16007. /**
  16008. * Parse properties from a JSON object
  16009. * @param serializationObject defines the JSON object
  16010. */
  16011. parse(serializationObject: any): void;
  16012. }
  16013. /**
  16014. * Particle emitter emitting particles from the inside of a cylinder.
  16015. * It emits the particles randomly between two vectors.
  16016. */
  16017. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16018. /**
  16019. * The min limit of the emission direction.
  16020. */
  16021. direction1: Vector3;
  16022. /**
  16023. * The max limit of the emission direction.
  16024. */
  16025. direction2: Vector3;
  16026. /**
  16027. * Creates a new instance CylinderDirectedParticleEmitter
  16028. * @param radius the radius of the emission cylinder (1 by default)
  16029. * @param height the height of the emission cylinder (1 by default)
  16030. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16031. * @param direction1 the min limit of the emission direction (up vector by default)
  16032. * @param direction2 the max limit of the emission direction (up vector by default)
  16033. */
  16034. constructor(radius?: number, height?: number, radiusRange?: number,
  16035. /**
  16036. * The min limit of the emission direction.
  16037. */
  16038. direction1?: Vector3,
  16039. /**
  16040. * The max limit of the emission direction.
  16041. */
  16042. direction2?: Vector3);
  16043. /**
  16044. * Called by the particle System when the direction is computed for the created particle.
  16045. * @param worldMatrix is the world matrix of the particle system
  16046. * @param directionToUpdate is the direction vector to update with the result
  16047. * @param particle is the particle we are computed the direction for
  16048. */
  16049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16050. /**
  16051. * Clones the current emitter and returns a copy of it
  16052. * @returns the new emitter
  16053. */
  16054. clone(): CylinderDirectedParticleEmitter;
  16055. /**
  16056. * Called by the GPUParticleSystem to setup the update shader
  16057. * @param effect defines the update shader
  16058. */
  16059. applyToShader(effect: Effect): void;
  16060. /**
  16061. * Returns a string to use to update the GPU particles update shader
  16062. * @returns a string containng the defines string
  16063. */
  16064. getEffectDefines(): string;
  16065. /**
  16066. * Returns the string "CylinderDirectedParticleEmitter"
  16067. * @returns a string containing the class name
  16068. */
  16069. getClassName(): string;
  16070. /**
  16071. * Serializes the particle system to a JSON object.
  16072. * @returns the JSON object
  16073. */
  16074. serialize(): any;
  16075. /**
  16076. * Parse properties from a JSON object
  16077. * @param serializationObject defines the JSON object
  16078. */
  16079. parse(serializationObject: any): void;
  16080. }
  16081. }
  16082. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16083. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16084. import { Effect } from "babylonjs/Materials/effect";
  16085. import { Particle } from "babylonjs/Particles/particle";
  16086. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16087. /**
  16088. * Particle emitter emitting particles from the inside of a hemisphere.
  16089. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16090. */
  16091. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16092. /**
  16093. * The radius of the emission hemisphere.
  16094. */
  16095. radius: number;
  16096. /**
  16097. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16098. */
  16099. radiusRange: number;
  16100. /**
  16101. * How much to randomize the particle direction [0-1].
  16102. */
  16103. directionRandomizer: number;
  16104. /**
  16105. * Creates a new instance HemisphericParticleEmitter
  16106. * @param radius the radius of the emission hemisphere (1 by default)
  16107. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16108. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16109. */
  16110. constructor(
  16111. /**
  16112. * The radius of the emission hemisphere.
  16113. */
  16114. radius?: number,
  16115. /**
  16116. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16117. */
  16118. radiusRange?: number,
  16119. /**
  16120. * How much to randomize the particle direction [0-1].
  16121. */
  16122. directionRandomizer?: number);
  16123. /**
  16124. * Called by the particle System when the direction is computed for the created particle.
  16125. * @param worldMatrix is the world matrix of the particle system
  16126. * @param directionToUpdate is the direction vector to update with the result
  16127. * @param particle is the particle we are computed the direction for
  16128. */
  16129. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16130. /**
  16131. * Called by the particle System when the position is computed for the created particle.
  16132. * @param worldMatrix is the world matrix of the particle system
  16133. * @param positionToUpdate is the position vector to update with the result
  16134. * @param particle is the particle we are computed the position for
  16135. */
  16136. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16137. /**
  16138. * Clones the current emitter and returns a copy of it
  16139. * @returns the new emitter
  16140. */
  16141. clone(): HemisphericParticleEmitter;
  16142. /**
  16143. * Called by the GPUParticleSystem to setup the update shader
  16144. * @param effect defines the update shader
  16145. */
  16146. applyToShader(effect: Effect): void;
  16147. /**
  16148. * Returns a string to use to update the GPU particles update shader
  16149. * @returns a string containng the defines string
  16150. */
  16151. getEffectDefines(): string;
  16152. /**
  16153. * Returns the string "HemisphericParticleEmitter"
  16154. * @returns a string containing the class name
  16155. */
  16156. getClassName(): string;
  16157. /**
  16158. * Serializes the particle system to a JSON object.
  16159. * @returns the JSON object
  16160. */
  16161. serialize(): any;
  16162. /**
  16163. * Parse properties from a JSON object
  16164. * @param serializationObject defines the JSON object
  16165. */
  16166. parse(serializationObject: any): void;
  16167. }
  16168. }
  16169. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16170. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16171. import { Effect } from "babylonjs/Materials/effect";
  16172. import { Particle } from "babylonjs/Particles/particle";
  16173. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16174. /**
  16175. * Particle emitter emitting particles from a point.
  16176. * It emits the particles randomly between 2 given directions.
  16177. */
  16178. export class PointParticleEmitter implements IParticleEmitterType {
  16179. /**
  16180. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16181. */
  16182. direction1: Vector3;
  16183. /**
  16184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16185. */
  16186. direction2: Vector3;
  16187. /**
  16188. * Creates a new instance PointParticleEmitter
  16189. */
  16190. constructor();
  16191. /**
  16192. * Called by the particle System when the direction is computed for the created particle.
  16193. * @param worldMatrix is the world matrix of the particle system
  16194. * @param directionToUpdate is the direction vector to update with the result
  16195. * @param particle is the particle we are computed the direction for
  16196. */
  16197. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16198. /**
  16199. * Called by the particle System when the position is computed for the created particle.
  16200. * @param worldMatrix is the world matrix of the particle system
  16201. * @param positionToUpdate is the position vector to update with the result
  16202. * @param particle is the particle we are computed the position for
  16203. */
  16204. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16205. /**
  16206. * Clones the current emitter and returns a copy of it
  16207. * @returns the new emitter
  16208. */
  16209. clone(): PointParticleEmitter;
  16210. /**
  16211. * Called by the GPUParticleSystem to setup the update shader
  16212. * @param effect defines the update shader
  16213. */
  16214. applyToShader(effect: Effect): void;
  16215. /**
  16216. * Returns a string to use to update the GPU particles update shader
  16217. * @returns a string containng the defines string
  16218. */
  16219. getEffectDefines(): string;
  16220. /**
  16221. * Returns the string "PointParticleEmitter"
  16222. * @returns a string containing the class name
  16223. */
  16224. getClassName(): string;
  16225. /**
  16226. * Serializes the particle system to a JSON object.
  16227. * @returns the JSON object
  16228. */
  16229. serialize(): any;
  16230. /**
  16231. * Parse properties from a JSON object
  16232. * @param serializationObject defines the JSON object
  16233. */
  16234. parse(serializationObject: any): void;
  16235. }
  16236. }
  16237. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16238. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16239. import { Effect } from "babylonjs/Materials/effect";
  16240. import { Particle } from "babylonjs/Particles/particle";
  16241. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16242. /**
  16243. * Particle emitter emitting particles from the inside of a sphere.
  16244. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16245. */
  16246. export class SphereParticleEmitter implements IParticleEmitterType {
  16247. /**
  16248. * The radius of the emission sphere.
  16249. */
  16250. radius: number;
  16251. /**
  16252. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16253. */
  16254. radiusRange: number;
  16255. /**
  16256. * How much to randomize the particle direction [0-1].
  16257. */
  16258. directionRandomizer: number;
  16259. /**
  16260. * Creates a new instance SphereParticleEmitter
  16261. * @param radius the radius of the emission sphere (1 by default)
  16262. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16263. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16264. */
  16265. constructor(
  16266. /**
  16267. * The radius of the emission sphere.
  16268. */
  16269. radius?: number,
  16270. /**
  16271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16272. */
  16273. radiusRange?: number,
  16274. /**
  16275. * How much to randomize the particle direction [0-1].
  16276. */
  16277. directionRandomizer?: number);
  16278. /**
  16279. * Called by the particle System when the direction is computed for the created particle.
  16280. * @param worldMatrix is the world matrix of the particle system
  16281. * @param directionToUpdate is the direction vector to update with the result
  16282. * @param particle is the particle we are computed the direction for
  16283. */
  16284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16285. /**
  16286. * Called by the particle System when the position is computed for the created particle.
  16287. * @param worldMatrix is the world matrix of the particle system
  16288. * @param positionToUpdate is the position vector to update with the result
  16289. * @param particle is the particle we are computed the position for
  16290. */
  16291. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16292. /**
  16293. * Clones the current emitter and returns a copy of it
  16294. * @returns the new emitter
  16295. */
  16296. clone(): SphereParticleEmitter;
  16297. /**
  16298. * Called by the GPUParticleSystem to setup the update shader
  16299. * @param effect defines the update shader
  16300. */
  16301. applyToShader(effect: Effect): void;
  16302. /**
  16303. * Returns a string to use to update the GPU particles update shader
  16304. * @returns a string containng the defines string
  16305. */
  16306. getEffectDefines(): string;
  16307. /**
  16308. * Returns the string "SphereParticleEmitter"
  16309. * @returns a string containing the class name
  16310. */
  16311. getClassName(): string;
  16312. /**
  16313. * Serializes the particle system to a JSON object.
  16314. * @returns the JSON object
  16315. */
  16316. serialize(): any;
  16317. /**
  16318. * Parse properties from a JSON object
  16319. * @param serializationObject defines the JSON object
  16320. */
  16321. parse(serializationObject: any): void;
  16322. }
  16323. /**
  16324. * Particle emitter emitting particles from the inside of a sphere.
  16325. * It emits the particles randomly between two vectors.
  16326. */
  16327. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16328. /**
  16329. * The min limit of the emission direction.
  16330. */
  16331. direction1: Vector3;
  16332. /**
  16333. * The max limit of the emission direction.
  16334. */
  16335. direction2: Vector3;
  16336. /**
  16337. * Creates a new instance SphereDirectedParticleEmitter
  16338. * @param radius the radius of the emission sphere (1 by default)
  16339. * @param direction1 the min limit of the emission direction (up vector by default)
  16340. * @param direction2 the max limit of the emission direction (up vector by default)
  16341. */
  16342. constructor(radius?: number,
  16343. /**
  16344. * The min limit of the emission direction.
  16345. */
  16346. direction1?: Vector3,
  16347. /**
  16348. * The max limit of the emission direction.
  16349. */
  16350. direction2?: Vector3);
  16351. /**
  16352. * Called by the particle System when the direction is computed for the created particle.
  16353. * @param worldMatrix is the world matrix of the particle system
  16354. * @param directionToUpdate is the direction vector to update with the result
  16355. * @param particle is the particle we are computed the direction for
  16356. */
  16357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16358. /**
  16359. * Clones the current emitter and returns a copy of it
  16360. * @returns the new emitter
  16361. */
  16362. clone(): SphereDirectedParticleEmitter;
  16363. /**
  16364. * Called by the GPUParticleSystem to setup the update shader
  16365. * @param effect defines the update shader
  16366. */
  16367. applyToShader(effect: Effect): void;
  16368. /**
  16369. * Returns a string to use to update the GPU particles update shader
  16370. * @returns a string containng the defines string
  16371. */
  16372. getEffectDefines(): string;
  16373. /**
  16374. * Returns the string "SphereDirectedParticleEmitter"
  16375. * @returns a string containing the class name
  16376. */
  16377. getClassName(): string;
  16378. /**
  16379. * Serializes the particle system to a JSON object.
  16380. * @returns the JSON object
  16381. */
  16382. serialize(): any;
  16383. /**
  16384. * Parse properties from a JSON object
  16385. * @param serializationObject defines the JSON object
  16386. */
  16387. parse(serializationObject: any): void;
  16388. }
  16389. }
  16390. declare module "babylonjs/Particles/EmitterTypes/index" {
  16391. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16392. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16393. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16394. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16395. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16396. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16397. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16398. }
  16399. declare module "babylonjs/Particles/IParticleSystem" {
  16400. import { Nullable } from "babylonjs/types";
  16401. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16404. import { Texture } from "babylonjs/Materials/Textures/texture";
  16405. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16406. import { Scene } from "babylonjs/scene";
  16407. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16408. import { Animation } from "babylonjs/Animations/animation";
  16409. /**
  16410. * Interface representing a particle system in Babylon.js.
  16411. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16412. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16413. */
  16414. export interface IParticleSystem {
  16415. /**
  16416. * List of animations used by the particle system.
  16417. */
  16418. animations: Animation[];
  16419. /**
  16420. * The id of the Particle system.
  16421. */
  16422. id: string;
  16423. /**
  16424. * The name of the Particle system.
  16425. */
  16426. name: string;
  16427. /**
  16428. * The emitter represents the Mesh or position we are attaching the particle system to.
  16429. */
  16430. emitter: Nullable<AbstractMesh | Vector3>;
  16431. /**
  16432. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16433. */
  16434. isBillboardBased: boolean;
  16435. /**
  16436. * The rendering group used by the Particle system to chose when to render.
  16437. */
  16438. renderingGroupId: number;
  16439. /**
  16440. * The layer mask we are rendering the particles through.
  16441. */
  16442. layerMask: number;
  16443. /**
  16444. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16445. */
  16446. updateSpeed: number;
  16447. /**
  16448. * The amount of time the particle system is running (depends of the overall update speed).
  16449. */
  16450. targetStopDuration: number;
  16451. /**
  16452. * The texture used to render each particle. (this can be a spritesheet)
  16453. */
  16454. particleTexture: Nullable<Texture>;
  16455. /**
  16456. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16457. */
  16458. blendMode: number;
  16459. /**
  16460. * Minimum life time of emitting particles.
  16461. */
  16462. minLifeTime: number;
  16463. /**
  16464. * Maximum life time of emitting particles.
  16465. */
  16466. maxLifeTime: number;
  16467. /**
  16468. * Minimum Size of emitting particles.
  16469. */
  16470. minSize: number;
  16471. /**
  16472. * Maximum Size of emitting particles.
  16473. */
  16474. maxSize: number;
  16475. /**
  16476. * Minimum scale of emitting particles on X axis.
  16477. */
  16478. minScaleX: number;
  16479. /**
  16480. * Maximum scale of emitting particles on X axis.
  16481. */
  16482. maxScaleX: number;
  16483. /**
  16484. * Minimum scale of emitting particles on Y axis.
  16485. */
  16486. minScaleY: number;
  16487. /**
  16488. * Maximum scale of emitting particles on Y axis.
  16489. */
  16490. maxScaleY: number;
  16491. /**
  16492. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16493. */
  16494. color1: Color4;
  16495. /**
  16496. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16497. */
  16498. color2: Color4;
  16499. /**
  16500. * Color the particle will have at the end of its lifetime.
  16501. */
  16502. colorDead: Color4;
  16503. /**
  16504. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16505. */
  16506. emitRate: number;
  16507. /**
  16508. * You can use gravity if you want to give an orientation to your particles.
  16509. */
  16510. gravity: Vector3;
  16511. /**
  16512. * Minimum power of emitting particles.
  16513. */
  16514. minEmitPower: number;
  16515. /**
  16516. * Maximum power of emitting particles.
  16517. */
  16518. maxEmitPower: number;
  16519. /**
  16520. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16521. */
  16522. minAngularSpeed: number;
  16523. /**
  16524. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16525. */
  16526. maxAngularSpeed: number;
  16527. /**
  16528. * Gets or sets the minimal initial rotation in radians.
  16529. */
  16530. minInitialRotation: number;
  16531. /**
  16532. * Gets or sets the maximal initial rotation in radians.
  16533. */
  16534. maxInitialRotation: number;
  16535. /**
  16536. * The particle emitter type defines the emitter used by the particle system.
  16537. * It can be for example box, sphere, or cone...
  16538. */
  16539. particleEmitterType: Nullable<IParticleEmitterType>;
  16540. /**
  16541. * Defines the delay in milliseconds before starting the system (0 by default)
  16542. */
  16543. startDelay: number;
  16544. /**
  16545. * 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
  16546. */
  16547. preWarmCycles: number;
  16548. /**
  16549. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16550. */
  16551. preWarmStepOffset: number;
  16552. /**
  16553. * 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)
  16554. */
  16555. spriteCellChangeSpeed: number;
  16556. /**
  16557. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16558. */
  16559. startSpriteCellID: number;
  16560. /**
  16561. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16562. */
  16563. endSpriteCellID: number;
  16564. /**
  16565. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16566. */
  16567. spriteCellWidth: number;
  16568. /**
  16569. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16570. */
  16571. spriteCellHeight: number;
  16572. /**
  16573. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16574. */
  16575. spriteRandomStartCell: boolean;
  16576. /**
  16577. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16578. */
  16579. isAnimationSheetEnabled: boolean;
  16580. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16581. translationPivot: Vector2;
  16582. /**
  16583. * Gets or sets a texture used to add random noise to particle positions
  16584. */
  16585. noiseTexture: Nullable<BaseTexture>;
  16586. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16587. noiseStrength: Vector3;
  16588. /**
  16589. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16590. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16591. */
  16592. billboardMode: number;
  16593. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16594. limitVelocityDamping: number;
  16595. /**
  16596. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16597. */
  16598. beginAnimationOnStart: boolean;
  16599. /**
  16600. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16601. */
  16602. beginAnimationFrom: number;
  16603. /**
  16604. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16605. */
  16606. beginAnimationTo: number;
  16607. /**
  16608. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16609. */
  16610. beginAnimationLoop: boolean;
  16611. /**
  16612. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16613. */
  16614. disposeOnStop: boolean;
  16615. /**
  16616. * Gets the maximum number of particles active at the same time.
  16617. * @returns The max number of active particles.
  16618. */
  16619. getCapacity(): number;
  16620. /**
  16621. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16622. * @returns True if it has been started, otherwise false.
  16623. */
  16624. isStarted(): boolean;
  16625. /**
  16626. * Animates the particle system for this frame.
  16627. */
  16628. animate(): void;
  16629. /**
  16630. * Renders the particle system in its current state.
  16631. * @returns the current number of particles
  16632. */
  16633. render(): number;
  16634. /**
  16635. * Dispose the particle system and frees its associated resources.
  16636. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16637. */
  16638. dispose(disposeTexture?: boolean): void;
  16639. /**
  16640. * Clones the particle system.
  16641. * @param name The name of the cloned object
  16642. * @param newEmitter The new emitter to use
  16643. * @returns the cloned particle system
  16644. */
  16645. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16646. /**
  16647. * Serializes the particle system to a JSON object.
  16648. * @returns the JSON object
  16649. */
  16650. serialize(): any;
  16651. /**
  16652. * Rebuild the particle system
  16653. */
  16654. rebuild(): void;
  16655. /**
  16656. * Starts the particle system and begins to emit
  16657. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16658. */
  16659. start(delay?: number): void;
  16660. /**
  16661. * Stops the particle system.
  16662. */
  16663. stop(): void;
  16664. /**
  16665. * Remove all active particles
  16666. */
  16667. reset(): void;
  16668. /**
  16669. * Is this system ready to be used/rendered
  16670. * @return true if the system is ready
  16671. */
  16672. isReady(): boolean;
  16673. /**
  16674. * Adds a new color gradient
  16675. * @param gradient defines the gradient to use (between 0 and 1)
  16676. * @param color1 defines the color to affect to the specified gradient
  16677. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16678. * @returns the current particle system
  16679. */
  16680. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16681. /**
  16682. * Remove a specific color gradient
  16683. * @param gradient defines the gradient to remove
  16684. * @returns the current particle system
  16685. */
  16686. removeColorGradient(gradient: number): IParticleSystem;
  16687. /**
  16688. * Adds a new size gradient
  16689. * @param gradient defines the gradient to use (between 0 and 1)
  16690. * @param factor defines the size factor to affect to the specified gradient
  16691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16692. * @returns the current particle system
  16693. */
  16694. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16695. /**
  16696. * Remove a specific size gradient
  16697. * @param gradient defines the gradient to remove
  16698. * @returns the current particle system
  16699. */
  16700. removeSizeGradient(gradient: number): IParticleSystem;
  16701. /**
  16702. * Gets the current list of color gradients.
  16703. * You must use addColorGradient and removeColorGradient to udpate this list
  16704. * @returns the list of color gradients
  16705. */
  16706. getColorGradients(): Nullable<Array<ColorGradient>>;
  16707. /**
  16708. * Gets the current list of size gradients.
  16709. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16710. * @returns the list of size gradients
  16711. */
  16712. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16713. /**
  16714. * Gets the current list of angular speed gradients.
  16715. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16716. * @returns the list of angular speed gradients
  16717. */
  16718. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16719. /**
  16720. * Adds a new angular speed gradient
  16721. * @param gradient defines the gradient to use (between 0 and 1)
  16722. * @param factor defines the angular speed to affect to the specified gradient
  16723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16724. * @returns the current particle system
  16725. */
  16726. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16727. /**
  16728. * Remove a specific angular speed gradient
  16729. * @param gradient defines the gradient to remove
  16730. * @returns the current particle system
  16731. */
  16732. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16733. /**
  16734. * Gets the current list of velocity gradients.
  16735. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16736. * @returns the list of velocity gradients
  16737. */
  16738. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16739. /**
  16740. * Adds a new velocity gradient
  16741. * @param gradient defines the gradient to use (between 0 and 1)
  16742. * @param factor defines the velocity to affect to the specified gradient
  16743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16744. * @returns the current particle system
  16745. */
  16746. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16747. /**
  16748. * Remove a specific velocity gradient
  16749. * @param gradient defines the gradient to remove
  16750. * @returns the current particle system
  16751. */
  16752. removeVelocityGradient(gradient: number): IParticleSystem;
  16753. /**
  16754. * Gets the current list of limit velocity gradients.
  16755. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16756. * @returns the list of limit velocity gradients
  16757. */
  16758. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16759. /**
  16760. * Adds a new limit velocity gradient
  16761. * @param gradient defines the gradient to use (between 0 and 1)
  16762. * @param factor defines the limit velocity to affect to the specified gradient
  16763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16764. * @returns the current particle system
  16765. */
  16766. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16767. /**
  16768. * Remove a specific limit velocity gradient
  16769. * @param gradient defines the gradient to remove
  16770. * @returns the current particle system
  16771. */
  16772. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16773. /**
  16774. * Adds a new drag gradient
  16775. * @param gradient defines the gradient to use (between 0 and 1)
  16776. * @param factor defines the drag to affect to the specified gradient
  16777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16778. * @returns the current particle system
  16779. */
  16780. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16781. /**
  16782. * Remove a specific drag gradient
  16783. * @param gradient defines the gradient to remove
  16784. * @returns the current particle system
  16785. */
  16786. removeDragGradient(gradient: number): IParticleSystem;
  16787. /**
  16788. * Gets the current list of drag gradients.
  16789. * You must use addDragGradient and removeDragGradient to udpate this list
  16790. * @returns the list of drag gradients
  16791. */
  16792. getDragGradients(): Nullable<Array<FactorGradient>>;
  16793. /**
  16794. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16795. * @param gradient defines the gradient to use (between 0 and 1)
  16796. * @param factor defines the emit rate to affect to the specified gradient
  16797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16798. * @returns the current particle system
  16799. */
  16800. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16801. /**
  16802. * Remove a specific emit rate gradient
  16803. * @param gradient defines the gradient to remove
  16804. * @returns the current particle system
  16805. */
  16806. removeEmitRateGradient(gradient: number): IParticleSystem;
  16807. /**
  16808. * Gets the current list of emit rate gradients.
  16809. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16810. * @returns the list of emit rate gradients
  16811. */
  16812. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16815. * @param gradient defines the gradient to use (between 0 and 1)
  16816. * @param factor defines the start size to affect to the specified gradient
  16817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16818. * @returns the current particle system
  16819. */
  16820. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16821. /**
  16822. * Remove a specific start size gradient
  16823. * @param gradient defines the gradient to remove
  16824. * @returns the current particle system
  16825. */
  16826. removeStartSizeGradient(gradient: number): IParticleSystem;
  16827. /**
  16828. * Gets the current list of start size gradients.
  16829. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16830. * @returns the list of start size gradients
  16831. */
  16832. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Adds a new life time gradient
  16835. * @param gradient defines the gradient to use (between 0 and 1)
  16836. * @param factor defines the life time factor to affect to the specified gradient
  16837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16838. * @returns the current particle system
  16839. */
  16840. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16841. /**
  16842. * Remove a specific life time gradient
  16843. * @param gradient defines the gradient to remove
  16844. * @returns the current particle system
  16845. */
  16846. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16847. /**
  16848. * Gets the current list of life time gradients.
  16849. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16850. * @returns the list of life time gradients
  16851. */
  16852. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16853. /**
  16854. * Gets the current list of color gradients.
  16855. * You must use addColorGradient and removeColorGradient to udpate this list
  16856. * @returns the list of color gradients
  16857. */
  16858. getColorGradients(): Nullable<Array<ColorGradient>>;
  16859. /**
  16860. * Adds a new ramp gradient used to remap particle colors
  16861. * @param gradient defines the gradient to use (between 0 and 1)
  16862. * @param color defines the color to affect to the specified gradient
  16863. * @returns the current particle system
  16864. */
  16865. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16866. /**
  16867. * Gets the current list of ramp gradients.
  16868. * You must use addRampGradient and removeRampGradient to udpate this list
  16869. * @returns the list of ramp gradients
  16870. */
  16871. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16872. /** Gets or sets a boolean indicating that ramp gradients must be used
  16873. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16874. */
  16875. useRampGradients: boolean;
  16876. /**
  16877. * Adds a new color remap gradient
  16878. * @param gradient defines the gradient to use (between 0 and 1)
  16879. * @param min defines the color remap minimal range
  16880. * @param max defines the color remap maximal range
  16881. * @returns the current particle system
  16882. */
  16883. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16884. /**
  16885. * Gets the current list of color remap gradients.
  16886. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16887. * @returns the list of color remap gradients
  16888. */
  16889. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16890. /**
  16891. * Adds a new alpha remap gradient
  16892. * @param gradient defines the gradient to use (between 0 and 1)
  16893. * @param min defines the alpha remap minimal range
  16894. * @param max defines the alpha remap maximal range
  16895. * @returns the current particle system
  16896. */
  16897. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16898. /**
  16899. * Gets the current list of alpha remap gradients.
  16900. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16901. * @returns the list of alpha remap gradients
  16902. */
  16903. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16904. /**
  16905. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16906. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16907. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16908. * @returns the emitter
  16909. */
  16910. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16911. /**
  16912. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16913. * @param radius The radius of the hemisphere to emit from
  16914. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16915. * @returns the emitter
  16916. */
  16917. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16918. /**
  16919. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16920. * @param radius The radius of the sphere to emit from
  16921. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16922. * @returns the emitter
  16923. */
  16924. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16925. /**
  16926. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16927. * @param radius The radius of the sphere to emit from
  16928. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16929. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16930. * @returns the emitter
  16931. */
  16932. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16933. /**
  16934. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16935. * @param radius The radius of the emission cylinder
  16936. * @param height The height of the emission cylinder
  16937. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16938. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16939. * @returns the emitter
  16940. */
  16941. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16942. /**
  16943. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16944. * @param radius The radius of the cylinder to emit from
  16945. * @param height The height of the emission cylinder
  16946. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16947. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16948. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16949. * @returns the emitter
  16950. */
  16951. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16952. /**
  16953. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16954. * @param radius The radius of the cone to emit from
  16955. * @param angle The base angle of the cone
  16956. * @returns the emitter
  16957. */
  16958. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16959. /**
  16960. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16961. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16962. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16963. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16964. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16965. * @returns the emitter
  16966. */
  16967. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16968. /**
  16969. * Get hosting scene
  16970. * @returns the scene
  16971. */
  16972. getScene(): Scene;
  16973. }
  16974. }
  16975. declare module "babylonjs/Shaders/line.fragment" {
  16976. /** @hidden */
  16977. export var linePixelShader: {
  16978. name: string;
  16979. shader: string;
  16980. };
  16981. }
  16982. declare module "babylonjs/Shaders/line.vertex" {
  16983. /** @hidden */
  16984. export var lineVertexShader: {
  16985. name: string;
  16986. shader: string;
  16987. };
  16988. }
  16989. declare module "babylonjs/Rendering/edgesRenderer" {
  16990. import { Nullable } from "babylonjs/types";
  16991. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16993. import { Vector3 } from "babylonjs/Maths/math";
  16994. import { IDisposable } from "babylonjs/scene";
  16995. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16996. import "babylonjs/Shaders/line.fragment";
  16997. import "babylonjs/Shaders/line.vertex";
  16998. module "babylonjs/Meshes/abstractMesh" {
  16999. interface AbstractMesh {
  17000. /**
  17001. * Disables the mesh edge rendering mode
  17002. * @returns the currentAbstractMesh
  17003. */
  17004. disableEdgesRendering(): AbstractMesh;
  17005. /**
  17006. * Enables the edge rendering mode on the mesh.
  17007. * This mode makes the mesh edges visible
  17008. * @param epsilon defines the maximal distance between two angles to detect a face
  17009. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17010. * @returns the currentAbstractMesh
  17011. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17012. */
  17013. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17014. /**
  17015. * Gets the edgesRenderer associated with the mesh
  17016. */
  17017. edgesRenderer: Nullable<EdgesRenderer>;
  17018. }
  17019. }
  17020. module "babylonjs/Meshes/linesMesh" {
  17021. interface LinesMesh {
  17022. /**
  17023. * Enables the edge rendering mode on the mesh.
  17024. * This mode makes the mesh edges visible
  17025. * @param epsilon defines the maximal distance between two angles to detect a face
  17026. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17027. * @returns the currentAbstractMesh
  17028. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17029. */
  17030. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17031. }
  17032. }
  17033. module "babylonjs/Meshes/linesMesh" {
  17034. interface InstancedLinesMesh {
  17035. /**
  17036. * Enables the edge rendering mode on the mesh.
  17037. * This mode makes the mesh edges visible
  17038. * @param epsilon defines the maximal distance between two angles to detect a face
  17039. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17040. * @returns the current InstancedLinesMesh
  17041. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17042. */
  17043. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17044. }
  17045. }
  17046. /**
  17047. * Defines the minimum contract an Edges renderer should follow.
  17048. */
  17049. export interface IEdgesRenderer extends IDisposable {
  17050. /**
  17051. * Gets or sets a boolean indicating if the edgesRenderer is active
  17052. */
  17053. isEnabled: boolean;
  17054. /**
  17055. * Renders the edges of the attached mesh,
  17056. */
  17057. render(): void;
  17058. /**
  17059. * Checks wether or not the edges renderer is ready to render.
  17060. * @return true if ready, otherwise false.
  17061. */
  17062. isReady(): boolean;
  17063. }
  17064. /**
  17065. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17066. */
  17067. export class EdgesRenderer implements IEdgesRenderer {
  17068. /**
  17069. * Define the size of the edges with an orthographic camera
  17070. */
  17071. edgesWidthScalerForOrthographic: number;
  17072. /**
  17073. * Define the size of the edges with a perspective camera
  17074. */
  17075. edgesWidthScalerForPerspective: number;
  17076. protected _source: AbstractMesh;
  17077. protected _linesPositions: number[];
  17078. protected _linesNormals: number[];
  17079. protected _linesIndices: number[];
  17080. protected _epsilon: number;
  17081. protected _indicesCount: number;
  17082. protected _lineShader: ShaderMaterial;
  17083. protected _ib: WebGLBuffer;
  17084. protected _buffers: {
  17085. [key: string]: Nullable<VertexBuffer>;
  17086. };
  17087. protected _checkVerticesInsteadOfIndices: boolean;
  17088. private _meshRebuildObserver;
  17089. private _meshDisposeObserver;
  17090. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17091. isEnabled: boolean;
  17092. /**
  17093. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17094. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17095. * @param source Mesh used to create edges
  17096. * @param epsilon sum of angles in adjacency to check for edge
  17097. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17098. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17099. */
  17100. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17101. protected _prepareRessources(): void;
  17102. /** @hidden */
  17103. _rebuild(): void;
  17104. /**
  17105. * Releases the required resources for the edges renderer
  17106. */
  17107. dispose(): void;
  17108. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17109. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17110. /**
  17111. * Checks if the pair of p0 and p1 is en edge
  17112. * @param faceIndex
  17113. * @param edge
  17114. * @param faceNormals
  17115. * @param p0
  17116. * @param p1
  17117. * @private
  17118. */
  17119. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17120. /**
  17121. * push line into the position, normal and index buffer
  17122. * @protected
  17123. */
  17124. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17125. /**
  17126. * Generates lines edges from adjacencjes
  17127. * @private
  17128. */
  17129. _generateEdgesLines(): void;
  17130. /**
  17131. * Checks wether or not the edges renderer is ready to render.
  17132. * @return true if ready, otherwise false.
  17133. */
  17134. isReady(): boolean;
  17135. /**
  17136. * Renders the edges of the attached mesh,
  17137. */
  17138. render(): void;
  17139. }
  17140. /**
  17141. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17142. */
  17143. export class LineEdgesRenderer extends EdgesRenderer {
  17144. /**
  17145. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17146. * @param source LineMesh used to generate edges
  17147. * @param epsilon not important (specified angle for edge detection)
  17148. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17149. */
  17150. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17151. /**
  17152. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17153. */
  17154. _generateEdgesLines(): void;
  17155. }
  17156. }
  17157. declare module "babylonjs/Rendering/renderingGroup" {
  17158. import { SmartArray } from "babylonjs/Misc/smartArray";
  17159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17161. import { Nullable } from "babylonjs/types";
  17162. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17163. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17164. import { Material } from "babylonjs/Materials/material";
  17165. import { Scene } from "babylonjs/scene";
  17166. /**
  17167. * This represents the object necessary to create a rendering group.
  17168. * This is exclusively used and created by the rendering manager.
  17169. * To modify the behavior, you use the available helpers in your scene or meshes.
  17170. * @hidden
  17171. */
  17172. export class RenderingGroup {
  17173. index: number;
  17174. private _scene;
  17175. private _opaqueSubMeshes;
  17176. private _transparentSubMeshes;
  17177. private _alphaTestSubMeshes;
  17178. private _depthOnlySubMeshes;
  17179. private _particleSystems;
  17180. private _spriteManagers;
  17181. private _opaqueSortCompareFn;
  17182. private _alphaTestSortCompareFn;
  17183. private _transparentSortCompareFn;
  17184. private _renderOpaque;
  17185. private _renderAlphaTest;
  17186. private _renderTransparent;
  17187. private _edgesRenderers;
  17188. onBeforeTransparentRendering: () => void;
  17189. /**
  17190. * Set the opaque sort comparison function.
  17191. * If null the sub meshes will be render in the order they were created
  17192. */
  17193. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17194. /**
  17195. * Set the alpha test sort comparison function.
  17196. * If null the sub meshes will be render in the order they were created
  17197. */
  17198. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17199. /**
  17200. * Set the transparent sort comparison function.
  17201. * If null the sub meshes will be render in the order they were created
  17202. */
  17203. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17204. /**
  17205. * Creates a new rendering group.
  17206. * @param index The rendering group index
  17207. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17208. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17209. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17210. */
  17211. 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>);
  17212. /**
  17213. * Render all the sub meshes contained in the group.
  17214. * @param customRenderFunction Used to override the default render behaviour of the group.
  17215. * @returns true if rendered some submeshes.
  17216. */
  17217. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17218. /**
  17219. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17220. * @param subMeshes The submeshes to render
  17221. */
  17222. private renderOpaqueSorted;
  17223. /**
  17224. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17225. * @param subMeshes The submeshes to render
  17226. */
  17227. private renderAlphaTestSorted;
  17228. /**
  17229. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17230. * @param subMeshes The submeshes to render
  17231. */
  17232. private renderTransparentSorted;
  17233. /**
  17234. * Renders the submeshes in a specified order.
  17235. * @param subMeshes The submeshes to sort before render
  17236. * @param sortCompareFn The comparison function use to sort
  17237. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17238. * @param transparent Specifies to activate blending if true
  17239. */
  17240. private static renderSorted;
  17241. /**
  17242. * Renders the submeshes in the order they were dispatched (no sort applied).
  17243. * @param subMeshes The submeshes to render
  17244. */
  17245. private static renderUnsorted;
  17246. /**
  17247. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17248. * are rendered back to front if in the same alpha index.
  17249. *
  17250. * @param a The first submesh
  17251. * @param b The second submesh
  17252. * @returns The result of the comparison
  17253. */
  17254. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17255. /**
  17256. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17257. * are rendered back to front.
  17258. *
  17259. * @param a The first submesh
  17260. * @param b The second submesh
  17261. * @returns The result of the comparison
  17262. */
  17263. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17264. /**
  17265. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17266. * are rendered front to back (prevent overdraw).
  17267. *
  17268. * @param a The first submesh
  17269. * @param b The second submesh
  17270. * @returns The result of the comparison
  17271. */
  17272. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17273. /**
  17274. * Resets the different lists of submeshes to prepare a new frame.
  17275. */
  17276. prepare(): void;
  17277. dispose(): void;
  17278. /**
  17279. * Inserts the submesh in its correct queue depending on its material.
  17280. * @param subMesh The submesh to dispatch
  17281. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17282. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17283. */
  17284. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17285. dispatchSprites(spriteManager: ISpriteManager): void;
  17286. dispatchParticles(particleSystem: IParticleSystem): void;
  17287. private _renderParticles;
  17288. private _renderSprites;
  17289. }
  17290. }
  17291. declare module "babylonjs/Rendering/renderingManager" {
  17292. import { Nullable } from "babylonjs/types";
  17293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17294. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17295. import { SmartArray } from "babylonjs/Misc/smartArray";
  17296. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17297. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17298. import { Material } from "babylonjs/Materials/material";
  17299. import { Scene } from "babylonjs/scene";
  17300. import { Camera } from "babylonjs/Cameras/camera";
  17301. /**
  17302. * Interface describing the different options available in the rendering manager
  17303. * regarding Auto Clear between groups.
  17304. */
  17305. export interface IRenderingManagerAutoClearSetup {
  17306. /**
  17307. * Defines whether or not autoclear is enable.
  17308. */
  17309. autoClear: boolean;
  17310. /**
  17311. * Defines whether or not to autoclear the depth buffer.
  17312. */
  17313. depth: boolean;
  17314. /**
  17315. * Defines whether or not to autoclear the stencil buffer.
  17316. */
  17317. stencil: boolean;
  17318. }
  17319. /**
  17320. * This class is used by the onRenderingGroupObservable
  17321. */
  17322. export class RenderingGroupInfo {
  17323. /**
  17324. * The Scene that being rendered
  17325. */
  17326. scene: Scene;
  17327. /**
  17328. * The camera currently used for the rendering pass
  17329. */
  17330. camera: Nullable<Camera>;
  17331. /**
  17332. * The ID of the renderingGroup being processed
  17333. */
  17334. renderingGroupId: number;
  17335. }
  17336. /**
  17337. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17338. * It is enable to manage the different groups as well as the different necessary sort functions.
  17339. * This should not be used directly aside of the few static configurations
  17340. */
  17341. export class RenderingManager {
  17342. /**
  17343. * The max id used for rendering groups (not included)
  17344. */
  17345. static MAX_RENDERINGGROUPS: number;
  17346. /**
  17347. * The min id used for rendering groups (included)
  17348. */
  17349. static MIN_RENDERINGGROUPS: number;
  17350. /**
  17351. * Used to globally prevent autoclearing scenes.
  17352. */
  17353. static AUTOCLEAR: boolean;
  17354. /**
  17355. * @hidden
  17356. */
  17357. _useSceneAutoClearSetup: boolean;
  17358. private _scene;
  17359. private _renderingGroups;
  17360. private _depthStencilBufferAlreadyCleaned;
  17361. private _autoClearDepthStencil;
  17362. private _customOpaqueSortCompareFn;
  17363. private _customAlphaTestSortCompareFn;
  17364. private _customTransparentSortCompareFn;
  17365. private _renderingGroupInfo;
  17366. /**
  17367. * Instantiates a new rendering group for a particular scene
  17368. * @param scene Defines the scene the groups belongs to
  17369. */
  17370. constructor(scene: Scene);
  17371. private _clearDepthStencilBuffer;
  17372. /**
  17373. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17374. * @hidden
  17375. */
  17376. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17377. /**
  17378. * Resets the different information of the group to prepare a new frame
  17379. * @hidden
  17380. */
  17381. reset(): void;
  17382. /**
  17383. * Dispose and release the group and its associated resources.
  17384. * @hidden
  17385. */
  17386. dispose(): void;
  17387. /**
  17388. * Clear the info related to rendering groups preventing retention points during dispose.
  17389. */
  17390. freeRenderingGroups(): void;
  17391. private _prepareRenderingGroup;
  17392. /**
  17393. * Add a sprite manager to the rendering manager in order to render it this frame.
  17394. * @param spriteManager Define the sprite manager to render
  17395. */
  17396. dispatchSprites(spriteManager: ISpriteManager): void;
  17397. /**
  17398. * Add a particle system to the rendering manager in order to render it this frame.
  17399. * @param particleSystem Define the particle system to render
  17400. */
  17401. dispatchParticles(particleSystem: IParticleSystem): void;
  17402. /**
  17403. * Add a submesh to the manager in order to render it this frame
  17404. * @param subMesh The submesh to dispatch
  17405. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17406. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17407. */
  17408. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17409. /**
  17410. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17411. * This allowed control for front to back rendering or reversly depending of the special needs.
  17412. *
  17413. * @param renderingGroupId The rendering group id corresponding to its index
  17414. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17415. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17416. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17417. */
  17418. 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;
  17419. /**
  17420. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17421. *
  17422. * @param renderingGroupId The rendering group id corresponding to its index
  17423. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17424. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17425. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17426. */
  17427. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17428. /**
  17429. * Gets the current auto clear configuration for one rendering group of the rendering
  17430. * manager.
  17431. * @param index the rendering group index to get the information for
  17432. * @returns The auto clear setup for the requested rendering group
  17433. */
  17434. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17435. }
  17436. }
  17437. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17438. import { Observable } from "babylonjs/Misc/observable";
  17439. import { SmartArray } from "babylonjs/Misc/smartArray";
  17440. import { Nullable } from "babylonjs/types";
  17441. import { Camera } from "babylonjs/Cameras/camera";
  17442. import { Scene } from "babylonjs/scene";
  17443. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17444. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17446. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17448. import { Texture } from "babylonjs/Materials/Textures/texture";
  17449. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17450. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17451. import { Engine } from "babylonjs/Engines/engine";
  17452. /**
  17453. * This Helps creating a texture that will be created from a camera in your scene.
  17454. * It is basically a dynamic texture that could be used to create special effects for instance.
  17455. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17456. */
  17457. export class RenderTargetTexture extends Texture {
  17458. isCube: boolean;
  17459. /**
  17460. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17461. */
  17462. static readonly REFRESHRATE_RENDER_ONCE: number;
  17463. /**
  17464. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17465. */
  17466. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17467. /**
  17468. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17469. * the central point of your effect and can save a lot of performances.
  17470. */
  17471. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17472. /**
  17473. * Use this predicate to dynamically define the list of mesh you want to render.
  17474. * If set, the renderList property will be overwritten.
  17475. */
  17476. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17477. private _renderList;
  17478. /**
  17479. * Use this list to define the list of mesh you want to render.
  17480. */
  17481. renderList: Nullable<Array<AbstractMesh>>;
  17482. private _hookArray;
  17483. /**
  17484. * Define if particles should be rendered in your texture.
  17485. */
  17486. renderParticles: boolean;
  17487. /**
  17488. * Define if sprites should be rendered in your texture.
  17489. */
  17490. renderSprites: boolean;
  17491. /**
  17492. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17493. */
  17494. coordinatesMode: number;
  17495. /**
  17496. * Define the camera used to render the texture.
  17497. */
  17498. activeCamera: Nullable<Camera>;
  17499. /**
  17500. * Override the render function of the texture with your own one.
  17501. */
  17502. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17503. /**
  17504. * Define if camera post processes should be use while rendering the texture.
  17505. */
  17506. useCameraPostProcesses: boolean;
  17507. /**
  17508. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17509. */
  17510. ignoreCameraViewport: boolean;
  17511. private _postProcessManager;
  17512. private _postProcesses;
  17513. private _resizeObserver;
  17514. /**
  17515. * An event triggered when the texture is unbind.
  17516. */
  17517. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17518. /**
  17519. * An event triggered when the texture is unbind.
  17520. */
  17521. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17522. private _onAfterUnbindObserver;
  17523. /**
  17524. * Set a after unbind callback in the texture.
  17525. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17526. */
  17527. onAfterUnbind: () => void;
  17528. /**
  17529. * An event triggered before rendering the texture
  17530. */
  17531. onBeforeRenderObservable: Observable<number>;
  17532. private _onBeforeRenderObserver;
  17533. /**
  17534. * Set a before render callback in the texture.
  17535. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17536. */
  17537. onBeforeRender: (faceIndex: number) => void;
  17538. /**
  17539. * An event triggered after rendering the texture
  17540. */
  17541. onAfterRenderObservable: Observable<number>;
  17542. private _onAfterRenderObserver;
  17543. /**
  17544. * Set a after render callback in the texture.
  17545. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17546. */
  17547. onAfterRender: (faceIndex: number) => void;
  17548. /**
  17549. * An event triggered after the texture clear
  17550. */
  17551. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17552. private _onClearObserver;
  17553. /**
  17554. * Set a clear callback in the texture.
  17555. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17556. */
  17557. onClear: (Engine: Engine) => void;
  17558. /**
  17559. * Define the clear color of the Render Target if it should be different from the scene.
  17560. */
  17561. clearColor: Color4;
  17562. protected _size: number | {
  17563. width: number;
  17564. height: number;
  17565. };
  17566. protected _initialSizeParameter: number | {
  17567. width: number;
  17568. height: number;
  17569. } | {
  17570. ratio: number;
  17571. };
  17572. protected _sizeRatio: Nullable<number>;
  17573. /** @hidden */
  17574. _generateMipMaps: boolean;
  17575. protected _renderingManager: RenderingManager;
  17576. /** @hidden */
  17577. _waitingRenderList: string[];
  17578. protected _doNotChangeAspectRatio: boolean;
  17579. protected _currentRefreshId: number;
  17580. protected _refreshRate: number;
  17581. protected _textureMatrix: Matrix;
  17582. protected _samples: number;
  17583. protected _renderTargetOptions: RenderTargetCreationOptions;
  17584. /**
  17585. * Gets render target creation options that were used.
  17586. */
  17587. readonly renderTargetOptions: RenderTargetCreationOptions;
  17588. protected _engine: Engine;
  17589. protected _onRatioRescale(): void;
  17590. /**
  17591. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17592. * It must define where the camera used to render the texture is set
  17593. */
  17594. boundingBoxPosition: Vector3;
  17595. private _boundingBoxSize;
  17596. /**
  17597. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17598. * When defined, the cubemap will switch to local mode
  17599. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17600. * @example https://www.babylonjs-playground.com/#RNASML
  17601. */
  17602. boundingBoxSize: Vector3;
  17603. /**
  17604. * In case the RTT has been created with a depth texture, get the associated
  17605. * depth texture.
  17606. * Otherwise, return null.
  17607. */
  17608. depthStencilTexture: Nullable<InternalTexture>;
  17609. /**
  17610. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17611. * or used a shadow, depth texture...
  17612. * @param name The friendly name of the texture
  17613. * @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)
  17614. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17615. * @param generateMipMaps True if mip maps need to be generated after render.
  17616. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17617. * @param type The type of the buffer in the RTT (int, half float, float...)
  17618. * @param isCube True if a cube texture needs to be created
  17619. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17620. * @param generateDepthBuffer True to generate a depth buffer
  17621. * @param generateStencilBuffer True to generate a stencil buffer
  17622. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17623. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17624. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17625. */
  17626. constructor(name: string, size: number | {
  17627. width: number;
  17628. height: number;
  17629. } | {
  17630. ratio: number;
  17631. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17632. /**
  17633. * Creates a depth stencil texture.
  17634. * This is only available in WebGL 2 or with the depth texture extension available.
  17635. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17636. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17637. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17638. */
  17639. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17640. private _processSizeParameter;
  17641. /**
  17642. * Define the number of samples to use in case of MSAA.
  17643. * It defaults to one meaning no MSAA has been enabled.
  17644. */
  17645. samples: number;
  17646. /**
  17647. * Resets the refresh counter of the texture and start bak from scratch.
  17648. * Could be useful to regenerate the texture if it is setup to render only once.
  17649. */
  17650. resetRefreshCounter(): void;
  17651. /**
  17652. * Define the refresh rate of the texture or the rendering frequency.
  17653. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17654. */
  17655. refreshRate: number;
  17656. /**
  17657. * Adds a post process to the render target rendering passes.
  17658. * @param postProcess define the post process to add
  17659. */
  17660. addPostProcess(postProcess: PostProcess): void;
  17661. /**
  17662. * Clear all the post processes attached to the render target
  17663. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17664. */
  17665. clearPostProcesses(dispose?: boolean): void;
  17666. /**
  17667. * Remove one of the post process from the list of attached post processes to the texture
  17668. * @param postProcess define the post process to remove from the list
  17669. */
  17670. removePostProcess(postProcess: PostProcess): void;
  17671. /** @hidden */
  17672. _shouldRender(): boolean;
  17673. /**
  17674. * Gets the actual render size of the texture.
  17675. * @returns the width of the render size
  17676. */
  17677. getRenderSize(): number;
  17678. /**
  17679. * Gets the actual render width of the texture.
  17680. * @returns the width of the render size
  17681. */
  17682. getRenderWidth(): number;
  17683. /**
  17684. * Gets the actual render height of the texture.
  17685. * @returns the height of the render size
  17686. */
  17687. getRenderHeight(): number;
  17688. /**
  17689. * Get if the texture can be rescaled or not.
  17690. */
  17691. readonly canRescale: boolean;
  17692. /**
  17693. * Resize the texture using a ratio.
  17694. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17695. */
  17696. scale(ratio: number): void;
  17697. /**
  17698. * Get the texture reflection matrix used to rotate/transform the reflection.
  17699. * @returns the reflection matrix
  17700. */
  17701. getReflectionTextureMatrix(): Matrix;
  17702. /**
  17703. * Resize the texture to a new desired size.
  17704. * Be carrefull as it will recreate all the data in the new texture.
  17705. * @param size Define the new size. It can be:
  17706. * - a number for squared texture,
  17707. * - an object containing { width: number, height: number }
  17708. * - or an object containing a ratio { ratio: number }
  17709. */
  17710. resize(size: number | {
  17711. width: number;
  17712. height: number;
  17713. } | {
  17714. ratio: number;
  17715. }): void;
  17716. /**
  17717. * Renders all the objects from the render list into the texture.
  17718. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17719. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17720. */
  17721. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17722. private _bestReflectionRenderTargetDimension;
  17723. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17724. private renderToTarget;
  17725. /**
  17726. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17727. * This allowed control for front to back rendering or reversly depending of the special needs.
  17728. *
  17729. * @param renderingGroupId The rendering group id corresponding to its index
  17730. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17731. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17732. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17733. */
  17734. 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;
  17735. /**
  17736. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17737. *
  17738. * @param renderingGroupId The rendering group id corresponding to its index
  17739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17740. */
  17741. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17742. /**
  17743. * Clones the texture.
  17744. * @returns the cloned texture
  17745. */
  17746. clone(): RenderTargetTexture;
  17747. /**
  17748. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17749. * @returns The JSON representation of the texture
  17750. */
  17751. serialize(): any;
  17752. /**
  17753. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17754. */
  17755. disposeFramebufferObjects(): void;
  17756. /**
  17757. * Dispose the texture and release its associated resources.
  17758. */
  17759. dispose(): void;
  17760. /** @hidden */
  17761. _rebuild(): void;
  17762. /**
  17763. * Clear the info related to rendering groups preventing retention point in material dispose.
  17764. */
  17765. freeRenderingGroups(): void;
  17766. }
  17767. }
  17768. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17769. import { Scene } from "babylonjs/scene";
  17770. import { Plane } from "babylonjs/Maths/math";
  17771. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17772. /**
  17773. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17774. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17775. * You can then easily use it as a reflectionTexture on a flat surface.
  17776. * In case the surface is not a plane, please consider relying on reflection probes.
  17777. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17778. */
  17779. export class MirrorTexture extends RenderTargetTexture {
  17780. private scene;
  17781. /**
  17782. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17783. * 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.
  17784. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17785. */
  17786. mirrorPlane: Plane;
  17787. /**
  17788. * Define the blur ratio used to blur the reflection if needed.
  17789. */
  17790. blurRatio: number;
  17791. /**
  17792. * Define the adaptive blur kernel used to blur the reflection if needed.
  17793. * This will autocompute the closest best match for the `blurKernel`
  17794. */
  17795. adaptiveBlurKernel: number;
  17796. /**
  17797. * Define the blur kernel used to blur the reflection if needed.
  17798. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17799. */
  17800. blurKernel: number;
  17801. /**
  17802. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17803. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17804. */
  17805. blurKernelX: number;
  17806. /**
  17807. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17809. */
  17810. blurKernelY: number;
  17811. private _autoComputeBlurKernel;
  17812. protected _onRatioRescale(): void;
  17813. private _updateGammaSpace;
  17814. private _imageProcessingConfigChangeObserver;
  17815. private _transformMatrix;
  17816. private _mirrorMatrix;
  17817. private _savedViewMatrix;
  17818. private _blurX;
  17819. private _blurY;
  17820. private _adaptiveBlurKernel;
  17821. private _blurKernelX;
  17822. private _blurKernelY;
  17823. private _blurRatio;
  17824. /**
  17825. * Instantiates a Mirror Texture.
  17826. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17827. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17828. * You can then easily use it as a reflectionTexture on a flat surface.
  17829. * In case the surface is not a plane, please consider relying on reflection probes.
  17830. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17831. * @param name
  17832. * @param size
  17833. * @param scene
  17834. * @param generateMipMaps
  17835. * @param type
  17836. * @param samplingMode
  17837. * @param generateDepthBuffer
  17838. */
  17839. constructor(name: string, size: number | {
  17840. width: number;
  17841. height: number;
  17842. } | {
  17843. ratio: number;
  17844. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17845. private _preparePostProcesses;
  17846. /**
  17847. * Clone the mirror texture.
  17848. * @returns the cloned texture
  17849. */
  17850. clone(): MirrorTexture;
  17851. /**
  17852. * Serialize the texture to a JSON representation you could use in Parse later on
  17853. * @returns the serialized JSON representation
  17854. */
  17855. serialize(): any;
  17856. /**
  17857. * Dispose the texture and release its associated resources.
  17858. */
  17859. dispose(): void;
  17860. }
  17861. }
  17862. declare module "babylonjs/Materials/Textures/texture" {
  17863. import { Observable } from "babylonjs/Misc/observable";
  17864. import { Nullable } from "babylonjs/types";
  17865. import { Scene } from "babylonjs/scene";
  17866. import { Matrix } from "babylonjs/Maths/math";
  17867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17868. /**
  17869. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17870. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17871. */
  17872. export class Texture extends BaseTexture {
  17873. /** @hidden */
  17874. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17875. /** @hidden */
  17876. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17877. /** @hidden */
  17878. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17879. /** nearest is mag = nearest and min = nearest and mip = linear */
  17880. static readonly NEAREST_SAMPLINGMODE: number;
  17881. /** nearest is mag = nearest and min = nearest and mip = linear */
  17882. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17883. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17884. static readonly BILINEAR_SAMPLINGMODE: number;
  17885. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17886. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17887. /** Trilinear is mag = linear and min = linear and mip = linear */
  17888. static readonly TRILINEAR_SAMPLINGMODE: number;
  17889. /** Trilinear is mag = linear and min = linear and mip = linear */
  17890. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17891. /** mag = nearest and min = nearest and mip = nearest */
  17892. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17893. /** mag = nearest and min = linear and mip = nearest */
  17894. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17895. /** mag = nearest and min = linear and mip = linear */
  17896. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17897. /** mag = nearest and min = linear and mip = none */
  17898. static readonly NEAREST_LINEAR: number;
  17899. /** mag = nearest and min = nearest and mip = none */
  17900. static readonly NEAREST_NEAREST: number;
  17901. /** mag = linear and min = nearest and mip = nearest */
  17902. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17903. /** mag = linear and min = nearest and mip = linear */
  17904. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17905. /** mag = linear and min = linear and mip = none */
  17906. static readonly LINEAR_LINEAR: number;
  17907. /** mag = linear and min = nearest and mip = none */
  17908. static readonly LINEAR_NEAREST: number;
  17909. /** Explicit coordinates mode */
  17910. static readonly EXPLICIT_MODE: number;
  17911. /** Spherical coordinates mode */
  17912. static readonly SPHERICAL_MODE: number;
  17913. /** Planar coordinates mode */
  17914. static readonly PLANAR_MODE: number;
  17915. /** Cubic coordinates mode */
  17916. static readonly CUBIC_MODE: number;
  17917. /** Projection coordinates mode */
  17918. static readonly PROJECTION_MODE: number;
  17919. /** Inverse Cubic coordinates mode */
  17920. static readonly SKYBOX_MODE: number;
  17921. /** Inverse Cubic coordinates mode */
  17922. static readonly INVCUBIC_MODE: number;
  17923. /** Equirectangular coordinates mode */
  17924. static readonly EQUIRECTANGULAR_MODE: number;
  17925. /** Equirectangular Fixed coordinates mode */
  17926. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17927. /** Equirectangular Fixed Mirrored coordinates mode */
  17928. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17929. /** Texture is not repeating outside of 0..1 UVs */
  17930. static readonly CLAMP_ADDRESSMODE: number;
  17931. /** Texture is repeating outside of 0..1 UVs */
  17932. static readonly WRAP_ADDRESSMODE: number;
  17933. /** Texture is repeating and mirrored */
  17934. static readonly MIRROR_ADDRESSMODE: number;
  17935. /**
  17936. * 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
  17937. */
  17938. static UseSerializedUrlIfAny: boolean;
  17939. /**
  17940. * Define the url of the texture.
  17941. */
  17942. url: Nullable<string>;
  17943. /**
  17944. * Define an offset on the texture to offset the u coordinates of the UVs
  17945. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17946. */
  17947. uOffset: number;
  17948. /**
  17949. * Define an offset on the texture to offset the v coordinates of the UVs
  17950. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17951. */
  17952. vOffset: number;
  17953. /**
  17954. * Define an offset on the texture to scale the u coordinates of the UVs
  17955. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17956. */
  17957. uScale: number;
  17958. /**
  17959. * Define an offset on the texture to scale the v coordinates of the UVs
  17960. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17961. */
  17962. vScale: number;
  17963. /**
  17964. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17965. * @see http://doc.babylonjs.com/how_to/more_materials
  17966. */
  17967. uAng: number;
  17968. /**
  17969. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17970. * @see http://doc.babylonjs.com/how_to/more_materials
  17971. */
  17972. vAng: number;
  17973. /**
  17974. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17975. * @see http://doc.babylonjs.com/how_to/more_materials
  17976. */
  17977. wAng: number;
  17978. /**
  17979. * Defines the center of rotation (U)
  17980. */
  17981. uRotationCenter: number;
  17982. /**
  17983. * Defines the center of rotation (V)
  17984. */
  17985. vRotationCenter: number;
  17986. /**
  17987. * Defines the center of rotation (W)
  17988. */
  17989. wRotationCenter: number;
  17990. /**
  17991. * Are mip maps generated for this texture or not.
  17992. */
  17993. readonly noMipmap: boolean;
  17994. private _noMipmap;
  17995. /** @hidden */
  17996. _invertY: boolean;
  17997. private _rowGenerationMatrix;
  17998. private _cachedTextureMatrix;
  17999. private _projectionModeMatrix;
  18000. private _t0;
  18001. private _t1;
  18002. private _t2;
  18003. private _cachedUOffset;
  18004. private _cachedVOffset;
  18005. private _cachedUScale;
  18006. private _cachedVScale;
  18007. private _cachedUAng;
  18008. private _cachedVAng;
  18009. private _cachedWAng;
  18010. private _cachedProjectionMatrixId;
  18011. private _cachedCoordinatesMode;
  18012. /** @hidden */
  18013. protected _initialSamplingMode: number;
  18014. /** @hidden */
  18015. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18016. private _deleteBuffer;
  18017. protected _format: Nullable<number>;
  18018. private _delayedOnLoad;
  18019. private _delayedOnError;
  18020. /**
  18021. * Observable triggered once the texture has been loaded.
  18022. */
  18023. onLoadObservable: Observable<Texture>;
  18024. protected _isBlocking: boolean;
  18025. /**
  18026. * Is the texture preventing material to render while loading.
  18027. * If false, a default texture will be used instead of the loading one during the preparation step.
  18028. */
  18029. isBlocking: boolean;
  18030. /**
  18031. * Get the current sampling mode associated with the texture.
  18032. */
  18033. readonly samplingMode: number;
  18034. /**
  18035. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18036. */
  18037. readonly invertY: boolean;
  18038. /**
  18039. * Instantiates a new texture.
  18040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18041. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18042. * @param url define the url of the picture to load as a texture
  18043. * @param scene define the scene the texture will belong to
  18044. * @param noMipmap define if the texture will require mip maps or not
  18045. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18046. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18047. * @param onLoad define a callback triggered when the texture has been loaded
  18048. * @param onError define a callback triggered when an error occurred during the loading session
  18049. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18050. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18051. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18052. */
  18053. 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);
  18054. /**
  18055. * Update the url (and optional buffer) of this texture if url was null during construction.
  18056. * @param url the url of the texture
  18057. * @param buffer the buffer of the texture (defaults to null)
  18058. * @param onLoad callback called when the texture is loaded (defaults to null)
  18059. */
  18060. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18061. /**
  18062. * Finish the loading sequence of a texture flagged as delayed load.
  18063. * @hidden
  18064. */
  18065. delayLoad(): void;
  18066. private _prepareRowForTextureGeneration;
  18067. /**
  18068. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18069. * @returns the transform matrix of the texture.
  18070. */
  18071. getTextureMatrix(): Matrix;
  18072. /**
  18073. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18074. * @returns The reflection texture transform
  18075. */
  18076. getReflectionTextureMatrix(): Matrix;
  18077. /**
  18078. * Clones the texture.
  18079. * @returns the cloned texture
  18080. */
  18081. clone(): Texture;
  18082. /**
  18083. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18084. * @returns The JSON representation of the texture
  18085. */
  18086. serialize(): any;
  18087. /**
  18088. * Get the current class name of the texture useful for serialization or dynamic coding.
  18089. * @returns "Texture"
  18090. */
  18091. getClassName(): string;
  18092. /**
  18093. * Dispose the texture and release its associated resources.
  18094. */
  18095. dispose(): void;
  18096. /**
  18097. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18098. * @param parsedTexture Define the JSON representation of the texture
  18099. * @param scene Define the scene the parsed texture should be instantiated in
  18100. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18101. * @returns The parsed texture if successful
  18102. */
  18103. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18104. /**
  18105. * Creates a texture from its base 64 representation.
  18106. * @param data Define the base64 payload without the data: prefix
  18107. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18108. * @param scene Define the scene the texture should belong to
  18109. * @param noMipmap Forces the texture to not create mip map information if true
  18110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18112. * @param onLoad define a callback triggered when the texture has been loaded
  18113. * @param onError define a callback triggered when an error occurred during the loading session
  18114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18115. * @returns the created texture
  18116. */
  18117. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18118. /**
  18119. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18120. * @param data Define the base64 payload without the data: prefix
  18121. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18123. * @param scene Define the scene the texture should belong to
  18124. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18125. * @param noMipmap Forces the texture to not create mip map information if true
  18126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18128. * @param onLoad define a callback triggered when the texture has been loaded
  18129. * @param onError define a callback triggered when an error occurred during the loading session
  18130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18131. * @returns the created texture
  18132. */
  18133. 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;
  18134. }
  18135. }
  18136. declare module "babylonjs/Materials/shaderMaterial" {
  18137. import { Scene } from "babylonjs/scene";
  18138. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  18139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18140. import { Mesh } from "babylonjs/Meshes/mesh";
  18141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18142. import { Texture } from "babylonjs/Materials/Textures/texture";
  18143. import { Material } from "babylonjs/Materials/material";
  18144. /**
  18145. * Defines the options associated with the creation of a shader material.
  18146. */
  18147. export interface IShaderMaterialOptions {
  18148. /**
  18149. * Does the material work in alpha blend mode
  18150. */
  18151. needAlphaBlending: boolean;
  18152. /**
  18153. * Does the material work in alpha test mode
  18154. */
  18155. needAlphaTesting: boolean;
  18156. /**
  18157. * The list of attribute names used in the shader
  18158. */
  18159. attributes: string[];
  18160. /**
  18161. * The list of unifrom names used in the shader
  18162. */
  18163. uniforms: string[];
  18164. /**
  18165. * The list of UBO names used in the shader
  18166. */
  18167. uniformBuffers: string[];
  18168. /**
  18169. * The list of sampler names used in the shader
  18170. */
  18171. samplers: string[];
  18172. /**
  18173. * The list of defines used in the shader
  18174. */
  18175. defines: string[];
  18176. }
  18177. /**
  18178. * 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.
  18179. *
  18180. * This returned material effects how the mesh will look based on the code in the shaders.
  18181. *
  18182. * @see http://doc.babylonjs.com/how_to/shader_material
  18183. */
  18184. export class ShaderMaterial extends Material {
  18185. private _shaderPath;
  18186. private _options;
  18187. private _textures;
  18188. private _textureArrays;
  18189. private _floats;
  18190. private _ints;
  18191. private _floatsArrays;
  18192. private _colors3;
  18193. private _colors3Arrays;
  18194. private _colors4;
  18195. private _vectors2;
  18196. private _vectors3;
  18197. private _vectors4;
  18198. private _matrices;
  18199. private _matrices3x3;
  18200. private _matrices2x2;
  18201. private _vectors2Arrays;
  18202. private _vectors3Arrays;
  18203. private _cachedWorldViewMatrix;
  18204. private _renderId;
  18205. /**
  18206. * Instantiate a new shader material.
  18207. * 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.
  18208. * This returned material effects how the mesh will look based on the code in the shaders.
  18209. * @see http://doc.babylonjs.com/how_to/shader_material
  18210. * @param name Define the name of the material in the scene
  18211. * @param scene Define the scene the material belongs to
  18212. * @param shaderPath Defines the route to the shader code in one of three ways:
  18213. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18214. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18215. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18216. * @param options Define the options used to create the shader
  18217. */
  18218. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18219. /**
  18220. * Gets the current class name of the material e.g. "ShaderMaterial"
  18221. * Mainly use in serialization.
  18222. * @returns the class name
  18223. */
  18224. getClassName(): string;
  18225. /**
  18226. * Specifies if the material will require alpha blending
  18227. * @returns a boolean specifying if alpha blending is needed
  18228. */
  18229. needAlphaBlending(): boolean;
  18230. /**
  18231. * Specifies if this material should be rendered in alpha test mode
  18232. * @returns a boolean specifying if an alpha test is needed.
  18233. */
  18234. needAlphaTesting(): boolean;
  18235. private _checkUniform;
  18236. /**
  18237. * Set a texture in the shader.
  18238. * @param name Define the name of the uniform samplers as defined in the shader
  18239. * @param texture Define the texture to bind to this sampler
  18240. * @return the material itself allowing "fluent" like uniform updates
  18241. */
  18242. setTexture(name: string, texture: Texture): ShaderMaterial;
  18243. /**
  18244. * Set a texture array in the shader.
  18245. * @param name Define the name of the uniform sampler array as defined in the shader
  18246. * @param textures Define the list of textures to bind to this sampler
  18247. * @return the material itself allowing "fluent" like uniform updates
  18248. */
  18249. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18250. /**
  18251. * Set a float in the shader.
  18252. * @param name Define the name of the uniform as defined in the shader
  18253. * @param value Define the value to give to the uniform
  18254. * @return the material itself allowing "fluent" like uniform updates
  18255. */
  18256. setFloat(name: string, value: number): ShaderMaterial;
  18257. /**
  18258. * Set a int in the shader.
  18259. * @param name Define the name of the uniform as defined in the shader
  18260. * @param value Define the value to give to the uniform
  18261. * @return the material itself allowing "fluent" like uniform updates
  18262. */
  18263. setInt(name: string, value: number): ShaderMaterial;
  18264. /**
  18265. * Set an array of floats in the shader.
  18266. * @param name Define the name of the uniform as defined in the shader
  18267. * @param value Define the value to give to the uniform
  18268. * @return the material itself allowing "fluent" like uniform updates
  18269. */
  18270. setFloats(name: string, value: number[]): ShaderMaterial;
  18271. /**
  18272. * Set a vec3 in the shader from a Color3.
  18273. * @param name Define the name of the uniform as defined in the shader
  18274. * @param value Define the value to give to the uniform
  18275. * @return the material itself allowing "fluent" like uniform updates
  18276. */
  18277. setColor3(name: string, value: Color3): ShaderMaterial;
  18278. /**
  18279. * Set a vec3 array in the shader from a Color3 array.
  18280. * @param name Define the name of the uniform as defined in the shader
  18281. * @param value Define the value to give to the uniform
  18282. * @return the material itself allowing "fluent" like uniform updates
  18283. */
  18284. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18285. /**
  18286. * Set a vec4 in the shader from a Color4.
  18287. * @param name Define the name of the uniform as defined in the shader
  18288. * @param value Define the value to give to the uniform
  18289. * @return the material itself allowing "fluent" like uniform updates
  18290. */
  18291. setColor4(name: string, value: Color4): ShaderMaterial;
  18292. /**
  18293. * Set a vec2 in the shader from a Vector2.
  18294. * @param name Define the name of the uniform as defined in the shader
  18295. * @param value Define the value to give to the uniform
  18296. * @return the material itself allowing "fluent" like uniform updates
  18297. */
  18298. setVector2(name: string, value: Vector2): ShaderMaterial;
  18299. /**
  18300. * Set a vec3 in the shader from a Vector3.
  18301. * @param name Define the name of the uniform as defined in the shader
  18302. * @param value Define the value to give to the uniform
  18303. * @return the material itself allowing "fluent" like uniform updates
  18304. */
  18305. setVector3(name: string, value: Vector3): ShaderMaterial;
  18306. /**
  18307. * Set a vec4 in the shader from a Vector4.
  18308. * @param name Define the name of the uniform as defined in the shader
  18309. * @param value Define the value to give to the uniform
  18310. * @return the material itself allowing "fluent" like uniform updates
  18311. */
  18312. setVector4(name: string, value: Vector4): ShaderMaterial;
  18313. /**
  18314. * Set a mat4 in the shader from a Matrix.
  18315. * @param name Define the name of the uniform as defined in the shader
  18316. * @param value Define the value to give to the uniform
  18317. * @return the material itself allowing "fluent" like uniform updates
  18318. */
  18319. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18320. /**
  18321. * Set a mat3 in the shader from a Float32Array.
  18322. * @param name Define the name of the uniform as defined in the shader
  18323. * @param value Define the value to give to the uniform
  18324. * @return the material itself allowing "fluent" like uniform updates
  18325. */
  18326. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18327. /**
  18328. * Set a mat2 in the shader from a Float32Array.
  18329. * @param name Define the name of the uniform as defined in the shader
  18330. * @param value Define the value to give to the uniform
  18331. * @return the material itself allowing "fluent" like uniform updates
  18332. */
  18333. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18334. /**
  18335. * Set a vec2 array in the shader from a number array.
  18336. * @param name Define the name of the uniform as defined in the shader
  18337. * @param value Define the value to give to the uniform
  18338. * @return the material itself allowing "fluent" like uniform updates
  18339. */
  18340. setArray2(name: string, value: number[]): ShaderMaterial;
  18341. /**
  18342. * Set a vec3 array in the shader from a number array.
  18343. * @param name Define the name of the uniform as defined in the shader
  18344. * @param value Define the value to give to the uniform
  18345. * @return the material itself allowing "fluent" like uniform updates
  18346. */
  18347. setArray3(name: string, value: number[]): ShaderMaterial;
  18348. private _checkCache;
  18349. /**
  18350. * Checks if the material is ready to render the requested mesh
  18351. * @param mesh Define the mesh to render
  18352. * @param useInstances Define whether or not the material is used with instances
  18353. * @returns true if ready, otherwise false
  18354. */
  18355. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18356. /**
  18357. * Binds the world matrix to the material
  18358. * @param world defines the world transformation matrix
  18359. */
  18360. bindOnlyWorldMatrix(world: Matrix): void;
  18361. /**
  18362. * Binds the material to the mesh
  18363. * @param world defines the world transformation matrix
  18364. * @param mesh defines the mesh to bind the material to
  18365. */
  18366. bind(world: Matrix, mesh?: Mesh): void;
  18367. /**
  18368. * Gets the active textures from the material
  18369. * @returns an array of textures
  18370. */
  18371. getActiveTextures(): BaseTexture[];
  18372. /**
  18373. * Specifies if the material uses a texture
  18374. * @param texture defines the texture to check against the material
  18375. * @returns a boolean specifying if the material uses the texture
  18376. */
  18377. hasTexture(texture: BaseTexture): boolean;
  18378. /**
  18379. * Makes a duplicate of the material, and gives it a new name
  18380. * @param name defines the new name for the duplicated material
  18381. * @returns the cloned material
  18382. */
  18383. clone(name: string): ShaderMaterial;
  18384. /**
  18385. * Disposes the material
  18386. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18387. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18388. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18389. */
  18390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18391. /**
  18392. * Serializes this material in a JSON representation
  18393. * @returns the serialized material object
  18394. */
  18395. serialize(): any;
  18396. /**
  18397. * Creates a shader material from parsed shader material data
  18398. * @param source defines the JSON represnetation of the material
  18399. * @param scene defines the hosting scene
  18400. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18401. * @returns a new material
  18402. */
  18403. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18404. }
  18405. }
  18406. declare module "babylonjs/Shaders/color.fragment" {
  18407. /** @hidden */
  18408. export var colorPixelShader: {
  18409. name: string;
  18410. shader: string;
  18411. };
  18412. }
  18413. declare module "babylonjs/Shaders/color.vertex" {
  18414. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  18415. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  18416. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  18417. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  18418. /** @hidden */
  18419. export var colorVertexShader: {
  18420. name: string;
  18421. shader: string;
  18422. };
  18423. }
  18424. declare module "babylonjs/Meshes/linesMesh" {
  18425. import { Nullable } from "babylonjs/types";
  18426. import { Scene } from "babylonjs/scene";
  18427. import { Color3 } from "babylonjs/Maths/math";
  18428. import { Node } from "babylonjs/node";
  18429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18430. import { Mesh } from "babylonjs/Meshes/mesh";
  18431. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Material } from "babylonjs/Materials/material";
  18434. import "babylonjs/Shaders/color.fragment";
  18435. import "babylonjs/Shaders/color.vertex";
  18436. /**
  18437. * Line mesh
  18438. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18439. */
  18440. export class LinesMesh extends Mesh {
  18441. /**
  18442. * If vertex color should be applied to the mesh
  18443. */
  18444. useVertexColor?: boolean | undefined;
  18445. /**
  18446. * If vertex alpha should be applied to the mesh
  18447. */
  18448. useVertexAlpha?: boolean | undefined;
  18449. /**
  18450. * Color of the line (Default: White)
  18451. */
  18452. color: Color3;
  18453. /**
  18454. * Alpha of the line (Default: 1)
  18455. */
  18456. alpha: number;
  18457. /**
  18458. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18459. * This margin is expressed in world space coordinates, so its value may vary.
  18460. * Default value is 0.1
  18461. */
  18462. intersectionThreshold: number;
  18463. private _colorShader;
  18464. /**
  18465. * Creates a new LinesMesh
  18466. * @param name defines the name
  18467. * @param scene defines the hosting scene
  18468. * @param parent defines the parent mesh if any
  18469. * @param source defines the optional source LinesMesh used to clone data from
  18470. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18471. * When false, achieved by calling a clone(), also passing False.
  18472. * This will make creation of children, recursive.
  18473. * @param useVertexColor defines if this LinesMesh supports vertex color
  18474. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18475. */
  18476. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18477. /**
  18478. * If vertex color should be applied to the mesh
  18479. */
  18480. useVertexColor?: boolean | undefined,
  18481. /**
  18482. * If vertex alpha should be applied to the mesh
  18483. */
  18484. useVertexAlpha?: boolean | undefined);
  18485. /**
  18486. * Returns the string "LineMesh"
  18487. */
  18488. getClassName(): string;
  18489. /**
  18490. * @hidden
  18491. */
  18492. /**
  18493. * @hidden
  18494. */
  18495. material: Material;
  18496. /**
  18497. * @hidden
  18498. */
  18499. readonly checkCollisions: boolean;
  18500. /** @hidden */
  18501. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18502. /** @hidden */
  18503. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18504. /**
  18505. * Disposes of the line mesh
  18506. * @param doNotRecurse If children should be disposed
  18507. */
  18508. dispose(doNotRecurse?: boolean): void;
  18509. /**
  18510. * Returns a new LineMesh object cloned from the current one.
  18511. */
  18512. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18513. /**
  18514. * Creates a new InstancedLinesMesh object from the mesh model.
  18515. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18516. * @param name defines the name of the new instance
  18517. * @returns a new InstancedLinesMesh
  18518. */
  18519. createInstance(name: string): InstancedLinesMesh;
  18520. }
  18521. /**
  18522. * Creates an instance based on a source LinesMesh
  18523. */
  18524. export class InstancedLinesMesh extends InstancedMesh {
  18525. /**
  18526. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18527. * This margin is expressed in world space coordinates, so its value may vary.
  18528. * Initilized with the intersectionThreshold value of the source LinesMesh
  18529. */
  18530. intersectionThreshold: number;
  18531. constructor(name: string, source: LinesMesh);
  18532. /**
  18533. * Returns the string "InstancedLinesMesh".
  18534. */
  18535. getClassName(): string;
  18536. }
  18537. }
  18538. declare module "babylonjs/Meshes/groundMesh" {
  18539. import { Scene } from "babylonjs/scene";
  18540. import { Vector3 } from "babylonjs/Maths/math";
  18541. import { Mesh } from "babylonjs/Meshes/mesh";
  18542. /**
  18543. * Mesh representing the gorund
  18544. */
  18545. export class GroundMesh extends Mesh {
  18546. /** If octree should be generated */
  18547. generateOctree: boolean;
  18548. private _heightQuads;
  18549. /** @hidden */
  18550. _subdivisionsX: number;
  18551. /** @hidden */
  18552. _subdivisionsY: number;
  18553. /** @hidden */
  18554. _width: number;
  18555. /** @hidden */
  18556. _height: number;
  18557. /** @hidden */
  18558. _minX: number;
  18559. /** @hidden */
  18560. _maxX: number;
  18561. /** @hidden */
  18562. _minZ: number;
  18563. /** @hidden */
  18564. _maxZ: number;
  18565. constructor(name: string, scene: Scene);
  18566. /**
  18567. * "GroundMesh"
  18568. * @returns "GroundMesh"
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * The minimum of x and y subdivisions
  18573. */
  18574. readonly subdivisions: number;
  18575. /**
  18576. * X subdivisions
  18577. */
  18578. readonly subdivisionsX: number;
  18579. /**
  18580. * Y subdivisions
  18581. */
  18582. readonly subdivisionsY: number;
  18583. /**
  18584. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18585. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18586. * @param chunksCount the number of subdivisions for x and y
  18587. * @param octreeBlocksSize (Default: 32)
  18588. */
  18589. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18590. /**
  18591. * Returns a height (y) value in the Worl system :
  18592. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18593. * @param x x coordinate
  18594. * @param z z coordinate
  18595. * @returns the ground y position if (x, z) are outside the ground surface.
  18596. */
  18597. getHeightAtCoordinates(x: number, z: number): number;
  18598. /**
  18599. * Returns a normalized vector (Vector3) orthogonal to the ground
  18600. * at the ground coordinates (x, z) expressed in the World system.
  18601. * @param x x coordinate
  18602. * @param z z coordinate
  18603. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18604. */
  18605. getNormalAtCoordinates(x: number, z: number): Vector3;
  18606. /**
  18607. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18608. * at the ground coordinates (x, z) expressed in the World system.
  18609. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18610. * @param x x coordinate
  18611. * @param z z coordinate
  18612. * @param ref vector to store the result
  18613. * @returns the GroundMesh.
  18614. */
  18615. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18616. /**
  18617. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18618. * if the ground has been updated.
  18619. * This can be used in the render loop.
  18620. * @returns the GroundMesh.
  18621. */
  18622. updateCoordinateHeights(): GroundMesh;
  18623. private _getFacetAt;
  18624. private _initHeightQuads;
  18625. private _computeHeightQuads;
  18626. /**
  18627. * Serializes this ground mesh
  18628. * @param serializationObject object to write serialization to
  18629. */
  18630. serialize(serializationObject: any): void;
  18631. /**
  18632. * Parses a serialized ground mesh
  18633. * @param parsedMesh the serialized mesh
  18634. * @param scene the scene to create the ground mesh in
  18635. * @returns the created ground mesh
  18636. */
  18637. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18638. }
  18639. }
  18640. declare module "babylonjs/Physics/physicsJoint" {
  18641. import { Vector3 } from "babylonjs/Maths/math";
  18642. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18643. /**
  18644. * Interface for Physics-Joint data
  18645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18646. */
  18647. export interface PhysicsJointData {
  18648. /**
  18649. * The main pivot of the joint
  18650. */
  18651. mainPivot?: Vector3;
  18652. /**
  18653. * The connected pivot of the joint
  18654. */
  18655. connectedPivot?: Vector3;
  18656. /**
  18657. * The main axis of the joint
  18658. */
  18659. mainAxis?: Vector3;
  18660. /**
  18661. * The connected axis of the joint
  18662. */
  18663. connectedAxis?: Vector3;
  18664. /**
  18665. * The collision of the joint
  18666. */
  18667. collision?: boolean;
  18668. /**
  18669. * Native Oimo/Cannon/Energy data
  18670. */
  18671. nativeParams?: any;
  18672. }
  18673. /**
  18674. * This is a holder class for the physics joint created by the physics plugin
  18675. * It holds a set of functions to control the underlying joint
  18676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18677. */
  18678. export class PhysicsJoint {
  18679. /**
  18680. * The type of the physics joint
  18681. */
  18682. type: number;
  18683. /**
  18684. * The data for the physics joint
  18685. */
  18686. jointData: PhysicsJointData;
  18687. private _physicsJoint;
  18688. protected _physicsPlugin: IPhysicsEnginePlugin;
  18689. /**
  18690. * Initializes the physics joint
  18691. * @param type The type of the physics joint
  18692. * @param jointData The data for the physics joint
  18693. */
  18694. constructor(
  18695. /**
  18696. * The type of the physics joint
  18697. */
  18698. type: number,
  18699. /**
  18700. * The data for the physics joint
  18701. */
  18702. jointData: PhysicsJointData);
  18703. /**
  18704. * Gets the physics joint
  18705. */
  18706. /**
  18707. * Sets the physics joint
  18708. */
  18709. physicsJoint: any;
  18710. /**
  18711. * Sets the physics plugin
  18712. */
  18713. physicsPlugin: IPhysicsEnginePlugin;
  18714. /**
  18715. * Execute a function that is physics-plugin specific.
  18716. * @param {Function} func the function that will be executed.
  18717. * It accepts two parameters: the physics world and the physics joint
  18718. */
  18719. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18720. /**
  18721. * Distance-Joint type
  18722. */
  18723. static DistanceJoint: number;
  18724. /**
  18725. * Hinge-Joint type
  18726. */
  18727. static HingeJoint: number;
  18728. /**
  18729. * Ball-and-Socket joint type
  18730. */
  18731. static BallAndSocketJoint: number;
  18732. /**
  18733. * Wheel-Joint type
  18734. */
  18735. static WheelJoint: number;
  18736. /**
  18737. * Slider-Joint type
  18738. */
  18739. static SliderJoint: number;
  18740. /**
  18741. * Prismatic-Joint type
  18742. */
  18743. static PrismaticJoint: number;
  18744. /**
  18745. * Universal-Joint type
  18746. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18747. */
  18748. static UniversalJoint: number;
  18749. /**
  18750. * Hinge-Joint 2 type
  18751. */
  18752. static Hinge2Joint: number;
  18753. /**
  18754. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18755. */
  18756. static PointToPointJoint: number;
  18757. /**
  18758. * Spring-Joint type
  18759. */
  18760. static SpringJoint: number;
  18761. /**
  18762. * Lock-Joint type
  18763. */
  18764. static LockJoint: number;
  18765. }
  18766. /**
  18767. * A class representing a physics distance joint
  18768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18769. */
  18770. export class DistanceJoint extends PhysicsJoint {
  18771. /**
  18772. *
  18773. * @param jointData The data for the Distance-Joint
  18774. */
  18775. constructor(jointData: DistanceJointData);
  18776. /**
  18777. * Update the predefined distance.
  18778. * @param maxDistance The maximum preferred distance
  18779. * @param minDistance The minimum preferred distance
  18780. */
  18781. updateDistance(maxDistance: number, minDistance?: number): void;
  18782. }
  18783. /**
  18784. * Represents a Motor-Enabled Joint
  18785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18786. */
  18787. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18788. /**
  18789. * Initializes the Motor-Enabled Joint
  18790. * @param type The type of the joint
  18791. * @param jointData The physica joint data for the joint
  18792. */
  18793. constructor(type: number, jointData: PhysicsJointData);
  18794. /**
  18795. * Set the motor values.
  18796. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18797. * @param force the force to apply
  18798. * @param maxForce max force for this motor.
  18799. */
  18800. setMotor(force?: number, maxForce?: number): void;
  18801. /**
  18802. * Set the motor's limits.
  18803. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18804. * @param upperLimit The upper limit of the motor
  18805. * @param lowerLimit The lower limit of the motor
  18806. */
  18807. setLimit(upperLimit: number, lowerLimit?: number): void;
  18808. }
  18809. /**
  18810. * This class represents a single physics Hinge-Joint
  18811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18812. */
  18813. export class HingeJoint extends MotorEnabledJoint {
  18814. /**
  18815. * Initializes the Hinge-Joint
  18816. * @param jointData The joint data for the Hinge-Joint
  18817. */
  18818. constructor(jointData: PhysicsJointData);
  18819. /**
  18820. * Set the motor values.
  18821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18822. * @param {number} force the force to apply
  18823. * @param {number} maxForce max force for this motor.
  18824. */
  18825. setMotor(force?: number, maxForce?: number): void;
  18826. /**
  18827. * Set the motor's limits.
  18828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18829. * @param upperLimit The upper limit of the motor
  18830. * @param lowerLimit The lower limit of the motor
  18831. */
  18832. setLimit(upperLimit: number, lowerLimit?: number): void;
  18833. }
  18834. /**
  18835. * This class represents a dual hinge physics joint (same as wheel joint)
  18836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18837. */
  18838. export class Hinge2Joint extends MotorEnabledJoint {
  18839. /**
  18840. * Initializes the Hinge2-Joint
  18841. * @param jointData The joint data for the Hinge2-Joint
  18842. */
  18843. constructor(jointData: PhysicsJointData);
  18844. /**
  18845. * Set the motor values.
  18846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18847. * @param {number} targetSpeed the speed the motor is to reach
  18848. * @param {number} maxForce max force for this motor.
  18849. * @param {motorIndex} the motor's index, 0 or 1.
  18850. */
  18851. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  18852. /**
  18853. * Set the motor limits.
  18854. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18855. * @param {number} upperLimit the upper limit
  18856. * @param {number} lowerLimit lower limit
  18857. * @param {motorIndex} the motor's index, 0 or 1.
  18858. */
  18859. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18860. }
  18861. /**
  18862. * Interface for a motor enabled joint
  18863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18864. */
  18865. export interface IMotorEnabledJoint {
  18866. /**
  18867. * Physics joint
  18868. */
  18869. physicsJoint: any;
  18870. /**
  18871. * Sets the motor of the motor-enabled joint
  18872. * @param force The force of the motor
  18873. * @param maxForce The maximum force of the motor
  18874. * @param motorIndex The index of the motor
  18875. */
  18876. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18877. /**
  18878. * Sets the limit of the motor
  18879. * @param upperLimit The upper limit of the motor
  18880. * @param lowerLimit The lower limit of the motor
  18881. * @param motorIndex The index of the motor
  18882. */
  18883. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18884. }
  18885. /**
  18886. * Joint data for a Distance-Joint
  18887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18888. */
  18889. export interface DistanceJointData extends PhysicsJointData {
  18890. /**
  18891. * Max distance the 2 joint objects can be apart
  18892. */
  18893. maxDistance: number;
  18894. }
  18895. /**
  18896. * Joint data from a spring joint
  18897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18898. */
  18899. export interface SpringJointData extends PhysicsJointData {
  18900. /**
  18901. * Length of the spring
  18902. */
  18903. length: number;
  18904. /**
  18905. * Stiffness of the spring
  18906. */
  18907. stiffness: number;
  18908. /**
  18909. * Damping of the spring
  18910. */
  18911. damping: number;
  18912. /** this callback will be called when applying the force to the impostors. */
  18913. forceApplicationCallback: () => void;
  18914. }
  18915. }
  18916. declare module "babylonjs/Physics/IPhysicsEngine" {
  18917. import { Nullable } from "babylonjs/types";
  18918. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18920. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18921. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18922. /**
  18923. * Interface used to describe a physics joint
  18924. */
  18925. export interface PhysicsImpostorJoint {
  18926. /** Defines the main impostor to which the joint is linked */
  18927. mainImpostor: PhysicsImpostor;
  18928. /** Defines the impostor that is connected to the main impostor using this joint */
  18929. connectedImpostor: PhysicsImpostor;
  18930. /** Defines the joint itself */
  18931. joint: PhysicsJoint;
  18932. }
  18933. /** @hidden */
  18934. export interface IPhysicsEnginePlugin {
  18935. world: any;
  18936. name: string;
  18937. setGravity(gravity: Vector3): void;
  18938. setTimeStep(timeStep: number): void;
  18939. getTimeStep(): number;
  18940. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18941. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18942. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18943. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18944. removePhysicsBody(impostor: PhysicsImpostor): void;
  18945. generateJoint(joint: PhysicsImpostorJoint): void;
  18946. removeJoint(joint: PhysicsImpostorJoint): void;
  18947. isSupported(): boolean;
  18948. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18949. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18950. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18951. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18952. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18953. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18954. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18955. getBodyMass(impostor: PhysicsImpostor): number;
  18956. getBodyFriction(impostor: PhysicsImpostor): number;
  18957. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18958. getBodyRestitution(impostor: PhysicsImpostor): number;
  18959. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18960. sleepBody(impostor: PhysicsImpostor): void;
  18961. wakeUpBody(impostor: PhysicsImpostor): void;
  18962. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18963. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18964. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18965. getRadius(impostor: PhysicsImpostor): number;
  18966. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18968. dispose(): void;
  18969. }
  18970. /**
  18971. * Interface used to define a physics engine
  18972. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18973. */
  18974. export interface IPhysicsEngine {
  18975. /**
  18976. * Gets the gravity vector used by the simulation
  18977. */
  18978. gravity: Vector3;
  18979. /**
  18980. * Sets the gravity vector used by the simulation
  18981. * @param gravity defines the gravity vector to use
  18982. */
  18983. setGravity(gravity: Vector3): void;
  18984. /**
  18985. * Set the time step of the physics engine.
  18986. * Default is 1/60.
  18987. * To slow it down, enter 1/600 for example.
  18988. * To speed it up, 1/30
  18989. * @param newTimeStep the new timestep to apply to this world.
  18990. */
  18991. setTimeStep(newTimeStep: number): void;
  18992. /**
  18993. * Get the time step of the physics engine.
  18994. * @returns the current time step
  18995. */
  18996. getTimeStep(): number;
  18997. /**
  18998. * Release all resources
  18999. */
  19000. dispose(): void;
  19001. /**
  19002. * Gets the name of the current physics plugin
  19003. * @returns the name of the plugin
  19004. */
  19005. getPhysicsPluginName(): string;
  19006. /**
  19007. * Adding a new impostor for the impostor tracking.
  19008. * This will be done by the impostor itself.
  19009. * @param impostor the impostor to add
  19010. */
  19011. addImpostor(impostor: PhysicsImpostor): void;
  19012. /**
  19013. * Remove an impostor from the engine.
  19014. * This impostor and its mesh will not longer be updated by the physics engine.
  19015. * @param impostor the impostor to remove
  19016. */
  19017. removeImpostor(impostor: PhysicsImpostor): void;
  19018. /**
  19019. * Add a joint to the physics engine
  19020. * @param mainImpostor defines the main impostor to which the joint is added.
  19021. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19022. * @param joint defines the joint that will connect both impostors.
  19023. */
  19024. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19025. /**
  19026. * Removes a joint from the simulation
  19027. * @param mainImpostor defines the impostor used with the joint
  19028. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19029. * @param joint defines the joint to remove
  19030. */
  19031. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19032. /**
  19033. * Gets the current plugin used to run the simulation
  19034. * @returns current plugin
  19035. */
  19036. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19037. /**
  19038. * Gets the list of physic impostors
  19039. * @returns an array of PhysicsImpostor
  19040. */
  19041. getImpostors(): Array<PhysicsImpostor>;
  19042. /**
  19043. * Gets the impostor for a physics enabled object
  19044. * @param object defines the object impersonated by the impostor
  19045. * @returns the PhysicsImpostor or null if not found
  19046. */
  19047. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19048. /**
  19049. * Gets the impostor for a physics body object
  19050. * @param body defines physics body used by the impostor
  19051. * @returns the PhysicsImpostor or null if not found
  19052. */
  19053. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19054. /**
  19055. * Called by the scene. No need to call it.
  19056. * @param delta defines the timespam between frames
  19057. */
  19058. _step(delta: number): void;
  19059. }
  19060. }
  19061. declare module "babylonjs/Physics/physicsImpostor" {
  19062. import { Nullable, IndicesArray } from "babylonjs/types";
  19063. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19064. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19066. import { Scene } from "babylonjs/scene";
  19067. import { Bone } from "babylonjs/Bones/bone";
  19068. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19069. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19070. /**
  19071. * The interface for the physics imposter parameters
  19072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19073. */
  19074. export interface PhysicsImpostorParameters {
  19075. /**
  19076. * The mass of the physics imposter
  19077. */
  19078. mass: number;
  19079. /**
  19080. * The friction of the physics imposter
  19081. */
  19082. friction?: number;
  19083. /**
  19084. * The coefficient of restitution of the physics imposter
  19085. */
  19086. restitution?: number;
  19087. /**
  19088. * The native options of the physics imposter
  19089. */
  19090. nativeOptions?: any;
  19091. /**
  19092. * Specifies if the parent should be ignored
  19093. */
  19094. ignoreParent?: boolean;
  19095. /**
  19096. * Specifies if bi-directional transformations should be disabled
  19097. */
  19098. disableBidirectionalTransformation?: boolean;
  19099. }
  19100. /**
  19101. * Interface for a physics-enabled object
  19102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19103. */
  19104. export interface IPhysicsEnabledObject {
  19105. /**
  19106. * The position of the physics-enabled object
  19107. */
  19108. position: Vector3;
  19109. /**
  19110. * The rotation of the physics-enabled object
  19111. */
  19112. rotationQuaternion: Nullable<Quaternion>;
  19113. /**
  19114. * The scale of the physics-enabled object
  19115. */
  19116. scaling: Vector3;
  19117. /**
  19118. * The rotation of the physics-enabled object
  19119. */
  19120. rotation?: Vector3;
  19121. /**
  19122. * The parent of the physics-enabled object
  19123. */
  19124. parent?: any;
  19125. /**
  19126. * The bounding info of the physics-enabled object
  19127. * @returns The bounding info of the physics-enabled object
  19128. */
  19129. getBoundingInfo(): BoundingInfo;
  19130. /**
  19131. * Computes the world matrix
  19132. * @param force Specifies if the world matrix should be computed by force
  19133. * @returns A world matrix
  19134. */
  19135. computeWorldMatrix(force: boolean): Matrix;
  19136. /**
  19137. * Gets the world matrix
  19138. * @returns A world matrix
  19139. */
  19140. getWorldMatrix?(): Matrix;
  19141. /**
  19142. * Gets the child meshes
  19143. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19144. * @returns An array of abstract meshes
  19145. */
  19146. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19147. /**
  19148. * Gets the vertex data
  19149. * @param kind The type of vertex data
  19150. * @returns A nullable array of numbers, or a float32 array
  19151. */
  19152. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19153. /**
  19154. * Gets the indices from the mesh
  19155. * @returns A nullable array of index arrays
  19156. */
  19157. getIndices?(): Nullable<IndicesArray>;
  19158. /**
  19159. * Gets the scene from the mesh
  19160. * @returns the indices array or null
  19161. */
  19162. getScene?(): Scene;
  19163. /**
  19164. * Gets the absolute position from the mesh
  19165. * @returns the absolute position
  19166. */
  19167. getAbsolutePosition(): Vector3;
  19168. /**
  19169. * Gets the absolute pivot point from the mesh
  19170. * @returns the absolute pivot point
  19171. */
  19172. getAbsolutePivotPoint(): Vector3;
  19173. /**
  19174. * Rotates the mesh
  19175. * @param axis The axis of rotation
  19176. * @param amount The amount of rotation
  19177. * @param space The space of the rotation
  19178. * @returns The rotation transform node
  19179. */
  19180. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19181. /**
  19182. * Translates the mesh
  19183. * @param axis The axis of translation
  19184. * @param distance The distance of translation
  19185. * @param space The space of the translation
  19186. * @returns The transform node
  19187. */
  19188. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19189. /**
  19190. * Sets the absolute position of the mesh
  19191. * @param absolutePosition The absolute position of the mesh
  19192. * @returns The transform node
  19193. */
  19194. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19195. /**
  19196. * Gets the class name of the mesh
  19197. * @returns The class name
  19198. */
  19199. getClassName(): string;
  19200. }
  19201. /**
  19202. * Represents a physics imposter
  19203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19204. */
  19205. export class PhysicsImpostor {
  19206. /**
  19207. * The physics-enabled object used as the physics imposter
  19208. */
  19209. object: IPhysicsEnabledObject;
  19210. /**
  19211. * The type of the physics imposter
  19212. */
  19213. type: number;
  19214. private _options;
  19215. private _scene?;
  19216. /**
  19217. * The default object size of the imposter
  19218. */
  19219. static DEFAULT_OBJECT_SIZE: Vector3;
  19220. /**
  19221. * The identity quaternion of the imposter
  19222. */
  19223. static IDENTITY_QUATERNION: Quaternion;
  19224. /** @hidden */
  19225. _pluginData: any;
  19226. private _physicsEngine;
  19227. private _physicsBody;
  19228. private _bodyUpdateRequired;
  19229. private _onBeforePhysicsStepCallbacks;
  19230. private _onAfterPhysicsStepCallbacks;
  19231. /** @hidden */
  19232. _onPhysicsCollideCallbacks: Array<{
  19233. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19234. otherImpostors: Array<PhysicsImpostor>;
  19235. }>;
  19236. private _deltaPosition;
  19237. private _deltaRotation;
  19238. private _deltaRotationConjugated;
  19239. private _parent;
  19240. private _isDisposed;
  19241. private static _tmpVecs;
  19242. private static _tmpQuat;
  19243. /**
  19244. * Specifies if the physics imposter is disposed
  19245. */
  19246. readonly isDisposed: boolean;
  19247. /**
  19248. * Gets the mass of the physics imposter
  19249. */
  19250. mass: number;
  19251. /**
  19252. * Gets the coefficient of friction
  19253. */
  19254. /**
  19255. * Sets the coefficient of friction
  19256. */
  19257. friction: number;
  19258. /**
  19259. * Gets the coefficient of restitution
  19260. */
  19261. /**
  19262. * Sets the coefficient of restitution
  19263. */
  19264. restitution: number;
  19265. /**
  19266. * The unique id of the physics imposter
  19267. * set by the physics engine when adding this impostor to the array
  19268. */
  19269. uniqueId: number;
  19270. private _joints;
  19271. /**
  19272. * Initializes the physics imposter
  19273. * @param object The physics-enabled object used as the physics imposter
  19274. * @param type The type of the physics imposter
  19275. * @param _options The options for the physics imposter
  19276. * @param _scene The Babylon scene
  19277. */
  19278. constructor(
  19279. /**
  19280. * The physics-enabled object used as the physics imposter
  19281. */
  19282. object: IPhysicsEnabledObject,
  19283. /**
  19284. * The type of the physics imposter
  19285. */
  19286. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19287. /**
  19288. * This function will completly initialize this impostor.
  19289. * It will create a new body - but only if this mesh has no parent.
  19290. * If it has, this impostor will not be used other than to define the impostor
  19291. * of the child mesh.
  19292. * @hidden
  19293. */
  19294. _init(): void;
  19295. private _getPhysicsParent;
  19296. /**
  19297. * Should a new body be generated.
  19298. * @returns boolean specifying if body initialization is required
  19299. */
  19300. isBodyInitRequired(): boolean;
  19301. /**
  19302. * Sets the updated scaling
  19303. * @param updated Specifies if the scaling is updated
  19304. */
  19305. setScalingUpdated(): void;
  19306. /**
  19307. * Force a regeneration of this or the parent's impostor's body.
  19308. * Use under cautious - This will remove all joints already implemented.
  19309. */
  19310. forceUpdate(): void;
  19311. /**
  19312. * Gets the body that holds this impostor. Either its own, or its parent.
  19313. */
  19314. /**
  19315. * Set the physics body. Used mainly by the physics engine/plugin
  19316. */
  19317. physicsBody: any;
  19318. /**
  19319. * Get the parent of the physics imposter
  19320. * @returns Physics imposter or null
  19321. */
  19322. /**
  19323. * Sets the parent of the physics imposter
  19324. */
  19325. parent: Nullable<PhysicsImpostor>;
  19326. /**
  19327. * Resets the update flags
  19328. */
  19329. resetUpdateFlags(): void;
  19330. /**
  19331. * Gets the object extend size
  19332. * @returns the object extend size
  19333. */
  19334. getObjectExtendSize(): Vector3;
  19335. /**
  19336. * Gets the object center
  19337. * @returns The object center
  19338. */
  19339. getObjectCenter(): Vector3;
  19340. /**
  19341. * Get a specific parametes from the options parameter
  19342. * @param paramName The object parameter name
  19343. * @returns The object parameter
  19344. */
  19345. getParam(paramName: string): any;
  19346. /**
  19347. * Sets a specific parameter in the options given to the physics plugin
  19348. * @param paramName The parameter name
  19349. * @param value The value of the parameter
  19350. */
  19351. setParam(paramName: string, value: number): void;
  19352. /**
  19353. * Specifically change the body's mass option. Won't recreate the physics body object
  19354. * @param mass The mass of the physics imposter
  19355. */
  19356. setMass(mass: number): void;
  19357. /**
  19358. * Gets the linear velocity
  19359. * @returns linear velocity or null
  19360. */
  19361. getLinearVelocity(): Nullable<Vector3>;
  19362. /**
  19363. * Sets the linear velocity
  19364. * @param velocity linear velocity or null
  19365. */
  19366. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19367. /**
  19368. * Gets the angular velocity
  19369. * @returns angular velocity or null
  19370. */
  19371. getAngularVelocity(): Nullable<Vector3>;
  19372. /**
  19373. * Sets the angular velocity
  19374. * @param velocity The velocity or null
  19375. */
  19376. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19377. /**
  19378. * Execute a function with the physics plugin native code
  19379. * Provide a function the will have two variables - the world object and the physics body object
  19380. * @param func The function to execute with the physics plugin native code
  19381. */
  19382. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19383. /**
  19384. * Register a function that will be executed before the physics world is stepping forward
  19385. * @param func The function to execute before the physics world is stepped forward
  19386. */
  19387. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19388. /**
  19389. * Unregister a function that will be executed before the physics world is stepping forward
  19390. * @param func The function to execute before the physics world is stepped forward
  19391. */
  19392. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19393. /**
  19394. * Register a function that will be executed after the physics step
  19395. * @param func The function to execute after physics step
  19396. */
  19397. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19398. /**
  19399. * Unregisters a function that will be executed after the physics step
  19400. * @param func The function to execute after physics step
  19401. */
  19402. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19403. /**
  19404. * register a function that will be executed when this impostor collides against a different body
  19405. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19406. * @param func Callback that is executed on collision
  19407. */
  19408. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19409. /**
  19410. * Unregisters the physics imposter on contact
  19411. * @param collideAgainst The physics object to collide against
  19412. * @param func Callback to execute on collision
  19413. */
  19414. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19415. private _tmpQuat;
  19416. private _tmpQuat2;
  19417. /**
  19418. * Get the parent rotation
  19419. * @returns The parent rotation
  19420. */
  19421. getParentsRotation(): Quaternion;
  19422. /**
  19423. * this function is executed by the physics engine.
  19424. */
  19425. beforeStep: () => void;
  19426. /**
  19427. * this function is executed by the physics engine
  19428. */
  19429. afterStep: () => void;
  19430. /**
  19431. * Legacy collision detection event support
  19432. */
  19433. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19434. /**
  19435. * event and body object due to cannon's event-based architecture.
  19436. */
  19437. onCollide: (e: {
  19438. body: any;
  19439. }) => void;
  19440. /**
  19441. * Apply a force
  19442. * @param force The force to apply
  19443. * @param contactPoint The contact point for the force
  19444. * @returns The physics imposter
  19445. */
  19446. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19447. /**
  19448. * Apply an impulse
  19449. * @param force The impulse force
  19450. * @param contactPoint The contact point for the impulse force
  19451. * @returns The physics imposter
  19452. */
  19453. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19454. /**
  19455. * A help function to create a joint
  19456. * @param otherImpostor A physics imposter used to create a joint
  19457. * @param jointType The type of joint
  19458. * @param jointData The data for the joint
  19459. * @returns The physics imposter
  19460. */
  19461. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19462. /**
  19463. * Add a joint to this impostor with a different impostor
  19464. * @param otherImpostor A physics imposter used to add a joint
  19465. * @param joint The joint to add
  19466. * @returns The physics imposter
  19467. */
  19468. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19469. /**
  19470. * Will keep this body still, in a sleep mode.
  19471. * @returns the physics imposter
  19472. */
  19473. sleep(): PhysicsImpostor;
  19474. /**
  19475. * Wake the body up.
  19476. * @returns The physics imposter
  19477. */
  19478. wakeUp(): PhysicsImpostor;
  19479. /**
  19480. * Clones the physics imposter
  19481. * @param newObject The physics imposter clones to this physics-enabled object
  19482. * @returns A nullable physics imposter
  19483. */
  19484. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19485. /**
  19486. * Disposes the physics imposter
  19487. */
  19488. dispose(): void;
  19489. /**
  19490. * Sets the delta position
  19491. * @param position The delta position amount
  19492. */
  19493. setDeltaPosition(position: Vector3): void;
  19494. /**
  19495. * Sets the delta rotation
  19496. * @param rotation The delta rotation amount
  19497. */
  19498. setDeltaRotation(rotation: Quaternion): void;
  19499. /**
  19500. * Gets the box size of the physics imposter and stores the result in the input parameter
  19501. * @param result Stores the box size
  19502. * @returns The physics imposter
  19503. */
  19504. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19505. /**
  19506. * Gets the radius of the physics imposter
  19507. * @returns Radius of the physics imposter
  19508. */
  19509. getRadius(): number;
  19510. /**
  19511. * Sync a bone with this impostor
  19512. * @param bone The bone to sync to the impostor.
  19513. * @param boneMesh The mesh that the bone is influencing.
  19514. * @param jointPivot The pivot of the joint / bone in local space.
  19515. * @param distToJoint Optional distance from the impostor to the joint.
  19516. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19517. */
  19518. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19519. /**
  19520. * Sync impostor to a bone
  19521. * @param bone The bone that the impostor will be synced to.
  19522. * @param boneMesh The mesh that the bone is influencing.
  19523. * @param jointPivot The pivot of the joint / bone in local space.
  19524. * @param distToJoint Optional distance from the impostor to the joint.
  19525. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19526. * @param boneAxis Optional vector3 axis the bone is aligned with
  19527. */
  19528. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19529. /**
  19530. * No-Imposter type
  19531. */
  19532. static NoImpostor: number;
  19533. /**
  19534. * Sphere-Imposter type
  19535. */
  19536. static SphereImpostor: number;
  19537. /**
  19538. * Box-Imposter type
  19539. */
  19540. static BoxImpostor: number;
  19541. /**
  19542. * Plane-Imposter type
  19543. */
  19544. static PlaneImpostor: number;
  19545. /**
  19546. * Mesh-imposter type
  19547. */
  19548. static MeshImpostor: number;
  19549. /**
  19550. * Cylinder-Imposter type
  19551. */
  19552. static CylinderImpostor: number;
  19553. /**
  19554. * Particle-Imposter type
  19555. */
  19556. static ParticleImpostor: number;
  19557. /**
  19558. * Heightmap-Imposter type
  19559. */
  19560. static HeightmapImpostor: number;
  19561. }
  19562. }
  19563. declare module "babylonjs/Meshes/mesh" {
  19564. import { Observable } from "babylonjs/Misc/observable";
  19565. import { IAnimatable } from "babylonjs/Misc/tools";
  19566. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19567. import { Camera } from "babylonjs/Cameras/camera";
  19568. import { Scene } from "babylonjs/scene";
  19569. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19570. import { Engine } from "babylonjs/Engines/engine";
  19571. import { Node } from "babylonjs/node";
  19572. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19573. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19574. import { Buffer } from "babylonjs/Meshes/buffer";
  19575. import { Geometry } from "babylonjs/Meshes/geometry";
  19576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19578. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19579. import { Effect } from "babylonjs/Materials/effect";
  19580. import { Material } from "babylonjs/Materials/material";
  19581. import { Skeleton } from "babylonjs/Bones/skeleton";
  19582. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19583. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19584. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19585. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19586. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19587. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  19588. /**
  19589. * Class used to represent a specific level of detail of a mesh
  19590. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19591. */
  19592. export class MeshLODLevel {
  19593. /** Defines the distance where this level should star being displayed */
  19594. distance: number;
  19595. /** Defines the mesh to use to render this level */
  19596. mesh: Nullable<Mesh>;
  19597. /**
  19598. * Creates a new LOD level
  19599. * @param distance defines the distance where this level should star being displayed
  19600. * @param mesh defines the mesh to use to render this level
  19601. */
  19602. constructor(
  19603. /** Defines the distance where this level should star being displayed */
  19604. distance: number,
  19605. /** Defines the mesh to use to render this level */
  19606. mesh: Nullable<Mesh>);
  19607. }
  19608. /**
  19609. * @hidden
  19610. **/
  19611. export class _CreationDataStorage {
  19612. closePath?: boolean;
  19613. closeArray?: boolean;
  19614. idx: number[];
  19615. dashSize: number;
  19616. gapSize: number;
  19617. path3D: Path3D;
  19618. pathArray: Vector3[][];
  19619. arc: number;
  19620. radius: number;
  19621. cap: number;
  19622. tessellation: number;
  19623. }
  19624. /**
  19625. * @hidden
  19626. **/
  19627. class _InstanceDataStorage {
  19628. visibleInstances: any;
  19629. renderIdForInstances: number[];
  19630. batchCache: _InstancesBatch;
  19631. instancesBufferSize: number;
  19632. instancesBuffer: Nullable<Buffer>;
  19633. instancesData: Float32Array;
  19634. overridenInstanceCount: number;
  19635. }
  19636. /**
  19637. * @hidden
  19638. **/
  19639. export class _InstancesBatch {
  19640. mustReturn: boolean;
  19641. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19642. renderSelf: boolean[];
  19643. }
  19644. /**
  19645. * Class used to represent renderable models
  19646. */
  19647. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19648. /**
  19649. * Mesh side orientation : usually the external or front surface
  19650. */
  19651. static readonly FRONTSIDE: number;
  19652. /**
  19653. * Mesh side orientation : usually the internal or back surface
  19654. */
  19655. static readonly BACKSIDE: number;
  19656. /**
  19657. * Mesh side orientation : both internal and external or front and back surfaces
  19658. */
  19659. static readonly DOUBLESIDE: number;
  19660. /**
  19661. * Mesh side orientation : by default, `FRONTSIDE`
  19662. */
  19663. static readonly DEFAULTSIDE: number;
  19664. /**
  19665. * Mesh cap setting : no cap
  19666. */
  19667. static readonly NO_CAP: number;
  19668. /**
  19669. * Mesh cap setting : one cap at the beginning of the mesh
  19670. */
  19671. static readonly CAP_START: number;
  19672. /**
  19673. * Mesh cap setting : one cap at the end of the mesh
  19674. */
  19675. static readonly CAP_END: number;
  19676. /**
  19677. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19678. */
  19679. static readonly CAP_ALL: number;
  19680. /**
  19681. * Gets the default side orientation.
  19682. * @param orientation the orientation to value to attempt to get
  19683. * @returns the default orientation
  19684. * @hidden
  19685. */
  19686. static _GetDefaultSideOrientation(orientation?: number): number;
  19687. private _onBeforeRenderObservable;
  19688. private _onBeforeBindObservable;
  19689. private _onAfterRenderObservable;
  19690. private _onBeforeDrawObservable;
  19691. /**
  19692. * An event triggered before rendering the mesh
  19693. */
  19694. readonly onBeforeRenderObservable: Observable<Mesh>;
  19695. /**
  19696. * An event triggered before binding the mesh
  19697. */
  19698. readonly onBeforeBindObservable: Observable<Mesh>;
  19699. /**
  19700. * An event triggered after rendering the mesh
  19701. */
  19702. readonly onAfterRenderObservable: Observable<Mesh>;
  19703. /**
  19704. * An event triggered before drawing the mesh
  19705. */
  19706. readonly onBeforeDrawObservable: Observable<Mesh>;
  19707. private _onBeforeDrawObserver;
  19708. /**
  19709. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19710. */
  19711. onBeforeDraw: () => void;
  19712. /**
  19713. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19714. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19715. */
  19716. delayLoadState: number;
  19717. /**
  19718. * Gets the list of instances created from this mesh
  19719. * it is not supposed to be modified manually.
  19720. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19721. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19722. */
  19723. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19724. /**
  19725. * Gets the file containing delay loading data for this mesh
  19726. */
  19727. delayLoadingFile: string;
  19728. /** @hidden */
  19729. _binaryInfo: any;
  19730. private _LODLevels;
  19731. /**
  19732. * User defined function used to change how LOD level selection is done
  19733. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19734. */
  19735. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19736. private _morphTargetManager;
  19737. /**
  19738. * Gets or sets the morph target manager
  19739. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19740. */
  19741. morphTargetManager: Nullable<MorphTargetManager>;
  19742. /** @hidden */
  19743. _creationDataStorage: Nullable<_CreationDataStorage>;
  19744. /** @hidden */
  19745. _geometry: Nullable<Geometry>;
  19746. /** @hidden */
  19747. _delayInfo: Array<string>;
  19748. /** @hidden */
  19749. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19750. /** @hidden */
  19751. _instanceDataStorage: _InstanceDataStorage;
  19752. private _effectiveMaterial;
  19753. /** @hidden */
  19754. _shouldGenerateFlatShading: boolean;
  19755. private _preActivateId;
  19756. /** @hidden */
  19757. _originalBuilderSideOrientation: number;
  19758. /**
  19759. * Use this property to change the original side orientation defined at construction time
  19760. */
  19761. overrideMaterialSideOrientation: Nullable<number>;
  19762. private _areNormalsFrozen;
  19763. private _sourcePositions;
  19764. private _sourceNormals;
  19765. private _source;
  19766. private meshMap;
  19767. /**
  19768. * Gets the source mesh (the one used to clone this one from)
  19769. */
  19770. readonly source: Nullable<Mesh>;
  19771. /**
  19772. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19773. */
  19774. isUnIndexed: boolean;
  19775. /**
  19776. * @constructor
  19777. * @param name The value used by scene.getMeshByName() to do a lookup.
  19778. * @param scene The scene to add this mesh to.
  19779. * @param parent The parent of this mesh, if it has one
  19780. * @param source An optional Mesh from which geometry is shared, cloned.
  19781. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19782. * When false, achieved by calling a clone(), also passing False.
  19783. * This will make creation of children, recursive.
  19784. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19785. */
  19786. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19787. /**
  19788. * Gets the class name
  19789. * @returns the string "Mesh".
  19790. */
  19791. getClassName(): string;
  19792. /** @hidden */
  19793. readonly _isMesh: boolean;
  19794. /**
  19795. * Returns a description of this mesh
  19796. * @param fullDetails define if full details about this mesh must be used
  19797. * @returns a descriptive string representing this mesh
  19798. */
  19799. toString(fullDetails?: boolean): string;
  19800. /** @hidden */
  19801. _unBindEffect(): void;
  19802. /**
  19803. * Gets a boolean indicating if this mesh has LOD
  19804. */
  19805. readonly hasLODLevels: boolean;
  19806. /**
  19807. * Gets the list of MeshLODLevel associated with the current mesh
  19808. * @returns an array of MeshLODLevel
  19809. */
  19810. getLODLevels(): MeshLODLevel[];
  19811. private _sortLODLevels;
  19812. /**
  19813. * Add a mesh as LOD level triggered at the given distance.
  19814. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19815. * @param distance The distance from the center of the object to show this level
  19816. * @param mesh The mesh to be added as LOD level (can be null)
  19817. * @return This mesh (for chaining)
  19818. */
  19819. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19820. /**
  19821. * Returns the LOD level mesh at the passed distance or null if not found.
  19822. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19823. * @param distance The distance from the center of the object to show this level
  19824. * @returns a Mesh or `null`
  19825. */
  19826. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19827. /**
  19828. * Remove a mesh from the LOD array
  19829. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19830. * @param mesh defines the mesh to be removed
  19831. * @return This mesh (for chaining)
  19832. */
  19833. removeLODLevel(mesh: Mesh): Mesh;
  19834. /**
  19835. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19836. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19837. * @param camera defines the camera to use to compute distance
  19838. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19839. * @return This mesh (for chaining)
  19840. */
  19841. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19842. /**
  19843. * Gets the mesh internal Geometry object
  19844. */
  19845. readonly geometry: Nullable<Geometry>;
  19846. /**
  19847. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19848. * @returns the total number of vertices
  19849. */
  19850. getTotalVertices(): number;
  19851. /**
  19852. * Returns the content of an associated vertex buffer
  19853. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19854. * - VertexBuffer.PositionKind
  19855. * - VertexBuffer.UVKind
  19856. * - VertexBuffer.UV2Kind
  19857. * - VertexBuffer.UV3Kind
  19858. * - VertexBuffer.UV4Kind
  19859. * - VertexBuffer.UV5Kind
  19860. * - VertexBuffer.UV6Kind
  19861. * - VertexBuffer.ColorKind
  19862. * - VertexBuffer.MatricesIndicesKind
  19863. * - VertexBuffer.MatricesIndicesExtraKind
  19864. * - VertexBuffer.MatricesWeightsKind
  19865. * - VertexBuffer.MatricesWeightsExtraKind
  19866. * @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
  19867. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19868. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19869. */
  19870. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19871. /**
  19872. * Returns the mesh VertexBuffer object from the requested `kind`
  19873. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19874. * - VertexBuffer.PositionKind
  19875. * - VertexBuffer.UVKind
  19876. * - VertexBuffer.UV2Kind
  19877. * - VertexBuffer.UV3Kind
  19878. * - VertexBuffer.UV4Kind
  19879. * - VertexBuffer.UV5Kind
  19880. * - VertexBuffer.UV6Kind
  19881. * - VertexBuffer.ColorKind
  19882. * - VertexBuffer.MatricesIndicesKind
  19883. * - VertexBuffer.MatricesIndicesExtraKind
  19884. * - VertexBuffer.MatricesWeightsKind
  19885. * - VertexBuffer.MatricesWeightsExtraKind
  19886. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19887. */
  19888. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19889. /**
  19890. * Tests if a specific vertex buffer is associated with this mesh
  19891. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19892. * - VertexBuffer.PositionKind
  19893. * - VertexBuffer.UVKind
  19894. * - VertexBuffer.UV2Kind
  19895. * - VertexBuffer.UV3Kind
  19896. * - VertexBuffer.UV4Kind
  19897. * - VertexBuffer.UV5Kind
  19898. * - VertexBuffer.UV6Kind
  19899. * - VertexBuffer.ColorKind
  19900. * - VertexBuffer.MatricesIndicesKind
  19901. * - VertexBuffer.MatricesIndicesExtraKind
  19902. * - VertexBuffer.MatricesWeightsKind
  19903. * - VertexBuffer.MatricesWeightsExtraKind
  19904. * @returns a boolean
  19905. */
  19906. isVerticesDataPresent(kind: string): boolean;
  19907. /**
  19908. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19909. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19910. * - VertexBuffer.PositionKind
  19911. * - VertexBuffer.UVKind
  19912. * - VertexBuffer.UV2Kind
  19913. * - VertexBuffer.UV3Kind
  19914. * - VertexBuffer.UV4Kind
  19915. * - VertexBuffer.UV5Kind
  19916. * - VertexBuffer.UV6Kind
  19917. * - VertexBuffer.ColorKind
  19918. * - VertexBuffer.MatricesIndicesKind
  19919. * - VertexBuffer.MatricesIndicesExtraKind
  19920. * - VertexBuffer.MatricesWeightsKind
  19921. * - VertexBuffer.MatricesWeightsExtraKind
  19922. * @returns a boolean
  19923. */
  19924. isVertexBufferUpdatable(kind: string): boolean;
  19925. /**
  19926. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19927. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19928. * - VertexBuffer.PositionKind
  19929. * - VertexBuffer.UVKind
  19930. * - VertexBuffer.UV2Kind
  19931. * - VertexBuffer.UV3Kind
  19932. * - VertexBuffer.UV4Kind
  19933. * - VertexBuffer.UV5Kind
  19934. * - VertexBuffer.UV6Kind
  19935. * - VertexBuffer.ColorKind
  19936. * - VertexBuffer.MatricesIndicesKind
  19937. * - VertexBuffer.MatricesIndicesExtraKind
  19938. * - VertexBuffer.MatricesWeightsKind
  19939. * - VertexBuffer.MatricesWeightsExtraKind
  19940. * @returns an array of strings
  19941. */
  19942. getVerticesDataKinds(): string[];
  19943. /**
  19944. * Returns a positive integer : the total number of indices in this mesh geometry.
  19945. * @returns the numner of indices or zero if the mesh has no geometry.
  19946. */
  19947. getTotalIndices(): number;
  19948. /**
  19949. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19950. * @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.
  19951. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19952. * @returns the indices array or an empty array if the mesh has no geometry
  19953. */
  19954. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19955. readonly isBlocked: boolean;
  19956. /**
  19957. * Determine if the current mesh is ready to be rendered
  19958. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19959. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19960. * @returns true if all associated assets are ready (material, textures, shaders)
  19961. */
  19962. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19963. /**
  19964. * 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.
  19965. */
  19966. readonly areNormalsFrozen: boolean;
  19967. /**
  19968. * 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.
  19969. * @returns the current mesh
  19970. */
  19971. freezeNormals(): Mesh;
  19972. /**
  19973. * 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
  19974. * @returns the current mesh
  19975. */
  19976. unfreezeNormals(): Mesh;
  19977. /**
  19978. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19979. */
  19980. overridenInstanceCount: number;
  19981. /** @hidden */
  19982. _preActivate(): Mesh;
  19983. /** @hidden */
  19984. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19985. /** @hidden */
  19986. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19987. /**
  19988. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19989. * This means the mesh underlying bounding box and sphere are recomputed.
  19990. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19991. * @returns the current mesh
  19992. */
  19993. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19994. /** @hidden */
  19995. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19996. /**
  19997. * This function will subdivide the mesh into multiple submeshes
  19998. * @param count defines the expected number of submeshes
  19999. */
  20000. subdivide(count: number): void;
  20001. /**
  20002. * Copy a FloatArray into a specific associated vertex buffer
  20003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20004. * - VertexBuffer.PositionKind
  20005. * - VertexBuffer.UVKind
  20006. * - VertexBuffer.UV2Kind
  20007. * - VertexBuffer.UV3Kind
  20008. * - VertexBuffer.UV4Kind
  20009. * - VertexBuffer.UV5Kind
  20010. * - VertexBuffer.UV6Kind
  20011. * - VertexBuffer.ColorKind
  20012. * - VertexBuffer.MatricesIndicesKind
  20013. * - VertexBuffer.MatricesIndicesExtraKind
  20014. * - VertexBuffer.MatricesWeightsKind
  20015. * - VertexBuffer.MatricesWeightsExtraKind
  20016. * @param data defines the data source
  20017. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20018. * @param stride defines the data stride size (can be null)
  20019. * @returns the current mesh
  20020. */
  20021. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20022. /**
  20023. * Flags an associated vertex buffer as updatable
  20024. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20025. * - VertexBuffer.PositionKind
  20026. * - VertexBuffer.UVKind
  20027. * - VertexBuffer.UV2Kind
  20028. * - VertexBuffer.UV3Kind
  20029. * - VertexBuffer.UV4Kind
  20030. * - VertexBuffer.UV5Kind
  20031. * - VertexBuffer.UV6Kind
  20032. * - VertexBuffer.ColorKind
  20033. * - VertexBuffer.MatricesIndicesKind
  20034. * - VertexBuffer.MatricesIndicesExtraKind
  20035. * - VertexBuffer.MatricesWeightsKind
  20036. * - VertexBuffer.MatricesWeightsExtraKind
  20037. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20038. */
  20039. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20040. /**
  20041. * Sets the mesh global Vertex Buffer
  20042. * @param buffer defines the buffer to use
  20043. * @returns the current mesh
  20044. */
  20045. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20046. /**
  20047. * Update a specific associated vertex buffer
  20048. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20049. * - VertexBuffer.PositionKind
  20050. * - VertexBuffer.UVKind
  20051. * - VertexBuffer.UV2Kind
  20052. * - VertexBuffer.UV3Kind
  20053. * - VertexBuffer.UV4Kind
  20054. * - VertexBuffer.UV5Kind
  20055. * - VertexBuffer.UV6Kind
  20056. * - VertexBuffer.ColorKind
  20057. * - VertexBuffer.MatricesIndicesKind
  20058. * - VertexBuffer.MatricesIndicesExtraKind
  20059. * - VertexBuffer.MatricesWeightsKind
  20060. * - VertexBuffer.MatricesWeightsExtraKind
  20061. * @param data defines the data source
  20062. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20063. * @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)
  20064. * @returns the current mesh
  20065. */
  20066. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20067. /**
  20068. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20069. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20070. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20071. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20072. * @returns the current mesh
  20073. */
  20074. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20075. /**
  20076. * Creates a un-shared specific occurence of the geometry for the mesh.
  20077. * @returns the current mesh
  20078. */
  20079. makeGeometryUnique(): Mesh;
  20080. /**
  20081. * Set the index buffer of this mesh
  20082. * @param indices defines the source data
  20083. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20084. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20085. * @returns the current mesh
  20086. */
  20087. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20088. /**
  20089. * Update the current index buffer
  20090. * @param indices defines the source data
  20091. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20092. * @returns the current mesh
  20093. */
  20094. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20095. /**
  20096. * Invert the geometry to move from a right handed system to a left handed one.
  20097. * @returns the current mesh
  20098. */
  20099. toLeftHanded(): Mesh;
  20100. /** @hidden */
  20101. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20102. /** @hidden */
  20103. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20104. /**
  20105. * Registers for this mesh a javascript function called just before the rendering process
  20106. * @param func defines the function to call before rendering this mesh
  20107. * @returns the current mesh
  20108. */
  20109. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20110. /**
  20111. * Disposes a previously registered javascript function called before the rendering
  20112. * @param func defines the function to remove
  20113. * @returns the current mesh
  20114. */
  20115. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20116. /**
  20117. * Registers for this mesh a javascript function called just after the rendering is complete
  20118. * @param func defines the function to call after rendering this mesh
  20119. * @returns the current mesh
  20120. */
  20121. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20122. /**
  20123. * Disposes a previously registered javascript function called after the rendering.
  20124. * @param func defines the function to remove
  20125. * @returns the current mesh
  20126. */
  20127. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20128. /** @hidden */
  20129. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20130. /** @hidden */
  20131. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20132. /** @hidden */
  20133. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20134. /**
  20135. * 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
  20136. * @param subMesh defines the subMesh to render
  20137. * @param enableAlphaMode defines if alpha mode can be changed
  20138. * @returns the current mesh
  20139. */
  20140. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20141. private _onBeforeDraw;
  20142. /**
  20143. * Renormalize the mesh and patch it up if there are no weights
  20144. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20145. * However in the case of zero weights then we set just a single influence to 1.
  20146. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20147. */
  20148. cleanMatrixWeights(): void;
  20149. private normalizeSkinFourWeights;
  20150. private normalizeSkinWeightsAndExtra;
  20151. /**
  20152. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20153. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20154. * the user know there was an issue with importing the mesh
  20155. * @returns a validation object with skinned, valid and report string
  20156. */
  20157. validateSkinning(): {
  20158. skinned: boolean;
  20159. valid: boolean;
  20160. report: string;
  20161. };
  20162. /** @hidden */
  20163. _checkDelayState(): Mesh;
  20164. private _queueLoad;
  20165. /**
  20166. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20167. * A mesh is in the frustum if its bounding box intersects the frustum
  20168. * @param frustumPlanes defines the frustum to test
  20169. * @returns true if the mesh is in the frustum planes
  20170. */
  20171. isInFrustum(frustumPlanes: Plane[]): boolean;
  20172. /**
  20173. * Sets the mesh material by the material or multiMaterial `id` property
  20174. * @param id is a string identifying the material or the multiMaterial
  20175. * @returns the current mesh
  20176. */
  20177. setMaterialByID(id: string): Mesh;
  20178. /**
  20179. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20180. * @returns an array of IAnimatable
  20181. */
  20182. getAnimatables(): IAnimatable[];
  20183. /**
  20184. * Modifies the mesh geometry according to the passed transformation matrix.
  20185. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20186. * The mesh normals are modified using the same transformation.
  20187. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20188. * @param transform defines the transform matrix to use
  20189. * @see http://doc.babylonjs.com/resources/baking_transformations
  20190. * @returns the current mesh
  20191. */
  20192. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20193. /**
  20194. * Modifies the mesh geometry according to its own current World Matrix.
  20195. * The mesh World Matrix is then reset.
  20196. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20197. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20198. * @see http://doc.babylonjs.com/resources/baking_transformations
  20199. * @returns the current mesh
  20200. */
  20201. bakeCurrentTransformIntoVertices(): Mesh;
  20202. /** @hidden */
  20203. readonly _positions: Nullable<Vector3[]>;
  20204. /** @hidden */
  20205. _resetPointsArrayCache(): Mesh;
  20206. /** @hidden */
  20207. _generatePointsArray(): boolean;
  20208. /**
  20209. * Returns a new Mesh object generated from the current mesh properties.
  20210. * This method must not get confused with createInstance()
  20211. * @param name is a string, the name given to the new mesh
  20212. * @param newParent can be any Node object (default `null`)
  20213. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20214. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20215. * @returns a new mesh
  20216. */
  20217. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20218. /**
  20219. * Releases resources associated with this mesh.
  20220. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20221. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20222. */
  20223. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20224. /**
  20225. * Modifies the mesh geometry according to a displacement map.
  20226. * 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.
  20227. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20228. * @param url is a string, the URL from the image file is to be downloaded.
  20229. * @param minHeight is the lower limit of the displacement.
  20230. * @param maxHeight is the upper limit of the displacement.
  20231. * @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.
  20232. * @param uvOffset is an optional vector2 used to offset UV.
  20233. * @param uvScale is an optional vector2 used to scale UV.
  20234. * @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.
  20235. * @returns the Mesh.
  20236. */
  20237. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20238. /**
  20239. * Modifies the mesh geometry according to a displacementMap buffer.
  20240. * 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.
  20241. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20242. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20243. * @param heightMapWidth is the width of the buffer image.
  20244. * @param heightMapHeight is the height of the buffer image.
  20245. * @param minHeight is the lower limit of the displacement.
  20246. * @param maxHeight is the upper limit of the displacement.
  20247. * @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.
  20248. * @param uvOffset is an optional vector2 used to offset UV.
  20249. * @param uvScale is an optional vector2 used to scale UV.
  20250. * @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.
  20251. * @returns the Mesh.
  20252. */
  20253. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20254. /**
  20255. * Modify the mesh to get a flat shading rendering.
  20256. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20257. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20258. * @returns current mesh
  20259. */
  20260. convertToFlatShadedMesh(): Mesh;
  20261. /**
  20262. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20263. * In other words, more vertices, no more indices and a single bigger VBO.
  20264. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20265. * @returns current mesh
  20266. */
  20267. convertToUnIndexedMesh(): Mesh;
  20268. /**
  20269. * Inverses facet orientations.
  20270. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20271. * @param flipNormals will also inverts the normals
  20272. * @returns current mesh
  20273. */
  20274. flipFaces(flipNormals?: boolean): Mesh;
  20275. /** @hidden */
  20276. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20277. /** @hidden */
  20278. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20279. /**
  20280. * Creates a new InstancedMesh object from the mesh model.
  20281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20282. * @param name defines the name of the new instance
  20283. * @returns a new InstancedMesh
  20284. */
  20285. createInstance(name: string): InstancedMesh;
  20286. /**
  20287. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20288. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20289. * @returns the current mesh
  20290. */
  20291. synchronizeInstances(): Mesh;
  20292. /**
  20293. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20294. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20295. * This should be used together with the simplification to avoid disappearing triangles.
  20296. * @param successCallback an optional success callback to be called after the optimization finished.
  20297. * @returns the current mesh
  20298. */
  20299. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20300. /**
  20301. * Serialize current mesh
  20302. * @param serializationObject defines the object which will receive the serialization data
  20303. */
  20304. serialize(serializationObject: any): void;
  20305. /** @hidden */
  20306. _syncGeometryWithMorphTargetManager(): void;
  20307. /** @hidden */
  20308. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20309. /**
  20310. * Returns a new Mesh object parsed from the source provided.
  20311. * @param parsedMesh is the source
  20312. * @param scene defines the hosting scene
  20313. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20314. * @returns a new Mesh
  20315. */
  20316. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20317. /**
  20318. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20319. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20320. * @param name defines the name of the mesh to create
  20321. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20322. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20323. * @param closePath creates a seam between the first and the last points of each path of the path array
  20324. * @param offset is taken in account only if the `pathArray` is containing a single path
  20325. * @param scene defines the hosting scene
  20326. * @param updatable defines if the mesh must be flagged as updatable
  20327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20328. * @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)
  20329. * @returns a new Mesh
  20330. */
  20331. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20332. /**
  20333. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20334. * @param name defines the name of the mesh to create
  20335. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20336. * @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
  20337. * @param scene defines the hosting scene
  20338. * @param updatable defines if the mesh must be flagged as updatable
  20339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20340. * @returns a new Mesh
  20341. */
  20342. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20343. /**
  20344. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20345. * @param name defines the name of the mesh to create
  20346. * @param size sets the size (float) of each box side (default 1)
  20347. * @param scene defines the hosting scene
  20348. * @param updatable defines if the mesh must be flagged as updatable
  20349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20350. * @returns a new Mesh
  20351. */
  20352. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20353. /**
  20354. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20355. * @param name defines the name of the mesh to create
  20356. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20357. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20358. * @param scene defines the hosting scene
  20359. * @param updatable defines if the mesh must be flagged as updatable
  20360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20361. * @returns a new Mesh
  20362. */
  20363. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20364. /**
  20365. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20366. * @param name defines the name of the mesh to create
  20367. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20368. * @param diameterTop set the top cap diameter (floats, default 1)
  20369. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20370. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20371. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20372. * @param scene defines the hosting scene
  20373. * @param updatable defines if the mesh must be flagged as updatable
  20374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20375. * @returns a new Mesh
  20376. */
  20377. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20378. /**
  20379. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20380. * @param name defines the name of the mesh to create
  20381. * @param diameter sets the diameter size (float) of the torus (default 1)
  20382. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20383. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20384. * @param scene defines the hosting scene
  20385. * @param updatable defines if the mesh must be flagged as updatable
  20386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20387. * @returns a new Mesh
  20388. */
  20389. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20390. /**
  20391. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20392. * @param name defines the name of the mesh to create
  20393. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20394. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20395. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20396. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20397. * @param p the number of windings on X axis (positive integers, default 2)
  20398. * @param q the number of windings on Y axis (positive integers, default 3)
  20399. * @param scene defines the hosting scene
  20400. * @param updatable defines if the mesh must be flagged as updatable
  20401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20402. * @returns a new Mesh
  20403. */
  20404. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20405. /**
  20406. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20407. * @param name defines the name of the mesh to create
  20408. * @param points is an array successive Vector3
  20409. * @param scene defines the hosting scene
  20410. * @param updatable defines if the mesh must be flagged as updatable
  20411. * @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).
  20412. * @returns a new Mesh
  20413. */
  20414. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20415. /**
  20416. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20417. * @param name defines the name of the mesh to create
  20418. * @param points is an array successive Vector3
  20419. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20420. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20421. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20422. * @param scene defines the hosting scene
  20423. * @param updatable defines if the mesh must be flagged as updatable
  20424. * @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)
  20425. * @returns a new Mesh
  20426. */
  20427. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20428. /**
  20429. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20430. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20431. * 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.
  20432. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20433. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20434. * Remember you can only change the shape positions, not their number when updating a polygon.
  20435. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20436. * @param name defines the name of the mesh to create
  20437. * @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
  20438. * @param scene defines the hosting scene
  20439. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20440. * @param updatable defines if the mesh must be flagged as updatable
  20441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20442. * @param earcutInjection can be used to inject your own earcut reference
  20443. * @returns a new Mesh
  20444. */
  20445. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20446. /**
  20447. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20448. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20449. * @param name defines the name of the mesh to create
  20450. * @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
  20451. * @param depth defines the height of extrusion
  20452. * @param scene defines the hosting scene
  20453. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20454. * @param updatable defines if the mesh must be flagged as updatable
  20455. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20456. * @param earcutInjection can be used to inject your own earcut reference
  20457. * @returns a new Mesh
  20458. */
  20459. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20460. /**
  20461. * Creates an extruded shape mesh.
  20462. * 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
  20463. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20464. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20465. * @param name defines the name of the mesh to create
  20466. * @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
  20467. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20468. * @param scale is the value to scale the shape
  20469. * @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
  20470. * @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
  20471. * @param scene defines the hosting scene
  20472. * @param updatable defines if the mesh must be flagged as updatable
  20473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20474. * @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)
  20475. * @returns a new Mesh
  20476. */
  20477. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20478. /**
  20479. * Creates an custom extruded shape mesh.
  20480. * The custom extrusion is a parametric shape.
  20481. * It has no predefined shape. Its final shape will depend on the input parameters.
  20482. * Please consider using the same method from the MeshBuilder class instead
  20483. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20484. * @param name defines the name of the mesh to create
  20485. * @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
  20486. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20487. * @param scaleFunction is a custom Javascript function called on each path point
  20488. * @param rotationFunction is a custom Javascript function called on each path point
  20489. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20490. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20491. * @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
  20492. * @param scene defines the hosting scene
  20493. * @param updatable defines if the mesh must be flagged as updatable
  20494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20495. * @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)
  20496. * @returns a new Mesh
  20497. */
  20498. 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;
  20499. /**
  20500. * Creates lathe mesh.
  20501. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20502. * Please consider using the same method from the MeshBuilder class instead
  20503. * @param name defines the name of the mesh to create
  20504. * @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
  20505. * @param radius is the radius value of the lathe
  20506. * @param tessellation is the side number of the lathe.
  20507. * @param scene defines the hosting scene
  20508. * @param updatable defines if the mesh must be flagged as updatable
  20509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20510. * @returns a new Mesh
  20511. */
  20512. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20513. /**
  20514. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20515. * @param name defines the name of the mesh to create
  20516. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20517. * @param scene defines the hosting scene
  20518. * @param updatable defines if the mesh must be flagged as updatable
  20519. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20520. * @returns a new Mesh
  20521. */
  20522. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20523. /**
  20524. * Creates a ground mesh.
  20525. * Please consider using the same method from the MeshBuilder class instead
  20526. * @param name defines the name of the mesh to create
  20527. * @param width set the width of the ground
  20528. * @param height set the height of the ground
  20529. * @param subdivisions sets the number of subdivisions per side
  20530. * @param scene defines the hosting scene
  20531. * @param updatable defines if the mesh must be flagged as updatable
  20532. * @returns a new Mesh
  20533. */
  20534. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20535. /**
  20536. * Creates a tiled ground mesh.
  20537. * Please consider using the same method from the MeshBuilder class instead
  20538. * @param name defines the name of the mesh to create
  20539. * @param xmin set the ground minimum X coordinate
  20540. * @param zmin set the ground minimum Y coordinate
  20541. * @param xmax set the ground maximum X coordinate
  20542. * @param zmax set the ground maximum Z coordinate
  20543. * @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
  20544. * @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
  20545. * @param scene defines the hosting scene
  20546. * @param updatable defines if the mesh must be flagged as updatable
  20547. * @returns a new Mesh
  20548. */
  20549. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20550. w: number;
  20551. h: number;
  20552. }, precision: {
  20553. w: number;
  20554. h: number;
  20555. }, scene: Scene, updatable?: boolean): Mesh;
  20556. /**
  20557. * Creates a ground mesh from a height map.
  20558. * Please consider using the same method from the MeshBuilder class instead
  20559. * @see http://doc.babylonjs.com/babylon101/height_map
  20560. * @param name defines the name of the mesh to create
  20561. * @param url sets the URL of the height map image resource
  20562. * @param width set the ground width size
  20563. * @param height set the ground height size
  20564. * @param subdivisions sets the number of subdivision per side
  20565. * @param minHeight is the minimum altitude on the ground
  20566. * @param maxHeight is the maximum altitude on the ground
  20567. * @param scene defines the hosting scene
  20568. * @param updatable defines if the mesh must be flagged as updatable
  20569. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20570. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20571. * @returns a new Mesh
  20572. */
  20573. 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;
  20574. /**
  20575. * Creates a tube mesh.
  20576. * The tube is a parametric shape.
  20577. * It has no predefined shape. Its final shape will depend on the input parameters.
  20578. * Please consider using the same method from the MeshBuilder class instead
  20579. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20580. * @param name defines the name of the mesh to create
  20581. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20582. * @param radius sets the tube radius size
  20583. * @param tessellation is the number of sides on the tubular surface
  20584. * @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
  20585. * @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
  20586. * @param scene defines the hosting scene
  20587. * @param updatable defines if the mesh must be flagged as updatable
  20588. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20589. * @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)
  20590. * @returns a new Mesh
  20591. */
  20592. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20593. (i: number, distance: number): number;
  20594. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20595. /**
  20596. * Creates a polyhedron mesh.
  20597. * Please consider using the same method from the MeshBuilder class instead.
  20598. * * 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
  20599. * * The parameter `size` (positive float, default 1) sets the polygon size
  20600. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20601. * * 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`
  20602. * * 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
  20603. * * 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)`)
  20604. * * 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
  20605. * * 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
  20606. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20607. * * If you create a double-sided mesh, you can choose what parts of 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
  20608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20609. * @param name defines the name of the mesh to create
  20610. * @param options defines the options used to create the mesh
  20611. * @param scene defines the hosting scene
  20612. * @returns a new Mesh
  20613. */
  20614. static CreatePolyhedron(name: string, options: {
  20615. type?: number;
  20616. size?: number;
  20617. sizeX?: number;
  20618. sizeY?: number;
  20619. sizeZ?: number;
  20620. custom?: any;
  20621. faceUV?: Vector4[];
  20622. faceColors?: Color4[];
  20623. updatable?: boolean;
  20624. sideOrientation?: number;
  20625. }, scene: Scene): Mesh;
  20626. /**
  20627. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20628. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20629. * * 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`)
  20630. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20631. * * 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
  20632. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20633. * * If you create a double-sided mesh, you can choose what parts of 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
  20634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20635. * @param name defines the name of the mesh
  20636. * @param options defines the options used to create the mesh
  20637. * @param scene defines the hosting scene
  20638. * @returns a new Mesh
  20639. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20640. */
  20641. static CreateIcoSphere(name: string, options: {
  20642. radius?: number;
  20643. flat?: boolean;
  20644. subdivisions?: number;
  20645. sideOrientation?: number;
  20646. updatable?: boolean;
  20647. }, scene: Scene): Mesh;
  20648. /**
  20649. * Creates a decal mesh.
  20650. * Please consider using the same method from the MeshBuilder class instead.
  20651. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20652. * @param name defines the name of the mesh
  20653. * @param sourceMesh defines the mesh receiving the decal
  20654. * @param position sets the position of the decal in world coordinates
  20655. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20656. * @param size sets the decal scaling
  20657. * @param angle sets the angle to rotate the decal
  20658. * @returns a new Mesh
  20659. */
  20660. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20661. /**
  20662. * Prepare internal position array for software CPU skinning
  20663. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20664. */
  20665. setPositionsForCPUSkinning(): Float32Array;
  20666. /**
  20667. * Prepare internal normal array for software CPU skinning
  20668. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20669. */
  20670. setNormalsForCPUSkinning(): Float32Array;
  20671. /**
  20672. * Updates the vertex buffer by applying transformation from the bones
  20673. * @param skeleton defines the skeleton to apply to current mesh
  20674. * @returns the current mesh
  20675. */
  20676. applySkeleton(skeleton: Skeleton): Mesh;
  20677. /**
  20678. * 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
  20679. * @param meshes defines the list of meshes to scan
  20680. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20681. */
  20682. static MinMax(meshes: AbstractMesh[]): {
  20683. min: Vector3;
  20684. max: Vector3;
  20685. };
  20686. /**
  20687. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20688. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20689. * @returns a vector3
  20690. */
  20691. static Center(meshesOrMinMaxVector: {
  20692. min: Vector3;
  20693. max: Vector3;
  20694. } | AbstractMesh[]): Vector3;
  20695. /**
  20696. * Merge the array of meshes into a single mesh for performance reasons.
  20697. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20698. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20699. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20700. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20701. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20702. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20703. * @returns a new mesh
  20704. */
  20705. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20706. /** @hidden */
  20707. addInstance(instance: InstancedMesh): void;
  20708. /** @hidden */
  20709. removeInstance(instance: InstancedMesh): void;
  20710. }
  20711. }
  20712. declare module "babylonjs/Materials/material" {
  20713. import { IAnimatable } from "babylonjs/Misc/tools";
  20714. import { SmartArray } from "babylonjs/Misc/smartArray";
  20715. import { Observable } from "babylonjs/Misc/observable";
  20716. import { Nullable } from "babylonjs/types";
  20717. import { Scene } from "babylonjs/scene";
  20718. import { Matrix } from "babylonjs/Maths/math";
  20719. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20721. import { Mesh } from "babylonjs/Meshes/mesh";
  20722. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20723. import { Effect } from "babylonjs/Materials/effect";
  20724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20725. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20726. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20727. import { Animation } from "babylonjs/Animations/animation";
  20728. /**
  20729. * Base class for the main features of a material in Babylon.js
  20730. */
  20731. export class Material implements IAnimatable {
  20732. /**
  20733. * Returns the triangle fill mode
  20734. */
  20735. static readonly TriangleFillMode: number;
  20736. /**
  20737. * Returns the wireframe mode
  20738. */
  20739. static readonly WireFrameFillMode: number;
  20740. /**
  20741. * Returns the point fill mode
  20742. */
  20743. static readonly PointFillMode: number;
  20744. /**
  20745. * Returns the point list draw mode
  20746. */
  20747. static readonly PointListDrawMode: number;
  20748. /**
  20749. * Returns the line list draw mode
  20750. */
  20751. static readonly LineListDrawMode: number;
  20752. /**
  20753. * Returns the line loop draw mode
  20754. */
  20755. static readonly LineLoopDrawMode: number;
  20756. /**
  20757. * Returns the line strip draw mode
  20758. */
  20759. static readonly LineStripDrawMode: number;
  20760. /**
  20761. * Returns the triangle strip draw mode
  20762. */
  20763. static readonly TriangleStripDrawMode: number;
  20764. /**
  20765. * Returns the triangle fan draw mode
  20766. */
  20767. static readonly TriangleFanDrawMode: number;
  20768. /**
  20769. * Stores the clock-wise side orientation
  20770. */
  20771. static readonly ClockWiseSideOrientation: number;
  20772. /**
  20773. * Stores the counter clock-wise side orientation
  20774. */
  20775. static readonly CounterClockWiseSideOrientation: number;
  20776. /**
  20777. * The dirty texture flag value
  20778. */
  20779. static readonly TextureDirtyFlag: number;
  20780. /**
  20781. * The dirty light flag value
  20782. */
  20783. static readonly LightDirtyFlag: number;
  20784. /**
  20785. * The dirty fresnel flag value
  20786. */
  20787. static readonly FresnelDirtyFlag: number;
  20788. /**
  20789. * The dirty attribute flag value
  20790. */
  20791. static readonly AttributesDirtyFlag: number;
  20792. /**
  20793. * The dirty misc flag value
  20794. */
  20795. static readonly MiscDirtyFlag: number;
  20796. /**
  20797. * The all dirty flag value
  20798. */
  20799. static readonly AllDirtyFlag: number;
  20800. /**
  20801. * The ID of the material
  20802. */
  20803. id: string;
  20804. /**
  20805. * Gets or sets the unique id of the material
  20806. */
  20807. uniqueId: number;
  20808. /**
  20809. * The name of the material
  20810. */
  20811. name: string;
  20812. /**
  20813. * Gets or sets user defined metadata
  20814. */
  20815. metadata: any;
  20816. /**
  20817. * For internal use only. Please do not use.
  20818. */
  20819. reservedDataStore: any;
  20820. /**
  20821. * Specifies if the ready state should be checked on each call
  20822. */
  20823. checkReadyOnEveryCall: boolean;
  20824. /**
  20825. * Specifies if the ready state should be checked once
  20826. */
  20827. checkReadyOnlyOnce: boolean;
  20828. /**
  20829. * The state of the material
  20830. */
  20831. state: string;
  20832. /**
  20833. * The alpha value of the material
  20834. */
  20835. protected _alpha: number;
  20836. /**
  20837. * Sets the alpha value of the material
  20838. */
  20839. /**
  20840. * Gets the alpha value of the material
  20841. */
  20842. alpha: number;
  20843. /**
  20844. * Specifies if back face culling is enabled
  20845. */
  20846. protected _backFaceCulling: boolean;
  20847. /**
  20848. * Sets the back-face culling state
  20849. */
  20850. /**
  20851. * Gets the back-face culling state
  20852. */
  20853. backFaceCulling: boolean;
  20854. /**
  20855. * Stores the value for side orientation
  20856. */
  20857. sideOrientation: number;
  20858. /**
  20859. * Callback triggered when the material is compiled
  20860. */
  20861. onCompiled: (effect: Effect) => void;
  20862. /**
  20863. * Callback triggered when an error occurs
  20864. */
  20865. onError: (effect: Effect, errors: string) => void;
  20866. /**
  20867. * Callback triggered to get the render target textures
  20868. */
  20869. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20870. /**
  20871. * Gets a boolean indicating that current material needs to register RTT
  20872. */
  20873. readonly hasRenderTargetTextures: boolean;
  20874. /**
  20875. * Specifies if the material should be serialized
  20876. */
  20877. doNotSerialize: boolean;
  20878. /**
  20879. * @hidden
  20880. */
  20881. _storeEffectOnSubMeshes: boolean;
  20882. /**
  20883. * Stores the animations for the material
  20884. */
  20885. animations: Array<Animation>;
  20886. /**
  20887. * An event triggered when the material is disposed
  20888. */
  20889. onDisposeObservable: Observable<Material>;
  20890. /**
  20891. * An observer which watches for dispose events
  20892. */
  20893. private _onDisposeObserver;
  20894. private _onUnBindObservable;
  20895. /**
  20896. * Called during a dispose event
  20897. */
  20898. onDispose: () => void;
  20899. private _onBindObservable;
  20900. /**
  20901. * An event triggered when the material is bound
  20902. */
  20903. readonly onBindObservable: Observable<AbstractMesh>;
  20904. /**
  20905. * An observer which watches for bind events
  20906. */
  20907. private _onBindObserver;
  20908. /**
  20909. * Called during a bind event
  20910. */
  20911. onBind: (Mesh: AbstractMesh) => void;
  20912. /**
  20913. * An event triggered when the material is unbound
  20914. */
  20915. readonly onUnBindObservable: Observable<Material>;
  20916. /**
  20917. * Stores the value of the alpha mode
  20918. */
  20919. private _alphaMode;
  20920. /**
  20921. * Sets the value of the alpha mode.
  20922. *
  20923. * | Value | Type | Description |
  20924. * | --- | --- | --- |
  20925. * | 0 | ALPHA_DISABLE | |
  20926. * | 1 | ALPHA_ADD | |
  20927. * | 2 | ALPHA_COMBINE | |
  20928. * | 3 | ALPHA_SUBTRACT | |
  20929. * | 4 | ALPHA_MULTIPLY | |
  20930. * | 5 | ALPHA_MAXIMIZED | |
  20931. * | 6 | ALPHA_ONEONE | |
  20932. * | 7 | ALPHA_PREMULTIPLIED | |
  20933. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20934. * | 9 | ALPHA_INTERPOLATE | |
  20935. * | 10 | ALPHA_SCREENMODE | |
  20936. *
  20937. */
  20938. /**
  20939. * Gets the value of the alpha mode
  20940. */
  20941. alphaMode: number;
  20942. /**
  20943. * Stores the state of the need depth pre-pass value
  20944. */
  20945. private _needDepthPrePass;
  20946. /**
  20947. * Sets the need depth pre-pass value
  20948. */
  20949. /**
  20950. * Gets the depth pre-pass value
  20951. */
  20952. needDepthPrePass: boolean;
  20953. /**
  20954. * Specifies if depth writing should be disabled
  20955. */
  20956. disableDepthWrite: boolean;
  20957. /**
  20958. * Specifies if depth writing should be forced
  20959. */
  20960. forceDepthWrite: boolean;
  20961. /**
  20962. * Specifies if there should be a separate pass for culling
  20963. */
  20964. separateCullingPass: boolean;
  20965. /**
  20966. * Stores the state specifing if fog should be enabled
  20967. */
  20968. private _fogEnabled;
  20969. /**
  20970. * Sets the state for enabling fog
  20971. */
  20972. /**
  20973. * Gets the value of the fog enabled state
  20974. */
  20975. fogEnabled: boolean;
  20976. /**
  20977. * Stores the size of points
  20978. */
  20979. pointSize: number;
  20980. /**
  20981. * Stores the z offset value
  20982. */
  20983. zOffset: number;
  20984. /**
  20985. * Gets a value specifying if wireframe mode is enabled
  20986. */
  20987. /**
  20988. * Sets the state of wireframe mode
  20989. */
  20990. wireframe: boolean;
  20991. /**
  20992. * Gets the value specifying if point clouds are enabled
  20993. */
  20994. /**
  20995. * Sets the state of point cloud mode
  20996. */
  20997. pointsCloud: boolean;
  20998. /**
  20999. * Gets the material fill mode
  21000. */
  21001. /**
  21002. * Sets the material fill mode
  21003. */
  21004. fillMode: number;
  21005. /**
  21006. * @hidden
  21007. * Stores the effects for the material
  21008. */
  21009. _effect: Nullable<Effect>;
  21010. /**
  21011. * @hidden
  21012. * Specifies if the material was previously ready
  21013. */
  21014. _wasPreviouslyReady: boolean;
  21015. /**
  21016. * Specifies if uniform buffers should be used
  21017. */
  21018. private _useUBO;
  21019. /**
  21020. * Stores a reference to the scene
  21021. */
  21022. private _scene;
  21023. /**
  21024. * Stores the fill mode state
  21025. */
  21026. private _fillMode;
  21027. /**
  21028. * Specifies if the depth write state should be cached
  21029. */
  21030. private _cachedDepthWriteState;
  21031. /**
  21032. * Stores the uniform buffer
  21033. */
  21034. protected _uniformBuffer: UniformBuffer;
  21035. /** @hidden */
  21036. _indexInSceneMaterialArray: number;
  21037. /** @hidden */
  21038. meshMap: Nullable<{
  21039. [id: string]: AbstractMesh | undefined;
  21040. }>;
  21041. /**
  21042. * Creates a material instance
  21043. * @param name defines the name of the material
  21044. * @param scene defines the scene to reference
  21045. * @param doNotAdd specifies if the material should be added to the scene
  21046. */
  21047. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21048. /**
  21049. * Returns a string representation of the current material
  21050. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21051. * @returns a string with material information
  21052. */
  21053. toString(fullDetails?: boolean): string;
  21054. /**
  21055. * Gets the class name of the material
  21056. * @returns a string with the class name of the material
  21057. */
  21058. getClassName(): string;
  21059. /**
  21060. * Specifies if updates for the material been locked
  21061. */
  21062. readonly isFrozen: boolean;
  21063. /**
  21064. * Locks updates for the material
  21065. */
  21066. freeze(): void;
  21067. /**
  21068. * Unlocks updates for the material
  21069. */
  21070. unfreeze(): void;
  21071. /**
  21072. * Specifies if the material is ready to be used
  21073. * @param mesh defines the mesh to check
  21074. * @param useInstances specifies if instances should be used
  21075. * @returns a boolean indicating if the material is ready to be used
  21076. */
  21077. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21078. /**
  21079. * Specifies that the submesh is ready to be used
  21080. * @param mesh defines the mesh to check
  21081. * @param subMesh defines which submesh to check
  21082. * @param useInstances specifies that instances should be used
  21083. * @returns a boolean indicating that the submesh is ready or not
  21084. */
  21085. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21086. /**
  21087. * Returns the material effect
  21088. * @returns the effect associated with the material
  21089. */
  21090. getEffect(): Nullable<Effect>;
  21091. /**
  21092. * Returns the current scene
  21093. * @returns a Scene
  21094. */
  21095. getScene(): Scene;
  21096. /**
  21097. * Specifies if the material will require alpha blending
  21098. * @returns a boolean specifying if alpha blending is needed
  21099. */
  21100. needAlphaBlending(): boolean;
  21101. /**
  21102. * Specifies if the mesh will require alpha blending
  21103. * @param mesh defines the mesh to check
  21104. * @returns a boolean specifying if alpha blending is needed for the mesh
  21105. */
  21106. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21107. /**
  21108. * Specifies if this material should be rendered in alpha test mode
  21109. * @returns a boolean specifying if an alpha test is needed.
  21110. */
  21111. needAlphaTesting(): boolean;
  21112. /**
  21113. * Gets the texture used for the alpha test
  21114. * @returns the texture to use for alpha testing
  21115. */
  21116. getAlphaTestTexture(): Nullable<BaseTexture>;
  21117. /**
  21118. * Marks the material to indicate that it needs to be re-calculated
  21119. */
  21120. markDirty(): void;
  21121. /** @hidden */
  21122. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21123. /**
  21124. * Binds the material to the mesh
  21125. * @param world defines the world transformation matrix
  21126. * @param mesh defines the mesh to bind the material to
  21127. */
  21128. bind(world: Matrix, mesh?: Mesh): void;
  21129. /**
  21130. * Binds the submesh to the material
  21131. * @param world defines the world transformation matrix
  21132. * @param mesh defines the mesh containing the submesh
  21133. * @param subMesh defines the submesh to bind the material to
  21134. */
  21135. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21136. /**
  21137. * Binds the world matrix to the material
  21138. * @param world defines the world transformation matrix
  21139. */
  21140. bindOnlyWorldMatrix(world: Matrix): void;
  21141. /**
  21142. * Binds the scene's uniform buffer to the effect.
  21143. * @param effect defines the effect to bind to the scene uniform buffer
  21144. * @param sceneUbo defines the uniform buffer storing scene data
  21145. */
  21146. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21147. /**
  21148. * Binds the view matrix to the effect
  21149. * @param effect defines the effect to bind the view matrix to
  21150. */
  21151. bindView(effect: Effect): void;
  21152. /**
  21153. * Binds the view projection matrix to the effect
  21154. * @param effect defines the effect to bind the view projection matrix to
  21155. */
  21156. bindViewProjection(effect: Effect): void;
  21157. /**
  21158. * Specifies if material alpha testing should be turned on for the mesh
  21159. * @param mesh defines the mesh to check
  21160. */
  21161. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21162. /**
  21163. * Processes to execute after binding the material to a mesh
  21164. * @param mesh defines the rendered mesh
  21165. */
  21166. protected _afterBind(mesh?: Mesh): void;
  21167. /**
  21168. * Unbinds the material from the mesh
  21169. */
  21170. unbind(): void;
  21171. /**
  21172. * Gets the active textures from the material
  21173. * @returns an array of textures
  21174. */
  21175. getActiveTextures(): BaseTexture[];
  21176. /**
  21177. * Specifies if the material uses a texture
  21178. * @param texture defines the texture to check against the material
  21179. * @returns a boolean specifying if the material uses the texture
  21180. */
  21181. hasTexture(texture: BaseTexture): boolean;
  21182. /**
  21183. * Makes a duplicate of the material, and gives it a new name
  21184. * @param name defines the new name for the duplicated material
  21185. * @returns the cloned material
  21186. */
  21187. clone(name: string): Nullable<Material>;
  21188. /**
  21189. * Gets the meshes bound to the material
  21190. * @returns an array of meshes bound to the material
  21191. */
  21192. getBindedMeshes(): AbstractMesh[];
  21193. /**
  21194. * Force shader compilation
  21195. * @param mesh defines the mesh associated with this material
  21196. * @param onCompiled defines a function to execute once the material is compiled
  21197. * @param options defines the options to configure the compilation
  21198. */
  21199. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21200. clipPlane: boolean;
  21201. }>): void;
  21202. /**
  21203. * Force shader compilation
  21204. * @param mesh defines the mesh that will use this material
  21205. * @param options defines additional options for compiling the shaders
  21206. * @returns a promise that resolves when the compilation completes
  21207. */
  21208. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21209. clipPlane: boolean;
  21210. }>): Promise<void>;
  21211. private static readonly _ImageProcessingDirtyCallBack;
  21212. private static readonly _TextureDirtyCallBack;
  21213. private static readonly _FresnelDirtyCallBack;
  21214. private static readonly _MiscDirtyCallBack;
  21215. private static readonly _LightsDirtyCallBack;
  21216. private static readonly _AttributeDirtyCallBack;
  21217. private static _FresnelAndMiscDirtyCallBack;
  21218. private static _TextureAndMiscDirtyCallBack;
  21219. private static readonly _DirtyCallbackArray;
  21220. private static readonly _RunDirtyCallBacks;
  21221. /**
  21222. * Marks a define in the material to indicate that it needs to be re-computed
  21223. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21224. */
  21225. markAsDirty(flag: number): void;
  21226. /**
  21227. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21228. * @param func defines a function which checks material defines against the submeshes
  21229. */
  21230. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21231. /**
  21232. * Indicates that image processing needs to be re-calculated for all submeshes
  21233. */
  21234. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21235. /**
  21236. * Indicates that textures need to be re-calculated for all submeshes
  21237. */
  21238. protected _markAllSubMeshesAsTexturesDirty(): void;
  21239. /**
  21240. * Indicates that fresnel needs to be re-calculated for all submeshes
  21241. */
  21242. protected _markAllSubMeshesAsFresnelDirty(): void;
  21243. /**
  21244. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21245. */
  21246. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21247. /**
  21248. * Indicates that lights need to be re-calculated for all submeshes
  21249. */
  21250. protected _markAllSubMeshesAsLightsDirty(): void;
  21251. /**
  21252. * Indicates that attributes need to be re-calculated for all submeshes
  21253. */
  21254. protected _markAllSubMeshesAsAttributesDirty(): void;
  21255. /**
  21256. * Indicates that misc needs to be re-calculated for all submeshes
  21257. */
  21258. protected _markAllSubMeshesAsMiscDirty(): void;
  21259. /**
  21260. * Indicates that textures and misc need to be re-calculated for all submeshes
  21261. */
  21262. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21263. /**
  21264. * Disposes the material
  21265. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21266. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21267. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21268. */
  21269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21270. /** @hidden */
  21271. private releaseVertexArrayObject;
  21272. /**
  21273. * Serializes this material
  21274. * @returns the serialized material object
  21275. */
  21276. serialize(): any;
  21277. /**
  21278. * Creates a material from parsed material data
  21279. * @param parsedMaterial defines parsed material data
  21280. * @param scene defines the hosting scene
  21281. * @param rootUrl defines the root URL to use to load textures
  21282. * @returns a new material
  21283. */
  21284. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21285. }
  21286. }
  21287. declare module "babylonjs/Meshes/subMesh" {
  21288. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21289. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21290. import { Engine } from "babylonjs/Engines/engine";
  21291. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21292. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21293. import { Effect } from "babylonjs/Materials/effect";
  21294. import { Collider } from "babylonjs/Collisions/collider";
  21295. import { Material } from "babylonjs/Materials/material";
  21296. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21298. import { Mesh } from "babylonjs/Meshes/mesh";
  21299. import { Ray } from "babylonjs/Culling/ray";
  21300. /**
  21301. * Base class for submeshes
  21302. */
  21303. export class BaseSubMesh {
  21304. /** @hidden */
  21305. _materialDefines: Nullable<MaterialDefines>;
  21306. /** @hidden */
  21307. _materialEffect: Nullable<Effect>;
  21308. /**
  21309. * Gets associated effect
  21310. */
  21311. readonly effect: Nullable<Effect>;
  21312. /**
  21313. * Sets associated effect (effect used to render this submesh)
  21314. * @param effect defines the effect to associate with
  21315. * @param defines defines the set of defines used to compile this effect
  21316. */
  21317. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21318. }
  21319. /**
  21320. * Defines a subdivision inside a mesh
  21321. */
  21322. export class SubMesh extends BaseSubMesh implements ICullable {
  21323. /** the material index to use */
  21324. materialIndex: number;
  21325. /** vertex index start */
  21326. verticesStart: number;
  21327. /** vertices count */
  21328. verticesCount: number;
  21329. /** index start */
  21330. indexStart: number;
  21331. /** indices count */
  21332. indexCount: number;
  21333. /** @hidden */
  21334. _linesIndexCount: number;
  21335. private _mesh;
  21336. private _renderingMesh;
  21337. private _boundingInfo;
  21338. private _linesIndexBuffer;
  21339. /** @hidden */
  21340. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21341. /** @hidden */
  21342. _trianglePlanes: Plane[];
  21343. /** @hidden */
  21344. _lastColliderTransformMatrix: Matrix;
  21345. /** @hidden */
  21346. _renderId: number;
  21347. /** @hidden */
  21348. _alphaIndex: number;
  21349. /** @hidden */
  21350. _distanceToCamera: number;
  21351. /** @hidden */
  21352. _id: number;
  21353. private _currentMaterial;
  21354. /**
  21355. * Add a new submesh to a mesh
  21356. * @param materialIndex defines the material index to use
  21357. * @param verticesStart defines vertex index start
  21358. * @param verticesCount defines vertices count
  21359. * @param indexStart defines index start
  21360. * @param indexCount defines indices count
  21361. * @param mesh defines the parent mesh
  21362. * @param renderingMesh defines an optional rendering mesh
  21363. * @param createBoundingBox defines if bounding box should be created for this submesh
  21364. * @returns the new submesh
  21365. */
  21366. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21367. /**
  21368. * Creates a new submesh
  21369. * @param materialIndex defines the material index to use
  21370. * @param verticesStart defines vertex index start
  21371. * @param verticesCount defines vertices count
  21372. * @param indexStart defines index start
  21373. * @param indexCount defines indices count
  21374. * @param mesh defines the parent mesh
  21375. * @param renderingMesh defines an optional rendering mesh
  21376. * @param createBoundingBox defines if bounding box should be created for this submesh
  21377. */
  21378. constructor(
  21379. /** the material index to use */
  21380. materialIndex: number,
  21381. /** vertex index start */
  21382. verticesStart: number,
  21383. /** vertices count */
  21384. verticesCount: number,
  21385. /** index start */
  21386. indexStart: number,
  21387. /** indices count */
  21388. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21389. /**
  21390. * Returns true if this submesh covers the entire parent mesh
  21391. * @ignorenaming
  21392. */
  21393. readonly IsGlobal: boolean;
  21394. /**
  21395. * Returns the submesh BoudingInfo object
  21396. * @returns current bounding info (or mesh's one if the submesh is global)
  21397. */
  21398. getBoundingInfo(): BoundingInfo;
  21399. /**
  21400. * Sets the submesh BoundingInfo
  21401. * @param boundingInfo defines the new bounding info to use
  21402. * @returns the SubMesh
  21403. */
  21404. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21405. /**
  21406. * Returns the mesh of the current submesh
  21407. * @return the parent mesh
  21408. */
  21409. getMesh(): AbstractMesh;
  21410. /**
  21411. * Returns the rendering mesh of the submesh
  21412. * @returns the rendering mesh (could be different from parent mesh)
  21413. */
  21414. getRenderingMesh(): Mesh;
  21415. /**
  21416. * Returns the submesh material
  21417. * @returns null or the current material
  21418. */
  21419. getMaterial(): Nullable<Material>;
  21420. /**
  21421. * Sets a new updated BoundingInfo object to the submesh
  21422. * @returns the SubMesh
  21423. */
  21424. refreshBoundingInfo(): SubMesh;
  21425. /** @hidden */
  21426. _checkCollision(collider: Collider): boolean;
  21427. /**
  21428. * Updates the submesh BoundingInfo
  21429. * @param world defines the world matrix to use to update the bounding info
  21430. * @returns the submesh
  21431. */
  21432. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21433. /**
  21434. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21435. * @param frustumPlanes defines the frustum planes
  21436. * @returns true if the submesh is intersecting with the frustum
  21437. */
  21438. isInFrustum(frustumPlanes: Plane[]): boolean;
  21439. /**
  21440. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21441. * @param frustumPlanes defines the frustum planes
  21442. * @returns true if the submesh is inside the frustum
  21443. */
  21444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21445. /**
  21446. * Renders the submesh
  21447. * @param enableAlphaMode defines if alpha needs to be used
  21448. * @returns the submesh
  21449. */
  21450. render(enableAlphaMode: boolean): SubMesh;
  21451. /**
  21452. * @hidden
  21453. */
  21454. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21455. /**
  21456. * Checks if the submesh intersects with a ray
  21457. * @param ray defines the ray to test
  21458. * @returns true is the passed ray intersects the submesh bounding box
  21459. */
  21460. canIntersects(ray: Ray): boolean;
  21461. /**
  21462. * Intersects current submesh with a ray
  21463. * @param ray defines the ray to test
  21464. * @param positions defines mesh's positions array
  21465. * @param indices defines mesh's indices array
  21466. * @param fastCheck defines if only bounding info should be used
  21467. * @returns intersection info or null if no intersection
  21468. */
  21469. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21470. /** @hidden */
  21471. private _intersectLines;
  21472. /** @hidden */
  21473. private _intersectTriangles;
  21474. /** @hidden */
  21475. _rebuild(): void;
  21476. /**
  21477. * Creates a new submesh from the passed mesh
  21478. * @param newMesh defines the new hosting mesh
  21479. * @param newRenderingMesh defines an optional rendering mesh
  21480. * @returns the new submesh
  21481. */
  21482. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21483. /**
  21484. * Release associated resources
  21485. */
  21486. dispose(): void;
  21487. /**
  21488. * Gets the class name
  21489. * @returns the string "SubMesh".
  21490. */
  21491. getClassName(): string;
  21492. /**
  21493. * Creates a new submesh from indices data
  21494. * @param materialIndex the index of the main mesh material
  21495. * @param startIndex the index where to start the copy in the mesh indices array
  21496. * @param indexCount the number of indices to copy then from the startIndex
  21497. * @param mesh the main mesh to create the submesh from
  21498. * @param renderingMesh the optional rendering mesh
  21499. * @returns a new submesh
  21500. */
  21501. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21502. }
  21503. }
  21504. declare module "babylonjs/Meshes/geometry" {
  21505. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21506. import { Scene } from "babylonjs/scene";
  21507. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21508. import { Engine } from "babylonjs/Engines/engine";
  21509. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21510. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21511. import { Effect } from "babylonjs/Materials/effect";
  21512. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21513. import { Mesh } from "babylonjs/Meshes/mesh";
  21514. /**
  21515. * Class used to store geometry data (vertex buffers + index buffer)
  21516. */
  21517. export class Geometry implements IGetSetVerticesData {
  21518. /**
  21519. * Gets or sets the ID of the geometry
  21520. */
  21521. id: string;
  21522. /**
  21523. * Gets or sets the unique ID of the geometry
  21524. */
  21525. uniqueId: number;
  21526. /**
  21527. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21528. */
  21529. delayLoadState: number;
  21530. /**
  21531. * Gets the file containing the data to load when running in delay load state
  21532. */
  21533. delayLoadingFile: Nullable<string>;
  21534. /**
  21535. * Callback called when the geometry is updated
  21536. */
  21537. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21538. private _scene;
  21539. private _engine;
  21540. private _meshes;
  21541. private _totalVertices;
  21542. /** @hidden */
  21543. _indices: IndicesArray;
  21544. /** @hidden */
  21545. _vertexBuffers: {
  21546. [key: string]: VertexBuffer;
  21547. };
  21548. private _isDisposed;
  21549. private _extend;
  21550. private _boundingBias;
  21551. /** @hidden */
  21552. _delayInfo: Array<string>;
  21553. private _indexBuffer;
  21554. private _indexBufferIsUpdatable;
  21555. /** @hidden */
  21556. _boundingInfo: Nullable<BoundingInfo>;
  21557. /** @hidden */
  21558. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21559. /** @hidden */
  21560. _softwareSkinningFrameId: number;
  21561. private _vertexArrayObjects;
  21562. private _updatable;
  21563. /** @hidden */
  21564. _positions: Nullable<Vector3[]>;
  21565. /**
  21566. * 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
  21567. */
  21568. /**
  21569. * 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
  21570. */
  21571. boundingBias: Vector2;
  21572. /**
  21573. * Static function used to attach a new empty geometry to a mesh
  21574. * @param mesh defines the mesh to attach the geometry to
  21575. * @returns the new Geometry
  21576. */
  21577. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21578. /**
  21579. * Creates a new geometry
  21580. * @param id defines the unique ID
  21581. * @param scene defines the hosting scene
  21582. * @param vertexData defines the VertexData used to get geometry data
  21583. * @param updatable defines if geometry must be updatable (false by default)
  21584. * @param mesh defines the mesh that will be associated with the geometry
  21585. */
  21586. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21587. /**
  21588. * Gets the current extend of the geometry
  21589. */
  21590. readonly extend: {
  21591. minimum: Vector3;
  21592. maximum: Vector3;
  21593. };
  21594. /**
  21595. * Gets the hosting scene
  21596. * @returns the hosting Scene
  21597. */
  21598. getScene(): Scene;
  21599. /**
  21600. * Gets the hosting engine
  21601. * @returns the hosting Engine
  21602. */
  21603. getEngine(): Engine;
  21604. /**
  21605. * Defines if the geometry is ready to use
  21606. * @returns true if the geometry is ready to be used
  21607. */
  21608. isReady(): boolean;
  21609. /**
  21610. * Gets a value indicating that the geometry should not be serialized
  21611. */
  21612. readonly doNotSerialize: boolean;
  21613. /** @hidden */
  21614. _rebuild(): void;
  21615. /**
  21616. * Affects all geometry data in one call
  21617. * @param vertexData defines the geometry data
  21618. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21619. */
  21620. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21621. /**
  21622. * Set specific vertex data
  21623. * @param kind defines the data kind (Position, normal, etc...)
  21624. * @param data defines the vertex data to use
  21625. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21626. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21627. */
  21628. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21629. /**
  21630. * Removes a specific vertex data
  21631. * @param kind defines the data kind (Position, normal, etc...)
  21632. */
  21633. removeVerticesData(kind: string): void;
  21634. /**
  21635. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21636. * @param buffer defines the vertex buffer to use
  21637. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21638. */
  21639. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21640. /**
  21641. * Update a specific vertex buffer
  21642. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21643. * It will do nothing if the buffer is not updatable
  21644. * @param kind defines the data kind (Position, normal, etc...)
  21645. * @param data defines the data to use
  21646. * @param offset defines the offset in the target buffer where to store the data
  21647. * @param useBytes set to true if the offset is in bytes
  21648. */
  21649. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21650. /**
  21651. * Update a specific vertex buffer
  21652. * This function will create a new buffer if the current one is not updatable
  21653. * @param kind defines the data kind (Position, normal, etc...)
  21654. * @param data defines the data to use
  21655. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21656. */
  21657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21658. private _updateBoundingInfo;
  21659. /** @hidden */
  21660. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21661. /**
  21662. * Gets total number of vertices
  21663. * @returns the total number of vertices
  21664. */
  21665. getTotalVertices(): number;
  21666. /**
  21667. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21668. * @param kind defines the data kind (Position, normal, etc...)
  21669. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21670. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21671. * @returns a float array containing vertex data
  21672. */
  21673. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21674. /**
  21675. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21676. * @param kind defines the data kind (Position, normal, etc...)
  21677. * @returns true if the vertex buffer with the specified kind is updatable
  21678. */
  21679. isVertexBufferUpdatable(kind: string): boolean;
  21680. /**
  21681. * Gets a specific vertex buffer
  21682. * @param kind defines the data kind (Position, normal, etc...)
  21683. * @returns a VertexBuffer
  21684. */
  21685. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21686. /**
  21687. * Returns all vertex buffers
  21688. * @return an object holding all vertex buffers indexed by kind
  21689. */
  21690. getVertexBuffers(): Nullable<{
  21691. [key: string]: VertexBuffer;
  21692. }>;
  21693. /**
  21694. * Gets a boolean indicating if specific vertex buffer is present
  21695. * @param kind defines the data kind (Position, normal, etc...)
  21696. * @returns true if data is present
  21697. */
  21698. isVerticesDataPresent(kind: string): boolean;
  21699. /**
  21700. * Gets a list of all attached data kinds (Position, normal, etc...)
  21701. * @returns a list of string containing all kinds
  21702. */
  21703. getVerticesDataKinds(): string[];
  21704. /**
  21705. * Update index buffer
  21706. * @param indices defines the indices to store in the index buffer
  21707. * @param offset defines the offset in the target buffer where to store the data
  21708. */
  21709. updateIndices(indices: IndicesArray, offset?: number): void;
  21710. /**
  21711. * Creates a new index buffer
  21712. * @param indices defines the indices to store in the index buffer
  21713. * @param totalVertices defines the total number of vertices (could be null)
  21714. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21715. */
  21716. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21717. /**
  21718. * Return the total number of indices
  21719. * @returns the total number of indices
  21720. */
  21721. getTotalIndices(): number;
  21722. /**
  21723. * Gets the index buffer array
  21724. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21725. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21726. * @returns the index buffer array
  21727. */
  21728. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21729. /**
  21730. * Gets the index buffer
  21731. * @return the index buffer
  21732. */
  21733. getIndexBuffer(): Nullable<WebGLBuffer>;
  21734. /** @hidden */
  21735. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21736. /**
  21737. * Release the associated resources for a specific mesh
  21738. * @param mesh defines the source mesh
  21739. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21740. */
  21741. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21742. /**
  21743. * Apply current geometry to a given mesh
  21744. * @param mesh defines the mesh to apply geometry to
  21745. */
  21746. applyToMesh(mesh: Mesh): void;
  21747. private _updateExtend;
  21748. private _applyToMesh;
  21749. private notifyUpdate;
  21750. /**
  21751. * Load the geometry if it was flagged as delay loaded
  21752. * @param scene defines the hosting scene
  21753. * @param onLoaded defines a callback called when the geometry is loaded
  21754. */
  21755. load(scene: Scene, onLoaded?: () => void): void;
  21756. private _queueLoad;
  21757. /**
  21758. * Invert the geometry to move from a right handed system to a left handed one.
  21759. */
  21760. toLeftHanded(): void;
  21761. /** @hidden */
  21762. _resetPointsArrayCache(): void;
  21763. /** @hidden */
  21764. _generatePointsArray(): boolean;
  21765. /**
  21766. * Gets a value indicating if the geometry is disposed
  21767. * @returns true if the geometry was disposed
  21768. */
  21769. isDisposed(): boolean;
  21770. private _disposeVertexArrayObjects;
  21771. /**
  21772. * Free all associated resources
  21773. */
  21774. dispose(): void;
  21775. /**
  21776. * Clone the current geometry into a new geometry
  21777. * @param id defines the unique ID of the new geometry
  21778. * @returns a new geometry object
  21779. */
  21780. copy(id: string): Geometry;
  21781. /**
  21782. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21783. * @return a JSON representation of the current geometry data (without the vertices data)
  21784. */
  21785. serialize(): any;
  21786. private toNumberArray;
  21787. /**
  21788. * Serialize all vertices data into a JSON oject
  21789. * @returns a JSON representation of the current geometry data
  21790. */
  21791. serializeVerticeData(): any;
  21792. /**
  21793. * Extracts a clone of a mesh geometry
  21794. * @param mesh defines the source mesh
  21795. * @param id defines the unique ID of the new geometry object
  21796. * @returns the new geometry object
  21797. */
  21798. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21799. /**
  21800. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21801. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21802. * Be aware Math.random() could cause collisions, but:
  21803. * "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"
  21804. * @returns a string containing a new GUID
  21805. */
  21806. static RandomId(): string;
  21807. /** @hidden */
  21808. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21809. private static _CleanMatricesWeights;
  21810. /**
  21811. * Create a new geometry from persisted data (Using .babylon file format)
  21812. * @param parsedVertexData defines the persisted data
  21813. * @param scene defines the hosting scene
  21814. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21815. * @returns the new geometry object
  21816. */
  21817. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21818. }
  21819. }
  21820. declare module "babylonjs/Meshes/mesh.vertexData" {
  21821. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21822. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  21823. import { Geometry } from "babylonjs/Meshes/geometry";
  21824. import { Mesh } from "babylonjs/Meshes/mesh";
  21825. /**
  21826. * Define an interface for all classes that will get and set the data on vertices
  21827. */
  21828. export interface IGetSetVerticesData {
  21829. /**
  21830. * Gets a boolean indicating if specific vertex data is present
  21831. * @param kind defines the vertex data kind to use
  21832. * @returns true is data kind is present
  21833. */
  21834. isVerticesDataPresent(kind: string): boolean;
  21835. /**
  21836. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21837. * @param kind defines the data kind (Position, normal, etc...)
  21838. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21839. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21840. * @returns a float array containing vertex data
  21841. */
  21842. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21843. /**
  21844. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21845. * @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.
  21846. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21847. * @returns the indices array or an empty array if the mesh has no geometry
  21848. */
  21849. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21850. /**
  21851. * Set specific vertex data
  21852. * @param kind defines the data kind (Position, normal, etc...)
  21853. * @param data defines the vertex data to use
  21854. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21855. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21856. */
  21857. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21858. /**
  21859. * Update a specific associated vertex buffer
  21860. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21861. * - VertexBuffer.PositionKind
  21862. * - VertexBuffer.UVKind
  21863. * - VertexBuffer.UV2Kind
  21864. * - VertexBuffer.UV3Kind
  21865. * - VertexBuffer.UV4Kind
  21866. * - VertexBuffer.UV5Kind
  21867. * - VertexBuffer.UV6Kind
  21868. * - VertexBuffer.ColorKind
  21869. * - VertexBuffer.MatricesIndicesKind
  21870. * - VertexBuffer.MatricesIndicesExtraKind
  21871. * - VertexBuffer.MatricesWeightsKind
  21872. * - VertexBuffer.MatricesWeightsExtraKind
  21873. * @param data defines the data source
  21874. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21875. * @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)
  21876. */
  21877. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21878. /**
  21879. * Creates a new index buffer
  21880. * @param indices defines the indices to store in the index buffer
  21881. * @param totalVertices defines the total number of vertices (could be null)
  21882. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21883. */
  21884. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21885. }
  21886. /**
  21887. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21888. */
  21889. export class VertexData {
  21890. /**
  21891. * Mesh side orientation : usually the external or front surface
  21892. */
  21893. static readonly FRONTSIDE: number;
  21894. /**
  21895. * Mesh side orientation : usually the internal or back surface
  21896. */
  21897. static readonly BACKSIDE: number;
  21898. /**
  21899. * Mesh side orientation : both internal and external or front and back surfaces
  21900. */
  21901. static readonly DOUBLESIDE: number;
  21902. /**
  21903. * Mesh side orientation : by default, `FRONTSIDE`
  21904. */
  21905. static readonly DEFAULTSIDE: number;
  21906. /**
  21907. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21908. */
  21909. positions: Nullable<FloatArray>;
  21910. /**
  21911. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21912. */
  21913. normals: Nullable<FloatArray>;
  21914. /**
  21915. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21916. */
  21917. tangents: Nullable<FloatArray>;
  21918. /**
  21919. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21920. */
  21921. uvs: Nullable<FloatArray>;
  21922. /**
  21923. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21924. */
  21925. uvs2: Nullable<FloatArray>;
  21926. /**
  21927. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21928. */
  21929. uvs3: Nullable<FloatArray>;
  21930. /**
  21931. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21932. */
  21933. uvs4: Nullable<FloatArray>;
  21934. /**
  21935. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21936. */
  21937. uvs5: Nullable<FloatArray>;
  21938. /**
  21939. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21940. */
  21941. uvs6: Nullable<FloatArray>;
  21942. /**
  21943. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21944. */
  21945. colors: Nullable<FloatArray>;
  21946. /**
  21947. * 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).
  21948. */
  21949. matricesIndices: Nullable<FloatArray>;
  21950. /**
  21951. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21952. */
  21953. matricesWeights: Nullable<FloatArray>;
  21954. /**
  21955. * An array extending the number of possible indices
  21956. */
  21957. matricesIndicesExtra: Nullable<FloatArray>;
  21958. /**
  21959. * An array extending the number of possible weights when the number of indices is extended
  21960. */
  21961. matricesWeightsExtra: Nullable<FloatArray>;
  21962. /**
  21963. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21964. */
  21965. indices: Nullable<IndicesArray>;
  21966. /**
  21967. * Uses the passed data array to set the set the values for the specified kind of data
  21968. * @param data a linear array of floating numbers
  21969. * @param kind the type of data that is being set, eg positions, colors etc
  21970. */
  21971. set(data: FloatArray, kind: string): void;
  21972. /**
  21973. * Associates the vertexData to the passed Mesh.
  21974. * Sets it as updatable or not (default `false`)
  21975. * @param mesh the mesh the vertexData is applied to
  21976. * @param updatable when used and having the value true allows new data to update the vertexData
  21977. * @returns the VertexData
  21978. */
  21979. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21980. /**
  21981. * Associates the vertexData to the passed Geometry.
  21982. * Sets it as updatable or not (default `false`)
  21983. * @param geometry the geometry the vertexData is applied to
  21984. * @param updatable when used and having the value true allows new data to update the vertexData
  21985. * @returns VertexData
  21986. */
  21987. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21988. /**
  21989. * Updates the associated mesh
  21990. * @param mesh the mesh to be updated
  21991. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21992. * @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
  21993. * @returns VertexData
  21994. */
  21995. updateMesh(mesh: Mesh): VertexData;
  21996. /**
  21997. * Updates the associated geometry
  21998. * @param geometry the geometry to be updated
  21999. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22000. * @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
  22001. * @returns VertexData.
  22002. */
  22003. updateGeometry(geometry: Geometry): VertexData;
  22004. private _applyTo;
  22005. private _update;
  22006. /**
  22007. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22008. * @param matrix the transforming matrix
  22009. * @returns the VertexData
  22010. */
  22011. transform(matrix: Matrix): VertexData;
  22012. /**
  22013. * Merges the passed VertexData into the current one
  22014. * @param other the VertexData to be merged into the current one
  22015. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22016. * @returns the modified VertexData
  22017. */
  22018. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22019. private _mergeElement;
  22020. private _validate;
  22021. /**
  22022. * Serializes the VertexData
  22023. * @returns a serialized object
  22024. */
  22025. serialize(): any;
  22026. /**
  22027. * Extracts the vertexData from a mesh
  22028. * @param mesh the mesh from which to extract the VertexData
  22029. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22031. * @returns the object VertexData associated to the passed mesh
  22032. */
  22033. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22034. /**
  22035. * Extracts the vertexData from the geometry
  22036. * @param geometry the geometry from which to extract the VertexData
  22037. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22038. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22039. * @returns the object VertexData associated to the passed mesh
  22040. */
  22041. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22042. private static _ExtractFrom;
  22043. /**
  22044. * Creates the VertexData for a Ribbon
  22045. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22046. * * pathArray array of paths, each of which an array of successive Vector3
  22047. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22048. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22049. * * 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
  22050. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22051. * * 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)
  22052. * * 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)
  22053. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22054. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22055. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22056. * @returns the VertexData of the ribbon
  22057. */
  22058. static CreateRibbon(options: {
  22059. pathArray: Vector3[][];
  22060. closeArray?: boolean;
  22061. closePath?: boolean;
  22062. offset?: number;
  22063. sideOrientation?: number;
  22064. frontUVs?: Vector4;
  22065. backUVs?: Vector4;
  22066. invertUV?: boolean;
  22067. uvs?: Vector2[];
  22068. colors?: Color4[];
  22069. }): VertexData;
  22070. /**
  22071. * Creates the VertexData for a box
  22072. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22073. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22074. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22075. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22076. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22077. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22078. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22080. * * 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)
  22081. * * 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)
  22082. * @returns the VertexData of the box
  22083. */
  22084. static CreateBox(options: {
  22085. size?: number;
  22086. width?: number;
  22087. height?: number;
  22088. depth?: number;
  22089. faceUV?: Vector4[];
  22090. faceColors?: Color4[];
  22091. sideOrientation?: number;
  22092. frontUVs?: Vector4;
  22093. backUVs?: Vector4;
  22094. }): VertexData;
  22095. /**
  22096. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22098. * * segments sets the number of horizontal strips optional, default 32
  22099. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22100. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22101. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22102. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22103. * * 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
  22104. * * 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
  22105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22106. * * 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)
  22107. * * 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)
  22108. * @returns the VertexData of the ellipsoid
  22109. */
  22110. static CreateSphere(options: {
  22111. segments?: number;
  22112. diameter?: number;
  22113. diameterX?: number;
  22114. diameterY?: number;
  22115. diameterZ?: number;
  22116. arc?: number;
  22117. slice?: number;
  22118. sideOrientation?: number;
  22119. frontUVs?: Vector4;
  22120. backUVs?: Vector4;
  22121. }): VertexData;
  22122. /**
  22123. * Creates the VertexData for a cylinder, cone or prism
  22124. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22125. * * height sets the height (y direction) of the cylinder, optional, default 2
  22126. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22127. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22128. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22129. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22130. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22131. * * 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
  22132. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22133. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22134. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22135. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22137. * * 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)
  22138. * * 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)
  22139. * @returns the VertexData of the cylinder, cone or prism
  22140. */
  22141. static CreateCylinder(options: {
  22142. height?: number;
  22143. diameterTop?: number;
  22144. diameterBottom?: number;
  22145. diameter?: number;
  22146. tessellation?: number;
  22147. subdivisions?: number;
  22148. arc?: number;
  22149. faceColors?: Color4[];
  22150. faceUV?: Vector4[];
  22151. hasRings?: boolean;
  22152. enclose?: boolean;
  22153. sideOrientation?: number;
  22154. frontUVs?: Vector4;
  22155. backUVs?: Vector4;
  22156. }): VertexData;
  22157. /**
  22158. * Creates the VertexData for a torus
  22159. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22160. * * diameter the diameter of the torus, optional default 1
  22161. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22162. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22164. * * 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)
  22165. * * 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)
  22166. * @returns the VertexData of the torus
  22167. */
  22168. static CreateTorus(options: {
  22169. diameter?: number;
  22170. thickness?: number;
  22171. tessellation?: number;
  22172. sideOrientation?: number;
  22173. frontUVs?: Vector4;
  22174. backUVs?: Vector4;
  22175. }): VertexData;
  22176. /**
  22177. * Creates the VertexData of the LineSystem
  22178. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22179. * - lines an array of lines, each line being an array of successive Vector3
  22180. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22181. * @returns the VertexData of the LineSystem
  22182. */
  22183. static CreateLineSystem(options: {
  22184. lines: Vector3[][];
  22185. colors?: Nullable<Color4[][]>;
  22186. }): VertexData;
  22187. /**
  22188. * Create the VertexData for a DashedLines
  22189. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22190. * - points an array successive Vector3
  22191. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22192. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22193. * - dashNb the intended total number of dashes, optional, default 200
  22194. * @returns the VertexData for the DashedLines
  22195. */
  22196. static CreateDashedLines(options: {
  22197. points: Vector3[];
  22198. dashSize?: number;
  22199. gapSize?: number;
  22200. dashNb?: number;
  22201. }): VertexData;
  22202. /**
  22203. * Creates the VertexData for a Ground
  22204. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22205. * - width the width (x direction) of the ground, optional, default 1
  22206. * - height the height (z direction) of the ground, optional, default 1
  22207. * - subdivisions the number of subdivisions per side, optional, default 1
  22208. * @returns the VertexData of the Ground
  22209. */
  22210. static CreateGround(options: {
  22211. width?: number;
  22212. height?: number;
  22213. subdivisions?: number;
  22214. subdivisionsX?: number;
  22215. subdivisionsY?: number;
  22216. }): VertexData;
  22217. /**
  22218. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22219. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22220. * * xmin the ground minimum X coordinate, optional, default -1
  22221. * * zmin the ground minimum Z coordinate, optional, default -1
  22222. * * xmax the ground maximum X coordinate, optional, default 1
  22223. * * zmax the ground maximum Z coordinate, optional, default 1
  22224. * * 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}
  22225. * * 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}
  22226. * @returns the VertexData of the TiledGround
  22227. */
  22228. static CreateTiledGround(options: {
  22229. xmin: number;
  22230. zmin: number;
  22231. xmax: number;
  22232. zmax: number;
  22233. subdivisions?: {
  22234. w: number;
  22235. h: number;
  22236. };
  22237. precision?: {
  22238. w: number;
  22239. h: number;
  22240. };
  22241. }): VertexData;
  22242. /**
  22243. * Creates the VertexData of the Ground designed from a heightmap
  22244. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22245. * * width the width (x direction) of the ground
  22246. * * height the height (z direction) of the ground
  22247. * * subdivisions the number of subdivisions per side
  22248. * * minHeight the minimum altitude on the ground, optional, default 0
  22249. * * maxHeight the maximum altitude on the ground, optional default 1
  22250. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22251. * * buffer the array holding the image color data
  22252. * * bufferWidth the width of image
  22253. * * bufferHeight the height of image
  22254. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22255. * @returns the VertexData of the Ground designed from a heightmap
  22256. */
  22257. static CreateGroundFromHeightMap(options: {
  22258. width: number;
  22259. height: number;
  22260. subdivisions: number;
  22261. minHeight: number;
  22262. maxHeight: number;
  22263. colorFilter: Color3;
  22264. buffer: Uint8Array;
  22265. bufferWidth: number;
  22266. bufferHeight: number;
  22267. alphaFilter: number;
  22268. }): VertexData;
  22269. /**
  22270. * Creates the VertexData for a Plane
  22271. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22272. * * size sets the width and height of the plane to the value of size, optional default 1
  22273. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22274. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22276. * * 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)
  22277. * * 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)
  22278. * @returns the VertexData of the box
  22279. */
  22280. static CreatePlane(options: {
  22281. size?: number;
  22282. width?: number;
  22283. height?: number;
  22284. sideOrientation?: number;
  22285. frontUVs?: Vector4;
  22286. backUVs?: Vector4;
  22287. }): VertexData;
  22288. /**
  22289. * Creates the VertexData of the Disc or regular Polygon
  22290. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22291. * * radius the radius of the disc, optional default 0.5
  22292. * * tessellation the number of polygon sides, optional, default 64
  22293. * * 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
  22294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22295. * * 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)
  22296. * * 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)
  22297. * @returns the VertexData of the box
  22298. */
  22299. static CreateDisc(options: {
  22300. radius?: number;
  22301. tessellation?: number;
  22302. arc?: number;
  22303. sideOrientation?: number;
  22304. frontUVs?: Vector4;
  22305. backUVs?: Vector4;
  22306. }): VertexData;
  22307. /**
  22308. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22309. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22310. * @param polygon a mesh built from polygonTriangulation.build()
  22311. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22312. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22313. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22314. * @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)
  22315. * @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)
  22316. * @returns the VertexData of the Polygon
  22317. */
  22318. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22319. /**
  22320. * Creates the VertexData of the IcoSphere
  22321. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22322. * * radius the radius of the IcoSphere, optional default 1
  22323. * * radiusX allows stretching in the x direction, optional, default radius
  22324. * * radiusY allows stretching in the y direction, optional, default radius
  22325. * * radiusZ allows stretching in the z direction, optional, default radius
  22326. * * flat when true creates a flat shaded mesh, optional, default true
  22327. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22329. * * 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)
  22330. * * 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)
  22331. * @returns the VertexData of the IcoSphere
  22332. */
  22333. static CreateIcoSphere(options: {
  22334. radius?: number;
  22335. radiusX?: number;
  22336. radiusY?: number;
  22337. radiusZ?: number;
  22338. flat?: boolean;
  22339. subdivisions?: number;
  22340. sideOrientation?: number;
  22341. frontUVs?: Vector4;
  22342. backUVs?: Vector4;
  22343. }): VertexData;
  22344. /**
  22345. * Creates the VertexData for a Polyhedron
  22346. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22347. * * type provided types are:
  22348. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22349. * * 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)
  22350. * * size the size of the IcoSphere, optional default 1
  22351. * * sizeX allows stretching in the x direction, optional, default size
  22352. * * sizeY allows stretching in the y direction, optional, default size
  22353. * * sizeZ allows stretching in the z direction, optional, default size
  22354. * * 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
  22355. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22356. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22357. * * flat when true creates a flat shaded mesh, optional, default true
  22358. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22360. * * 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)
  22361. * * 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)
  22362. * @returns the VertexData of the Polyhedron
  22363. */
  22364. static CreatePolyhedron(options: {
  22365. type?: number;
  22366. size?: number;
  22367. sizeX?: number;
  22368. sizeY?: number;
  22369. sizeZ?: number;
  22370. custom?: any;
  22371. faceUV?: Vector4[];
  22372. faceColors?: Color4[];
  22373. flat?: boolean;
  22374. sideOrientation?: number;
  22375. frontUVs?: Vector4;
  22376. backUVs?: Vector4;
  22377. }): VertexData;
  22378. /**
  22379. * Creates the VertexData for a TorusKnot
  22380. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22381. * * radius the radius of the torus knot, optional, default 2
  22382. * * tube the thickness of the tube, optional, default 0.5
  22383. * * radialSegments the number of sides on each tube segments, optional, default 32
  22384. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22385. * * p the number of windings around the z axis, optional, default 2
  22386. * * q the number of windings around the x axis, optional, default 3
  22387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22388. * * 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)
  22389. * * 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)
  22390. * @returns the VertexData of the Torus Knot
  22391. */
  22392. static CreateTorusKnot(options: {
  22393. radius?: number;
  22394. tube?: number;
  22395. radialSegments?: number;
  22396. tubularSegments?: number;
  22397. p?: number;
  22398. q?: number;
  22399. sideOrientation?: number;
  22400. frontUVs?: Vector4;
  22401. backUVs?: Vector4;
  22402. }): VertexData;
  22403. /**
  22404. * Compute normals for given positions and indices
  22405. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22406. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22407. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22408. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22409. * * facetNormals : optional array of facet normals (vector3)
  22410. * * facetPositions : optional array of facet positions (vector3)
  22411. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22412. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22413. * * bInfo : optional bounding info, required for facetPartitioning computation
  22414. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22415. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22416. * * useRightHandedSystem: optional boolean to for right handed system computation
  22417. * * depthSort : optional boolean to enable the facet depth sort computation
  22418. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22419. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22420. */
  22421. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22422. facetNormals?: any;
  22423. facetPositions?: any;
  22424. facetPartitioning?: any;
  22425. ratio?: number;
  22426. bInfo?: any;
  22427. bbSize?: Vector3;
  22428. subDiv?: any;
  22429. useRightHandedSystem?: boolean;
  22430. depthSort?: boolean;
  22431. distanceTo?: Vector3;
  22432. depthSortedFacets?: any;
  22433. }): void;
  22434. /** @hidden */
  22435. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22436. /**
  22437. * Applies VertexData created from the imported parameters to the geometry
  22438. * @param parsedVertexData the parsed data from an imported file
  22439. * @param geometry the geometry to apply the VertexData to
  22440. */
  22441. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22442. }
  22443. }
  22444. declare module "babylonjs/Meshes/Builders/discBuilder" {
  22445. import { Nullable } from "babylonjs/types";
  22446. import { Scene } from "babylonjs/scene";
  22447. import { Vector4 } from "babylonjs/Maths/math";
  22448. import { Mesh } from "babylonjs/Meshes/mesh";
  22449. /**
  22450. * Class containing static functions to help procedurally build meshes
  22451. */
  22452. export class DiscBuilder {
  22453. /**
  22454. * Creates a plane polygonal mesh. By default, this is a disc
  22455. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22456. * * 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
  22457. * * 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
  22458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22461. * @param name defines the name of the mesh
  22462. * @param options defines the options used to create the mesh
  22463. * @param scene defines the hosting scene
  22464. * @returns the plane polygonal mesh
  22465. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22466. */
  22467. static CreateDisc(name: string, options: {
  22468. radius?: number;
  22469. tessellation?: number;
  22470. arc?: number;
  22471. updatable?: boolean;
  22472. sideOrientation?: number;
  22473. frontUVs?: Vector4;
  22474. backUVs?: Vector4;
  22475. }, scene?: Nullable<Scene>): Mesh;
  22476. }
  22477. }
  22478. declare module "babylonjs/Particles/solidParticleSystem" {
  22479. import { Vector3 } from "babylonjs/Maths/math";
  22480. import { Mesh } from "babylonjs/Meshes/mesh";
  22481. import { Scene, IDisposable } from "babylonjs/scene";
  22482. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  22483. /**
  22484. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22485. *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.
  22486. * The SPS is also a particle system. It provides some methods to manage the particles.
  22487. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22488. *
  22489. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22490. */
  22491. export class SolidParticleSystem implements IDisposable {
  22492. /**
  22493. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22494. * Example : var p = SPS.particles[i];
  22495. */
  22496. particles: SolidParticle[];
  22497. /**
  22498. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22499. */
  22500. nbParticles: number;
  22501. /**
  22502. * If the particles must ever face the camera (default false). Useful for planar particles.
  22503. */
  22504. billboard: boolean;
  22505. /**
  22506. * Recompute normals when adding a shape
  22507. */
  22508. recomputeNormals: boolean;
  22509. /**
  22510. * This a counter ofr your own usage. It's not set by any SPS functions.
  22511. */
  22512. counter: number;
  22513. /**
  22514. * The SPS name. This name is also given to the underlying mesh.
  22515. */
  22516. name: string;
  22517. /**
  22518. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22519. */
  22520. mesh: Mesh;
  22521. /**
  22522. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22523. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22524. */
  22525. vars: any;
  22526. /**
  22527. * This array is populated when the SPS is set as 'pickable'.
  22528. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22529. * Each element of this array is an object `{idx: int, faceId: int}`.
  22530. * `idx` is the picked particle index in the `SPS.particles` array
  22531. * `faceId` is the picked face index counted within this particle.
  22532. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22533. */
  22534. pickedParticles: {
  22535. idx: number;
  22536. faceId: number;
  22537. }[];
  22538. /**
  22539. * This array is populated when `enableDepthSort` is set to true.
  22540. * Each element of this array is an instance of the class DepthSortedParticle.
  22541. */
  22542. depthSortedParticles: DepthSortedParticle[];
  22543. /**
  22544. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22545. * @hidden
  22546. */
  22547. _bSphereOnly: boolean;
  22548. /**
  22549. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22550. * @hidden
  22551. */
  22552. _bSphereRadiusFactor: number;
  22553. private _scene;
  22554. private _positions;
  22555. private _indices;
  22556. private _normals;
  22557. private _colors;
  22558. private _uvs;
  22559. private _indices32;
  22560. private _positions32;
  22561. private _normals32;
  22562. private _fixedNormal32;
  22563. private _colors32;
  22564. private _uvs32;
  22565. private _index;
  22566. private _updatable;
  22567. private _pickable;
  22568. private _isVisibilityBoxLocked;
  22569. private _alwaysVisible;
  22570. private _depthSort;
  22571. private _shapeCounter;
  22572. private _copy;
  22573. private _color;
  22574. private _computeParticleColor;
  22575. private _computeParticleTexture;
  22576. private _computeParticleRotation;
  22577. private _computeParticleVertex;
  22578. private _computeBoundingBox;
  22579. private _depthSortParticles;
  22580. private _camera;
  22581. private _mustUnrotateFixedNormals;
  22582. private _particlesIntersect;
  22583. private _needs32Bits;
  22584. /**
  22585. * Creates a SPS (Solid Particle System) object.
  22586. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22587. * @param scene (Scene) is the scene in which the SPS is added.
  22588. * @param options defines the options of the sps e.g.
  22589. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22590. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22591. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22592. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22593. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22594. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22595. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22596. */
  22597. constructor(name: string, scene: Scene, options?: {
  22598. updatable?: boolean;
  22599. isPickable?: boolean;
  22600. enableDepthSort?: boolean;
  22601. particleIntersection?: boolean;
  22602. boundingSphereOnly?: boolean;
  22603. bSphereRadiusFactor?: number;
  22604. });
  22605. /**
  22606. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22607. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22608. * @returns the created mesh
  22609. */
  22610. buildMesh(): Mesh;
  22611. /**
  22612. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22613. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22614. * Thus the particles generated from `digest()` have their property `position` set yet.
  22615. * @param mesh ( Mesh ) is the mesh to be digested
  22616. * @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
  22617. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22618. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22619. * @returns the current SPS
  22620. */
  22621. digest(mesh: Mesh, options?: {
  22622. facetNb?: number;
  22623. number?: number;
  22624. delta?: number;
  22625. }): SolidParticleSystem;
  22626. private _unrotateFixedNormals;
  22627. private _resetCopy;
  22628. private _meshBuilder;
  22629. private _posToShape;
  22630. private _uvsToShapeUV;
  22631. private _addParticle;
  22632. /**
  22633. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22634. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22635. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22636. * @param nb (positive integer) the number of particles to be created from this model
  22637. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22638. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22639. * @returns the number of shapes in the system
  22640. */
  22641. addShape(mesh: Mesh, nb: number, options?: {
  22642. positionFunction?: any;
  22643. vertexFunction?: any;
  22644. }): number;
  22645. private _rebuildParticle;
  22646. /**
  22647. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22648. * @returns the SPS.
  22649. */
  22650. rebuildMesh(): SolidParticleSystem;
  22651. /**
  22652. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22653. * This method calls `updateParticle()` for each particle of the SPS.
  22654. * For an animated SPS, it is usually called within the render loop.
  22655. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22656. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22657. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22658. * @returns the SPS.
  22659. */
  22660. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22661. /**
  22662. * Disposes the SPS.
  22663. */
  22664. dispose(): void;
  22665. /**
  22666. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22667. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22668. * @returns the SPS.
  22669. */
  22670. refreshVisibleSize(): SolidParticleSystem;
  22671. /**
  22672. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22673. * @param size the size (float) of the visibility box
  22674. * note : this doesn't lock the SPS mesh bounding box.
  22675. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22676. */
  22677. setVisibilityBox(size: number): void;
  22678. /**
  22679. * Gets whether the SPS as always visible or not
  22680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22681. */
  22682. /**
  22683. * Sets the SPS as always visible or not
  22684. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22685. */
  22686. isAlwaysVisible: boolean;
  22687. /**
  22688. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22689. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22690. */
  22691. /**
  22692. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22693. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22694. */
  22695. isVisibilityBoxLocked: boolean;
  22696. /**
  22697. * Tells to `setParticles()` to compute the particle rotations or not.
  22698. * Default value : true. The SPS is faster when it's set to false.
  22699. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22700. */
  22701. /**
  22702. * Gets if `setParticles()` computes the particle rotations or not.
  22703. * Default value : true. The SPS is faster when it's set to false.
  22704. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22705. */
  22706. computeParticleRotation: boolean;
  22707. /**
  22708. * Tells to `setParticles()` to compute the particle colors or not.
  22709. * Default value : true. The SPS is faster when it's set to false.
  22710. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22711. */
  22712. /**
  22713. * Gets if `setParticles()` computes the particle colors or not.
  22714. * Default value : true. The SPS is faster when it's set to false.
  22715. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22716. */
  22717. computeParticleColor: boolean;
  22718. /**
  22719. * Gets if `setParticles()` computes the particle textures or not.
  22720. * Default value : true. The SPS is faster when it's set to false.
  22721. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22722. */
  22723. computeParticleTexture: boolean;
  22724. /**
  22725. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22726. * Default value : false. The SPS is faster when it's set to false.
  22727. * Note : the particle custom vertex positions aren't stored values.
  22728. */
  22729. /**
  22730. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22731. * Default value : false. The SPS is faster when it's set to false.
  22732. * Note : the particle custom vertex positions aren't stored values.
  22733. */
  22734. computeParticleVertex: boolean;
  22735. /**
  22736. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22737. */
  22738. /**
  22739. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22740. */
  22741. computeBoundingBox: boolean;
  22742. /**
  22743. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22744. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22745. * Default : `true`
  22746. */
  22747. /**
  22748. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22749. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22750. * Default : `true`
  22751. */
  22752. depthSortParticles: boolean;
  22753. /**
  22754. * This function does nothing. It may be overwritten to set all the particle first values.
  22755. * The SPS doesn't call this function, you may have to call it by your own.
  22756. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22757. */
  22758. initParticles(): void;
  22759. /**
  22760. * This function does nothing. It may be overwritten to recycle a particle.
  22761. * The SPS doesn't call this function, you may have to call it by your own.
  22762. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22763. * @param particle The particle to recycle
  22764. * @returns the recycled particle
  22765. */
  22766. recycleParticle(particle: SolidParticle): SolidParticle;
  22767. /**
  22768. * Updates a particle : this function should be overwritten by the user.
  22769. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22770. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22771. * @example : just set a particle position or velocity and recycle conditions
  22772. * @param particle The particle to update
  22773. * @returns the updated particle
  22774. */
  22775. updateParticle(particle: SolidParticle): SolidParticle;
  22776. /**
  22777. * Updates a vertex of a particle : it can be overwritten by the user.
  22778. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22779. * @param particle the current particle
  22780. * @param vertex the current index of the current particle
  22781. * @param pt the index of the current vertex in the particle shape
  22782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22783. * @example : just set a vertex particle position
  22784. * @returns the updated vertex
  22785. */
  22786. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22787. /**
  22788. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22789. * This does nothing and may be overwritten by the user.
  22790. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22791. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22792. * @param update the boolean update value actually passed to setParticles()
  22793. */
  22794. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22795. /**
  22796. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22797. * This will be passed three parameters.
  22798. * This does nothing and may be overwritten by the user.
  22799. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22800. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22801. * @param update the boolean update value actually passed to setParticles()
  22802. */
  22803. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22804. }
  22805. }
  22806. declare module "babylonjs/Particles/solidParticle" {
  22807. import { Nullable } from "babylonjs/types";
  22808. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  22809. import { Mesh } from "babylonjs/Meshes/mesh";
  22810. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22811. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  22812. /**
  22813. * Represents one particle of a solid particle system.
  22814. */
  22815. export class SolidParticle {
  22816. /**
  22817. * particle global index
  22818. */
  22819. idx: number;
  22820. /**
  22821. * The color of the particle
  22822. */
  22823. color: Nullable<Color4>;
  22824. /**
  22825. * The world space position of the particle.
  22826. */
  22827. position: Vector3;
  22828. /**
  22829. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22830. */
  22831. rotation: Vector3;
  22832. /**
  22833. * The world space rotation quaternion of the particle.
  22834. */
  22835. rotationQuaternion: Nullable<Quaternion>;
  22836. /**
  22837. * The scaling of the particle.
  22838. */
  22839. scaling: Vector3;
  22840. /**
  22841. * The uvs of the particle.
  22842. */
  22843. uvs: Vector4;
  22844. /**
  22845. * The current speed of the particle.
  22846. */
  22847. velocity: Vector3;
  22848. /**
  22849. * The pivot point in the particle local space.
  22850. */
  22851. pivot: Vector3;
  22852. /**
  22853. * Must the particle be translated from its pivot point in its local space ?
  22854. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22855. * Default : false
  22856. */
  22857. translateFromPivot: boolean;
  22858. /**
  22859. * Is the particle active or not ?
  22860. */
  22861. alive: boolean;
  22862. /**
  22863. * Is the particle visible or not ?
  22864. */
  22865. isVisible: boolean;
  22866. /**
  22867. * Index of this particle in the global "positions" array (Internal use)
  22868. * @hidden
  22869. */
  22870. _pos: number;
  22871. /**
  22872. * @hidden Index of this particle in the global "indices" array (Internal use)
  22873. */
  22874. _ind: number;
  22875. /**
  22876. * @hidden ModelShape of this particle (Internal use)
  22877. */
  22878. _model: ModelShape;
  22879. /**
  22880. * ModelShape id of this particle
  22881. */
  22882. shapeId: number;
  22883. /**
  22884. * Index of the particle in its shape id (Internal use)
  22885. */
  22886. idxInShape: number;
  22887. /**
  22888. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22889. */
  22890. _modelBoundingInfo: BoundingInfo;
  22891. /**
  22892. * @hidden Particle BoundingInfo object (Internal use)
  22893. */
  22894. _boundingInfo: BoundingInfo;
  22895. /**
  22896. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22897. */
  22898. _sps: SolidParticleSystem;
  22899. /**
  22900. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22901. */
  22902. _stillInvisible: boolean;
  22903. /**
  22904. * @hidden Last computed particle rotation matrix
  22905. */
  22906. _rotationMatrix: number[];
  22907. /**
  22908. * Parent particle Id, if any.
  22909. * Default null.
  22910. */
  22911. parentId: Nullable<number>;
  22912. /**
  22913. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22914. * The possible values are :
  22915. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22916. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22917. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22918. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22919. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22920. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22921. * */
  22922. cullingStrategy: number;
  22923. /**
  22924. * @hidden Internal global position in the SPS.
  22925. */
  22926. _globalPosition: Vector3;
  22927. /**
  22928. * Creates a Solid Particle object.
  22929. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22930. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22931. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22932. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22933. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22934. * @param shapeId (integer) is the model shape identifier in the SPS.
  22935. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22936. * @param sps defines the sps it is associated to
  22937. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22938. */
  22939. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22940. /**
  22941. * Legacy support, changed scale to scaling
  22942. */
  22943. /**
  22944. * Legacy support, changed scale to scaling
  22945. */
  22946. scale: Vector3;
  22947. /**
  22948. * Legacy support, changed quaternion to rotationQuaternion
  22949. */
  22950. /**
  22951. * Legacy support, changed quaternion to rotationQuaternion
  22952. */
  22953. quaternion: Nullable<Quaternion>;
  22954. /**
  22955. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22956. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22957. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22958. * @returns true if it intersects
  22959. */
  22960. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22961. /**
  22962. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22963. * A particle is in the frustum if its bounding box intersects the frustum
  22964. * @param frustumPlanes defines the frustum to test
  22965. * @returns true if the particle is in the frustum planes
  22966. */
  22967. isInFrustum(frustumPlanes: Plane[]): boolean;
  22968. /**
  22969. * get the rotation matrix of the particle
  22970. * @hidden
  22971. */
  22972. getRotationMatrix(m: Matrix): void;
  22973. }
  22974. /**
  22975. * Represents the shape of the model used by one particle of a solid particle system.
  22976. * SPS internal tool, don't use it manually.
  22977. */
  22978. export class ModelShape {
  22979. /**
  22980. * The shape id
  22981. * @hidden
  22982. */
  22983. shapeID: number;
  22984. /**
  22985. * flat array of model positions (internal use)
  22986. * @hidden
  22987. */
  22988. _shape: Vector3[];
  22989. /**
  22990. * flat array of model UVs (internal use)
  22991. * @hidden
  22992. */
  22993. _shapeUV: number[];
  22994. /**
  22995. * length of the shape in the model indices array (internal use)
  22996. * @hidden
  22997. */
  22998. _indicesLength: number;
  22999. /**
  23000. * Custom position function (internal use)
  23001. * @hidden
  23002. */
  23003. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23004. /**
  23005. * Custom vertex function (internal use)
  23006. * @hidden
  23007. */
  23008. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23009. /**
  23010. * 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.
  23011. * SPS internal tool, don't use it manually.
  23012. * @hidden
  23013. */
  23014. 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>);
  23015. }
  23016. /**
  23017. * Represents a Depth Sorted Particle in the solid particle system.
  23018. */
  23019. export class DepthSortedParticle {
  23020. /**
  23021. * Index of the particle in the "indices" array
  23022. */
  23023. ind: number;
  23024. /**
  23025. * Length of the particle shape in the "indices" array
  23026. */
  23027. indicesLength: number;
  23028. /**
  23029. * Squared distance from the particle to the camera
  23030. */
  23031. sqDistance: number;
  23032. }
  23033. }
  23034. declare module "babylonjs/Meshes/abstractMesh" {
  23035. import { Observable } from "babylonjs/Misc/observable";
  23036. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23037. import { Camera } from "babylonjs/Cameras/camera";
  23038. import { Scene, IDisposable } from "babylonjs/scene";
  23039. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23040. import { Node } from "babylonjs/node";
  23041. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23042. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23044. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23045. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23046. import { Material } from "babylonjs/Materials/material";
  23047. import { Light } from "babylonjs/Lights/light";
  23048. import { Skeleton } from "babylonjs/Bones/skeleton";
  23049. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23050. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23051. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23052. import { Ray } from "babylonjs/Culling/ray";
  23053. import { Collider } from "babylonjs/Collisions/collider";
  23054. /**
  23055. * Class used to store all common mesh properties
  23056. */
  23057. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23058. /** No occlusion */
  23059. static OCCLUSION_TYPE_NONE: number;
  23060. /** Occlusion set to optimisitic */
  23061. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23062. /** Occlusion set to strict */
  23063. static OCCLUSION_TYPE_STRICT: number;
  23064. /** Use an accurante occlusion algorithm */
  23065. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23066. /** Use a conservative occlusion algorithm */
  23067. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23068. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23069. * Test order :
  23070. * Is the bounding sphere outside the frustum ?
  23071. * If not, are the bounding box vertices outside the frustum ?
  23072. * It not, then the cullable object is in the frustum.
  23073. */
  23074. static readonly CULLINGSTRATEGY_STANDARD: number;
  23075. /** Culling strategy : Bounding Sphere Only.
  23076. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23077. * It's also less accurate than the standard because some not visible objects can still be selected.
  23078. * Test : is the bounding sphere outside the frustum ?
  23079. * If not, then the cullable object is in the frustum.
  23080. */
  23081. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23082. /** Culling strategy : Optimistic Inclusion.
  23083. * This in an inclusion test first, then the standard exclusion test.
  23084. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23085. * 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.
  23086. * Anyway, it's as accurate as the standard strategy.
  23087. * Test :
  23088. * Is the cullable object bounding sphere center in the frustum ?
  23089. * If not, apply the default culling strategy.
  23090. */
  23091. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23092. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23093. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23094. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23095. * 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.
  23096. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23097. * Test :
  23098. * Is the cullable object bounding sphere center in the frustum ?
  23099. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23100. */
  23101. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23102. /**
  23103. * No billboard
  23104. */
  23105. static readonly BILLBOARDMODE_NONE: number;
  23106. /** Billboard on X axis */
  23107. static readonly BILLBOARDMODE_X: number;
  23108. /** Billboard on Y axis */
  23109. static readonly BILLBOARDMODE_Y: number;
  23110. /** Billboard on Z axis */
  23111. static readonly BILLBOARDMODE_Z: number;
  23112. /** Billboard on all axes */
  23113. static readonly BILLBOARDMODE_ALL: number;
  23114. private _facetData;
  23115. /**
  23116. * The culling strategy to use to check whether the mesh must be rendered or not.
  23117. * This value can be changed at any time and will be used on the next render mesh selection.
  23118. * The possible values are :
  23119. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23120. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23121. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23122. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23123. * Please read each static variable documentation to get details about the culling process.
  23124. * */
  23125. cullingStrategy: number;
  23126. /**
  23127. * Gets the number of facets in the mesh
  23128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23129. */
  23130. readonly facetNb: number;
  23131. /**
  23132. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23134. */
  23135. partitioningSubdivisions: number;
  23136. /**
  23137. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23138. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23140. */
  23141. partitioningBBoxRatio: number;
  23142. /**
  23143. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23144. * Works only for updatable meshes.
  23145. * Doesn't work with multi-materials
  23146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23147. */
  23148. mustDepthSortFacets: boolean;
  23149. /**
  23150. * The location (Vector3) where the facet depth sort must be computed from.
  23151. * By default, the active camera position.
  23152. * Used only when facet depth sort is enabled
  23153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23154. */
  23155. facetDepthSortFrom: Vector3;
  23156. /**
  23157. * gets a boolean indicating if facetData is enabled
  23158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23159. */
  23160. readonly isFacetDataEnabled: boolean;
  23161. /** @hidden */
  23162. _updateNonUniformScalingState(value: boolean): boolean;
  23163. /**
  23164. * An event triggered when this mesh collides with another one
  23165. */
  23166. onCollideObservable: Observable<AbstractMesh>;
  23167. private _onCollideObserver;
  23168. /** Set a function to call when this mesh collides with another one */
  23169. onCollide: () => void;
  23170. /**
  23171. * An event triggered when the collision's position changes
  23172. */
  23173. onCollisionPositionChangeObservable: Observable<Vector3>;
  23174. private _onCollisionPositionChangeObserver;
  23175. /** Set a function to call when the collision's position changes */
  23176. onCollisionPositionChange: () => void;
  23177. /**
  23178. * An event triggered when material is changed
  23179. */
  23180. onMaterialChangedObservable: Observable<AbstractMesh>;
  23181. /**
  23182. * Gets or sets the orientation for POV movement & rotation
  23183. */
  23184. definedFacingForward: boolean;
  23185. /** @hidden */
  23186. _occlusionQuery: Nullable<WebGLQuery>;
  23187. private _visibility;
  23188. /**
  23189. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23190. */
  23191. /**
  23192. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23193. */
  23194. visibility: number;
  23195. /** Gets or sets the alpha index used to sort transparent meshes
  23196. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23197. */
  23198. alphaIndex: number;
  23199. /**
  23200. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23201. */
  23202. isVisible: boolean;
  23203. /**
  23204. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23205. */
  23206. isPickable: boolean;
  23207. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23208. showSubMeshesBoundingBox: boolean;
  23209. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23210. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23211. */
  23212. isBlocker: boolean;
  23213. /**
  23214. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23215. */
  23216. enablePointerMoveEvents: boolean;
  23217. /**
  23218. * Specifies the rendering group id for this mesh (0 by default)
  23219. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23220. */
  23221. renderingGroupId: number;
  23222. private _material;
  23223. /** Gets or sets current material */
  23224. material: Nullable<Material>;
  23225. private _receiveShadows;
  23226. /**
  23227. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23228. * @see http://doc.babylonjs.com/babylon101/shadows
  23229. */
  23230. receiveShadows: boolean;
  23231. /** Defines color to use when rendering outline */
  23232. outlineColor: Color3;
  23233. /** Define width to use when rendering outline */
  23234. outlineWidth: number;
  23235. /** Defines color to use when rendering overlay */
  23236. overlayColor: Color3;
  23237. /** Defines alpha to use when rendering overlay */
  23238. overlayAlpha: number;
  23239. private _hasVertexAlpha;
  23240. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23241. hasVertexAlpha: boolean;
  23242. private _useVertexColors;
  23243. /** 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) */
  23244. useVertexColors: boolean;
  23245. private _computeBonesUsingShaders;
  23246. /**
  23247. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23248. */
  23249. computeBonesUsingShaders: boolean;
  23250. private _numBoneInfluencers;
  23251. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23252. numBoneInfluencers: number;
  23253. private _applyFog;
  23254. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23255. applyFog: boolean;
  23256. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23257. useOctreeForRenderingSelection: boolean;
  23258. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23259. useOctreeForPicking: boolean;
  23260. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23261. useOctreeForCollisions: boolean;
  23262. private _layerMask;
  23263. /**
  23264. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23265. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23266. */
  23267. layerMask: number;
  23268. /**
  23269. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23270. */
  23271. alwaysSelectAsActiveMesh: boolean;
  23272. /**
  23273. * Gets or sets the current action manager
  23274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23275. */
  23276. actionManager: Nullable<AbstractActionManager>;
  23277. private _checkCollisions;
  23278. private _collisionMask;
  23279. private _collisionGroup;
  23280. /**
  23281. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23282. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23283. */
  23284. ellipsoid: Vector3;
  23285. /**
  23286. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23288. */
  23289. ellipsoidOffset: Vector3;
  23290. private _collider;
  23291. private _oldPositionForCollisions;
  23292. private _diffPositionForCollisions;
  23293. /**
  23294. * Gets or sets a collision mask used to mask collisions (default is -1).
  23295. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23296. */
  23297. collisionMask: number;
  23298. /**
  23299. * Gets or sets the current collision group mask (-1 by default).
  23300. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23301. */
  23302. collisionGroup: number;
  23303. /**
  23304. * Defines edge width used when edgesRenderer is enabled
  23305. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23306. */
  23307. edgesWidth: number;
  23308. /**
  23309. * Defines edge color used when edgesRenderer is enabled
  23310. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23311. */
  23312. edgesColor: Color4;
  23313. /** @hidden */
  23314. _edgesRenderer: Nullable<IEdgesRenderer>;
  23315. /** @hidden */
  23316. _masterMesh: Nullable<AbstractMesh>;
  23317. /** @hidden */
  23318. _boundingInfo: Nullable<BoundingInfo>;
  23319. /** @hidden */
  23320. _renderId: number;
  23321. /**
  23322. * Gets or sets the list of subMeshes
  23323. * @see http://doc.babylonjs.com/how_to/multi_materials
  23324. */
  23325. subMeshes: SubMesh[];
  23326. /** @hidden */
  23327. _intersectionsInProgress: AbstractMesh[];
  23328. /** @hidden */
  23329. _unIndexed: boolean;
  23330. /** @hidden */
  23331. _lightSources: Light[];
  23332. /** @hidden */
  23333. readonly _positions: Nullable<Vector3[]>;
  23334. /** @hidden */
  23335. _waitingActions: any;
  23336. /** @hidden */
  23337. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23338. private _skeleton;
  23339. /** @hidden */
  23340. _bonesTransformMatrices: Nullable<Float32Array>;
  23341. /**
  23342. * Gets or sets a skeleton to apply skining transformations
  23343. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23344. */
  23345. skeleton: Nullable<Skeleton>;
  23346. /**
  23347. * An event triggered when the mesh is rebuilt.
  23348. */
  23349. onRebuildObservable: Observable<AbstractMesh>;
  23350. /**
  23351. * Creates a new AbstractMesh
  23352. * @param name defines the name of the mesh
  23353. * @param scene defines the hosting scene
  23354. */
  23355. constructor(name: string, scene?: Nullable<Scene>);
  23356. /**
  23357. * Returns the string "AbstractMesh"
  23358. * @returns "AbstractMesh"
  23359. */
  23360. getClassName(): string;
  23361. /**
  23362. * Gets a string representation of the current mesh
  23363. * @param fullDetails defines a boolean indicating if full details must be included
  23364. * @returns a string representation of the current mesh
  23365. */
  23366. toString(fullDetails?: boolean): string;
  23367. /** @hidden */
  23368. _rebuild(): void;
  23369. /** @hidden */
  23370. _resyncLightSources(): void;
  23371. /** @hidden */
  23372. _resyncLighSource(light: Light): void;
  23373. /** @hidden */
  23374. _unBindEffect(): void;
  23375. /** @hidden */
  23376. _removeLightSource(light: Light): void;
  23377. private _markSubMeshesAsDirty;
  23378. /** @hidden */
  23379. _markSubMeshesAsLightDirty(): void;
  23380. /** @hidden */
  23381. _markSubMeshesAsAttributesDirty(): void;
  23382. /** @hidden */
  23383. _markSubMeshesAsMiscDirty(): void;
  23384. /**
  23385. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23386. */
  23387. scaling: Vector3;
  23388. /**
  23389. * Returns true if the mesh is blocked. Implemented by child classes
  23390. */
  23391. readonly isBlocked: boolean;
  23392. /**
  23393. * Returns the mesh itself by default. Implemented by child classes
  23394. * @param camera defines the camera to use to pick the right LOD level
  23395. * @returns the currentAbstractMesh
  23396. */
  23397. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23398. /**
  23399. * Returns 0 by default. Implemented by child classes
  23400. * @returns an integer
  23401. */
  23402. getTotalVertices(): number;
  23403. /**
  23404. * Returns a positive integer : the total number of indices in this mesh geometry.
  23405. * @returns the numner of indices or zero if the mesh has no geometry.
  23406. */
  23407. getTotalIndices(): number;
  23408. /**
  23409. * Returns null by default. Implemented by child classes
  23410. * @returns null
  23411. */
  23412. getIndices(): Nullable<IndicesArray>;
  23413. /**
  23414. * Returns the array of the requested vertex data kind. Implemented by child classes
  23415. * @param kind defines the vertex data kind to use
  23416. * @returns null
  23417. */
  23418. getVerticesData(kind: string): Nullable<FloatArray>;
  23419. /**
  23420. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23421. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23422. * Note that a new underlying VertexBuffer object is created each call.
  23423. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23424. * @param kind defines vertex data kind:
  23425. * * VertexBuffer.PositionKind
  23426. * * VertexBuffer.UVKind
  23427. * * VertexBuffer.UV2Kind
  23428. * * VertexBuffer.UV3Kind
  23429. * * VertexBuffer.UV4Kind
  23430. * * VertexBuffer.UV5Kind
  23431. * * VertexBuffer.UV6Kind
  23432. * * VertexBuffer.ColorKind
  23433. * * VertexBuffer.MatricesIndicesKind
  23434. * * VertexBuffer.MatricesIndicesExtraKind
  23435. * * VertexBuffer.MatricesWeightsKind
  23436. * * VertexBuffer.MatricesWeightsExtraKind
  23437. * @param data defines the data source
  23438. * @param updatable defines if the data must be flagged as updatable (or static)
  23439. * @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
  23440. * @returns the current mesh
  23441. */
  23442. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23443. /**
  23444. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23445. * If the mesh has no geometry, it is simply returned as it is.
  23446. * @param kind defines vertex data kind:
  23447. * * VertexBuffer.PositionKind
  23448. * * VertexBuffer.UVKind
  23449. * * VertexBuffer.UV2Kind
  23450. * * VertexBuffer.UV3Kind
  23451. * * VertexBuffer.UV4Kind
  23452. * * VertexBuffer.UV5Kind
  23453. * * VertexBuffer.UV6Kind
  23454. * * VertexBuffer.ColorKind
  23455. * * VertexBuffer.MatricesIndicesKind
  23456. * * VertexBuffer.MatricesIndicesExtraKind
  23457. * * VertexBuffer.MatricesWeightsKind
  23458. * * VertexBuffer.MatricesWeightsExtraKind
  23459. * @param data defines the data source
  23460. * @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
  23461. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23462. * @returns the current mesh
  23463. */
  23464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23465. /**
  23466. * Sets the mesh indices,
  23467. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23468. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23469. * @param totalVertices Defines the total number of vertices
  23470. * @returns the current mesh
  23471. */
  23472. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23473. /**
  23474. * Gets a boolean indicating if specific vertex data is present
  23475. * @param kind defines the vertex data kind to use
  23476. * @returns true is data kind is present
  23477. */
  23478. isVerticesDataPresent(kind: string): boolean;
  23479. /**
  23480. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23481. * @returns a BoundingInfo
  23482. */
  23483. getBoundingInfo(): BoundingInfo;
  23484. /**
  23485. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23486. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23487. * @returns the current mesh
  23488. */
  23489. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23490. /**
  23491. * Overwrite the current bounding info
  23492. * @param boundingInfo defines the new bounding info
  23493. * @returns the current mesh
  23494. */
  23495. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23496. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23497. readonly useBones: boolean;
  23498. /** @hidden */
  23499. _preActivate(): void;
  23500. /** @hidden */
  23501. _preActivateForIntermediateRendering(renderId: number): void;
  23502. /** @hidden */
  23503. _activate(renderId: number): void;
  23504. /**
  23505. * Gets the current world matrix
  23506. * @returns a Matrix
  23507. */
  23508. getWorldMatrix(): Matrix;
  23509. /** @hidden */
  23510. _getWorldMatrixDeterminant(): number;
  23511. /**
  23512. * Perform relative position change from the point of view of behind the front of the mesh.
  23513. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23514. * Supports definition of mesh facing forward or backward
  23515. * @param amountRight defines the distance on the right axis
  23516. * @param amountUp defines the distance on the up axis
  23517. * @param amountForward defines the distance on the forward axis
  23518. * @returns the current mesh
  23519. */
  23520. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23521. /**
  23522. * Calculate relative position change from the point of view of behind the front of the mesh.
  23523. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23524. * Supports definition of mesh facing forward or backward
  23525. * @param amountRight defines the distance on the right axis
  23526. * @param amountUp defines the distance on the up axis
  23527. * @param amountForward defines the distance on the forward axis
  23528. * @returns the new displacement vector
  23529. */
  23530. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23531. /**
  23532. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23533. * Supports definition of mesh facing forward or backward
  23534. * @param flipBack defines the flip
  23535. * @param twirlClockwise defines the twirl
  23536. * @param tiltRight defines the tilt
  23537. * @returns the current mesh
  23538. */
  23539. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23540. /**
  23541. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23542. * Supports definition of mesh facing forward or backward.
  23543. * @param flipBack defines the flip
  23544. * @param twirlClockwise defines the twirl
  23545. * @param tiltRight defines the tilt
  23546. * @returns the new rotation vector
  23547. */
  23548. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23549. /**
  23550. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23551. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23552. * @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
  23553. * @returns the new bounding vectors
  23554. */
  23555. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23556. min: Vector3;
  23557. max: Vector3;
  23558. };
  23559. /**
  23560. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23561. * This means the mesh underlying bounding box and sphere are recomputed.
  23562. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23563. * @returns the current mesh
  23564. */
  23565. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23566. /** @hidden */
  23567. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23568. /** @hidden */
  23569. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23570. /** @hidden */
  23571. _updateBoundingInfo(): AbstractMesh;
  23572. /** @hidden */
  23573. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23574. /** @hidden */
  23575. protected _afterComputeWorldMatrix(): void;
  23576. /**
  23577. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23578. * A mesh is in the frustum if its bounding box intersects the frustum
  23579. * @param frustumPlanes defines the frustum to test
  23580. * @returns true if the mesh is in the frustum planes
  23581. */
  23582. isInFrustum(frustumPlanes: Plane[]): boolean;
  23583. /**
  23584. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23585. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23586. * @param frustumPlanes defines the frustum to test
  23587. * @returns true if the mesh is completely in the frustum planes
  23588. */
  23589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23590. /**
  23591. * True if the mesh intersects another mesh or a SolidParticle object
  23592. * @param mesh defines a target mesh or SolidParticle to test
  23593. * @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)
  23594. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23595. * @returns true if there is an intersection
  23596. */
  23597. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23598. /**
  23599. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23600. * @param point defines the point to test
  23601. * @returns true if there is an intersection
  23602. */
  23603. intersectsPoint(point: Vector3): boolean;
  23604. /**
  23605. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23607. */
  23608. checkCollisions: boolean;
  23609. /**
  23610. * Gets Collider object used to compute collisions (not physics)
  23611. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23612. */
  23613. readonly collider: Collider;
  23614. /**
  23615. * Move the mesh using collision engine
  23616. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23617. * @param displacement defines the requested displacement vector
  23618. * @returns the current mesh
  23619. */
  23620. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23621. private _onCollisionPositionChange;
  23622. /** @hidden */
  23623. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23624. /** @hidden */
  23625. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23626. /** @hidden */
  23627. _checkCollision(collider: Collider): AbstractMesh;
  23628. /** @hidden */
  23629. _generatePointsArray(): boolean;
  23630. /**
  23631. * Checks if the passed Ray intersects with the mesh
  23632. * @param ray defines the ray to use
  23633. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23634. * @returns the picking info
  23635. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23636. */
  23637. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23638. /**
  23639. * Clones the current mesh
  23640. * @param name defines the mesh name
  23641. * @param newParent defines the new mesh parent
  23642. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23643. * @returns the new mesh
  23644. */
  23645. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23646. /**
  23647. * Disposes all the submeshes of the current meshnp
  23648. * @returns the current mesh
  23649. */
  23650. releaseSubMeshes(): AbstractMesh;
  23651. /**
  23652. * Releases resources associated with this abstract mesh.
  23653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23655. */
  23656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23657. /**
  23658. * Adds the passed mesh as a child to the current mesh
  23659. * @param mesh defines the child mesh
  23660. * @returns the current mesh
  23661. */
  23662. addChild(mesh: AbstractMesh): AbstractMesh;
  23663. /**
  23664. * Removes the passed mesh from the current mesh children list
  23665. * @param mesh defines the child mesh
  23666. * @returns the current mesh
  23667. */
  23668. removeChild(mesh: AbstractMesh): AbstractMesh;
  23669. /** @hidden */
  23670. private _initFacetData;
  23671. /**
  23672. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23673. * This method can be called within the render loop.
  23674. * 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
  23675. * @returns the current mesh
  23676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23677. */
  23678. updateFacetData(): AbstractMesh;
  23679. /**
  23680. * Returns the facetLocalNormals array.
  23681. * The normals are expressed in the mesh local spac
  23682. * @returns an array of Vector3
  23683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23684. */
  23685. getFacetLocalNormals(): Vector3[];
  23686. /**
  23687. * Returns the facetLocalPositions array.
  23688. * The facet positions are expressed in the mesh local space
  23689. * @returns an array of Vector3
  23690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23691. */
  23692. getFacetLocalPositions(): Vector3[];
  23693. /**
  23694. * Returns the facetLocalPartioning array
  23695. * @returns an array of array of numbers
  23696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23697. */
  23698. getFacetLocalPartitioning(): number[][];
  23699. /**
  23700. * Returns the i-th facet position in the world system.
  23701. * This method allocates a new Vector3 per call
  23702. * @param i defines the facet index
  23703. * @returns a new Vector3
  23704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23705. */
  23706. getFacetPosition(i: number): Vector3;
  23707. /**
  23708. * Sets the reference Vector3 with the i-th facet position in the world system
  23709. * @param i defines the facet index
  23710. * @param ref defines the target vector
  23711. * @returns the current mesh
  23712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23713. */
  23714. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23715. /**
  23716. * Returns the i-th facet normal in the world system.
  23717. * This method allocates a new Vector3 per call
  23718. * @param i defines the facet index
  23719. * @returns a new Vector3
  23720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23721. */
  23722. getFacetNormal(i: number): Vector3;
  23723. /**
  23724. * Sets the reference Vector3 with the i-th facet normal in the world system
  23725. * @param i defines the facet index
  23726. * @param ref defines the target vector
  23727. * @returns the current mesh
  23728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23729. */
  23730. getFacetNormalToRef(i: number, ref: Vector3): this;
  23731. /**
  23732. * 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)
  23733. * @param x defines x coordinate
  23734. * @param y defines y coordinate
  23735. * @param z defines z coordinate
  23736. * @returns the array of facet indexes
  23737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23738. */
  23739. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23740. /**
  23741. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23742. * @param projected sets as the (x,y,z) world projection on the facet
  23743. * @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
  23744. * @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
  23745. * @param x defines x coordinate
  23746. * @param y defines y coordinate
  23747. * @param z defines z coordinate
  23748. * @returns the face index if found (or null instead)
  23749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23750. */
  23751. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23752. /**
  23753. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23754. * @param projected sets as the (x,y,z) local projection on the facet
  23755. * @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
  23756. * @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
  23757. * @param x defines x coordinate
  23758. * @param y defines y coordinate
  23759. * @param z defines z coordinate
  23760. * @returns the face index if found (or null instead)
  23761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23762. */
  23763. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23764. /**
  23765. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23766. * @returns the parameters
  23767. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23768. */
  23769. getFacetDataParameters(): any;
  23770. /**
  23771. * Disables the feature FacetData and frees the related memory
  23772. * @returns the current mesh
  23773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23774. */
  23775. disableFacetData(): AbstractMesh;
  23776. /**
  23777. * Updates the AbstractMesh indices array
  23778. * @param indices defines the data source
  23779. * @returns the current mesh
  23780. */
  23781. updateIndices(indices: IndicesArray): AbstractMesh;
  23782. /**
  23783. * Creates new normals data for the mesh
  23784. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23785. * @returns the current mesh
  23786. */
  23787. createNormals(updatable: boolean): AbstractMesh;
  23788. /**
  23789. * Align the mesh with a normal
  23790. * @param normal defines the normal to use
  23791. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23792. * @returns the current mesh
  23793. */
  23794. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23795. /** @hidden */
  23796. _checkOcclusionQuery(): boolean;
  23797. }
  23798. }
  23799. declare module "babylonjs/Bones/skeleton" {
  23800. import { Bone } from "babylonjs/Bones/bone";
  23801. import { IAnimatable } from "babylonjs/Misc/tools";
  23802. import { Observable } from "babylonjs/Misc/observable";
  23803. import { Vector3, Matrix } from "babylonjs/Maths/math";
  23804. import { Scene } from "babylonjs/scene";
  23805. import { Nullable } from "babylonjs/types";
  23806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23807. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  23808. import { Animatable } from "babylonjs/Animations/animatable";
  23809. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23810. import { Animation } from "babylonjs/Animations/animation";
  23811. import { AnimationRange } from "babylonjs/Animations/animationRange";
  23812. /**
  23813. * Class used to handle skinning animations
  23814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23815. */
  23816. export class Skeleton implements IAnimatable {
  23817. /** defines the skeleton name */
  23818. name: string;
  23819. /** defines the skeleton Id */
  23820. id: string;
  23821. /**
  23822. * Defines the list of child bones
  23823. */
  23824. bones: Bone[];
  23825. /**
  23826. * Defines an estimate of the dimension of the skeleton at rest
  23827. */
  23828. dimensionsAtRest: Vector3;
  23829. /**
  23830. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23831. */
  23832. needInitialSkinMatrix: boolean;
  23833. /**
  23834. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23835. */
  23836. overrideMesh: Nullable<AbstractMesh>;
  23837. /**
  23838. * Gets the list of animations attached to this skeleton
  23839. */
  23840. animations: Array<Animation>;
  23841. private _scene;
  23842. private _isDirty;
  23843. private _transformMatrices;
  23844. private _transformMatrixTexture;
  23845. private _meshesWithPoseMatrix;
  23846. private _animatables;
  23847. private _identity;
  23848. private _synchronizedWithMesh;
  23849. private _ranges;
  23850. private _lastAbsoluteTransformsUpdateId;
  23851. private _canUseTextureForBones;
  23852. /** @hidden */
  23853. _numBonesWithLinkedTransformNode: number;
  23854. /**
  23855. * Specifies if the skeleton should be serialized
  23856. */
  23857. doNotSerialize: boolean;
  23858. /**
  23859. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23860. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23861. */
  23862. useTextureToStoreBoneMatrices: boolean;
  23863. private _animationPropertiesOverride;
  23864. /**
  23865. * Gets or sets the animation properties override
  23866. */
  23867. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23868. /**
  23869. * An observable triggered before computing the skeleton's matrices
  23870. */
  23871. onBeforeComputeObservable: Observable<Skeleton>;
  23872. /**
  23873. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23874. */
  23875. readonly isUsingTextureForMatrices: boolean;
  23876. /**
  23877. * Creates a new skeleton
  23878. * @param name defines the skeleton name
  23879. * @param id defines the skeleton Id
  23880. * @param scene defines the hosting scene
  23881. */
  23882. constructor(
  23883. /** defines the skeleton name */
  23884. name: string,
  23885. /** defines the skeleton Id */
  23886. id: string, scene: Scene);
  23887. /**
  23888. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23889. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23890. * @returns a Float32Array containing matrices data
  23891. */
  23892. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23893. /**
  23894. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23895. * @returns a raw texture containing the data
  23896. */
  23897. getTransformMatrixTexture(): Nullable<RawTexture>;
  23898. /**
  23899. * Gets the current hosting scene
  23900. * @returns a scene object
  23901. */
  23902. getScene(): Scene;
  23903. /**
  23904. * Gets a string representing the current skeleton data
  23905. * @param fullDetails defines a boolean indicating if we want a verbose version
  23906. * @returns a string representing the current skeleton data
  23907. */
  23908. toString(fullDetails?: boolean): string;
  23909. /**
  23910. * Get bone's index searching by name
  23911. * @param name defines bone's name to search for
  23912. * @return the indice of the bone. Returns -1 if not found
  23913. */
  23914. getBoneIndexByName(name: string): number;
  23915. /**
  23916. * Creater a new animation range
  23917. * @param name defines the name of the range
  23918. * @param from defines the start key
  23919. * @param to defines the end key
  23920. */
  23921. createAnimationRange(name: string, from: number, to: number): void;
  23922. /**
  23923. * Delete a specific animation range
  23924. * @param name defines the name of the range
  23925. * @param deleteFrames defines if frames must be removed as well
  23926. */
  23927. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23928. /**
  23929. * Gets a specific animation range
  23930. * @param name defines the name of the range to look for
  23931. * @returns the requested animation range or null if not found
  23932. */
  23933. getAnimationRange(name: string): Nullable<AnimationRange>;
  23934. /**
  23935. * Gets the list of all animation ranges defined on this skeleton
  23936. * @returns an array
  23937. */
  23938. getAnimationRanges(): Nullable<AnimationRange>[];
  23939. /**
  23940. * Copy animation range from a source skeleton.
  23941. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23942. * @param source defines the source skeleton
  23943. * @param name defines the name of the range to copy
  23944. * @param rescaleAsRequired defines if rescaling must be applied if required
  23945. * @returns true if operation was successful
  23946. */
  23947. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23948. /**
  23949. * Forces the skeleton to go to rest pose
  23950. */
  23951. returnToRest(): void;
  23952. private _getHighestAnimationFrame;
  23953. /**
  23954. * Begin a specific animation range
  23955. * @param name defines the name of the range to start
  23956. * @param loop defines if looping must be turned on (false by default)
  23957. * @param speedRatio defines the speed ratio to apply (1 by default)
  23958. * @param onAnimationEnd defines a callback which will be called when animation will end
  23959. * @returns a new animatable
  23960. */
  23961. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23962. /** @hidden */
  23963. _markAsDirty(): void;
  23964. /** @hidden */
  23965. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23966. /** @hidden */
  23967. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23968. private _computeTransformMatrices;
  23969. /**
  23970. * Build all resources required to render a skeleton
  23971. */
  23972. prepare(): void;
  23973. /**
  23974. * Gets the list of animatables currently running for this skeleton
  23975. * @returns an array of animatables
  23976. */
  23977. getAnimatables(): IAnimatable[];
  23978. /**
  23979. * Clone the current skeleton
  23980. * @param name defines the name of the new skeleton
  23981. * @param id defines the id of the enw skeleton
  23982. * @returns the new skeleton
  23983. */
  23984. clone(name: string, id: string): Skeleton;
  23985. /**
  23986. * Enable animation blending for this skeleton
  23987. * @param blendingSpeed defines the blending speed to apply
  23988. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23989. */
  23990. enableBlending(blendingSpeed?: number): void;
  23991. /**
  23992. * Releases all resources associated with the current skeleton
  23993. */
  23994. dispose(): void;
  23995. /**
  23996. * Serialize the skeleton in a JSON object
  23997. * @returns a JSON object
  23998. */
  23999. serialize(): any;
  24000. /**
  24001. * Creates a new skeleton from serialized data
  24002. * @param parsedSkeleton defines the serialized data
  24003. * @param scene defines the hosting scene
  24004. * @returns a new skeleton
  24005. */
  24006. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  24007. /**
  24008. * Compute all node absolute transforms
  24009. * @param forceUpdate defines if computation must be done even if cache is up to date
  24010. */
  24011. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  24012. /**
  24013. * Gets the root pose matrix
  24014. * @returns a matrix
  24015. */
  24016. getPoseMatrix(): Nullable<Matrix>;
  24017. /**
  24018. * Sorts bones per internal index
  24019. */
  24020. sortBones(): void;
  24021. private _sortBones;
  24022. }
  24023. }
  24024. declare module "babylonjs/Bones/bone" {
  24025. import { Skeleton } from "babylonjs/Bones/skeleton";
  24026. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  24027. import { Nullable } from "babylonjs/types";
  24028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24029. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24030. import { Node } from "babylonjs/node";
  24031. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24032. /**
  24033. * Class used to store bone information
  24034. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24035. */
  24036. export class Bone extends Node {
  24037. /**
  24038. * defines the bone name
  24039. */
  24040. name: string;
  24041. private static _tmpVecs;
  24042. private static _tmpQuat;
  24043. private static _tmpMats;
  24044. /**
  24045. * Gets the list of child bones
  24046. */
  24047. children: Bone[];
  24048. /** Gets the animations associated with this bone */
  24049. animations: import("babylonjs/Animations/animation").Animation[];
  24050. /**
  24051. * Gets or sets bone length
  24052. */
  24053. length: number;
  24054. /**
  24055. * @hidden Internal only
  24056. * Set this value to map this bone to a different index in the transform matrices
  24057. * Set this value to -1 to exclude the bone from the transform matrices
  24058. */
  24059. _index: Nullable<number>;
  24060. private _skeleton;
  24061. private _localMatrix;
  24062. private _restPose;
  24063. private _baseMatrix;
  24064. private _absoluteTransform;
  24065. private _invertedAbsoluteTransform;
  24066. private _parent;
  24067. private _scalingDeterminant;
  24068. private _worldTransform;
  24069. private _localScaling;
  24070. private _localRotation;
  24071. private _localPosition;
  24072. private _needToDecompose;
  24073. private _needToCompose;
  24074. /** @hidden */
  24075. _linkedTransformNode: Nullable<TransformNode>;
  24076. /** @hidden */
  24077. /** @hidden */
  24078. _matrix: Matrix;
  24079. /**
  24080. * Create a new bone
  24081. * @param name defines the bone name
  24082. * @param skeleton defines the parent skeleton
  24083. * @param parentBone defines the parent (can be null if the bone is the root)
  24084. * @param localMatrix defines the local matrix
  24085. * @param restPose defines the rest pose matrix
  24086. * @param baseMatrix defines the base matrix
  24087. * @param index defines index of the bone in the hiearchy
  24088. */
  24089. constructor(
  24090. /**
  24091. * defines the bone name
  24092. */
  24093. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  24094. /**
  24095. * Gets the parent skeleton
  24096. * @returns a skeleton
  24097. */
  24098. getSkeleton(): Skeleton;
  24099. /**
  24100. * Gets parent bone
  24101. * @returns a bone or null if the bone is the root of the bone hierarchy
  24102. */
  24103. getParent(): Nullable<Bone>;
  24104. /**
  24105. * Sets the parent bone
  24106. * @param parent defines the parent (can be null if the bone is the root)
  24107. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24108. */
  24109. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  24110. /**
  24111. * Gets the local matrix
  24112. * @returns a matrix
  24113. */
  24114. getLocalMatrix(): Matrix;
  24115. /**
  24116. * Gets the base matrix (initial matrix which remains unchanged)
  24117. * @returns a matrix
  24118. */
  24119. getBaseMatrix(): Matrix;
  24120. /**
  24121. * Gets the rest pose matrix
  24122. * @returns a matrix
  24123. */
  24124. getRestPose(): Matrix;
  24125. /**
  24126. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  24127. */
  24128. getWorldMatrix(): Matrix;
  24129. /**
  24130. * Sets the local matrix to rest pose matrix
  24131. */
  24132. returnToRest(): void;
  24133. /**
  24134. * Gets the inverse of the absolute transform matrix.
  24135. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  24136. * @returns a matrix
  24137. */
  24138. getInvertedAbsoluteTransform(): Matrix;
  24139. /**
  24140. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  24141. * @returns a matrix
  24142. */
  24143. getAbsoluteTransform(): Matrix;
  24144. /**
  24145. * Links with the given transform node.
  24146. * The local matrix of this bone is copied from the transform node every frame.
  24147. * @param transformNode defines the transform node to link to
  24148. */
  24149. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  24150. /** Gets or sets current position (in local space) */
  24151. position: Vector3;
  24152. /** Gets or sets current rotation (in local space) */
  24153. rotation: Vector3;
  24154. /** Gets or sets current rotation quaternion (in local space) */
  24155. rotationQuaternion: Quaternion;
  24156. /** Gets or sets current scaling (in local space) */
  24157. scaling: Vector3;
  24158. /**
  24159. * Gets the animation properties override
  24160. */
  24161. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24162. private _decompose;
  24163. private _compose;
  24164. /**
  24165. * Update the base and local matrices
  24166. * @param matrix defines the new base or local matrix
  24167. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24168. * @param updateLocalMatrix defines if the local matrix should be updated
  24169. */
  24170. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  24171. /** @hidden */
  24172. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  24173. /**
  24174. * Flag the bone as dirty (Forcing it to update everything)
  24175. */
  24176. markAsDirty(): void;
  24177. private _markAsDirtyAndCompose;
  24178. private _markAsDirtyAndDecompose;
  24179. /**
  24180. * Translate the bone in local or world space
  24181. * @param vec The amount to translate the bone
  24182. * @param space The space that the translation is in
  24183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24184. */
  24185. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24186. /**
  24187. * Set the postion of the bone in local or world space
  24188. * @param position The position to set the bone
  24189. * @param space The space that the position is in
  24190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24191. */
  24192. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24193. /**
  24194. * Set the absolute position of the bone (world space)
  24195. * @param position The position to set the bone
  24196. * @param mesh The mesh that this bone is attached to
  24197. */
  24198. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  24199. /**
  24200. * Scale the bone on the x, y and z axes (in local space)
  24201. * @param x The amount to scale the bone on the x axis
  24202. * @param y The amount to scale the bone on the y axis
  24203. * @param z The amount to scale the bone on the z axis
  24204. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  24205. */
  24206. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  24207. /**
  24208. * Set the bone scaling in local space
  24209. * @param scale defines the scaling vector
  24210. */
  24211. setScale(scale: Vector3): void;
  24212. /**
  24213. * Gets the current scaling in local space
  24214. * @returns the current scaling vector
  24215. */
  24216. getScale(): Vector3;
  24217. /**
  24218. * Gets the current scaling in local space and stores it in a target vector
  24219. * @param result defines the target vector
  24220. */
  24221. getScaleToRef(result: Vector3): void;
  24222. /**
  24223. * Set the yaw, pitch, and roll of the bone in local or world space
  24224. * @param yaw The rotation of the bone on the y axis
  24225. * @param pitch The rotation of the bone on the x axis
  24226. * @param roll The rotation of the bone on the z axis
  24227. * @param space The space that the axes of rotation are in
  24228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24229. */
  24230. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  24231. /**
  24232. * Add a rotation to the bone on an axis in local or world space
  24233. * @param axis The axis to rotate the bone on
  24234. * @param amount The amount to rotate the bone
  24235. * @param space The space that the axis is in
  24236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24237. */
  24238. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  24239. /**
  24240. * Set the rotation of the bone to a particular axis angle in local or world space
  24241. * @param axis The axis to rotate the bone on
  24242. * @param angle The angle that the bone should be rotated to
  24243. * @param space The space that the axis is in
  24244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24245. */
  24246. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  24247. /**
  24248. * Set the euler rotation of the bone in local of world space
  24249. * @param rotation The euler rotation that the bone should be set to
  24250. * @param space The space that the rotation is in
  24251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24252. */
  24253. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24254. /**
  24255. * Set the quaternion rotation of the bone in local of world space
  24256. * @param quat The quaternion rotation that the bone should be set to
  24257. * @param space The space that the rotation is in
  24258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24259. */
  24260. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  24261. /**
  24262. * Set the rotation matrix of the bone in local of world space
  24263. * @param rotMat The rotation matrix that the bone should be set to
  24264. * @param space The space that the rotation is in
  24265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24266. */
  24267. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  24268. private _rotateWithMatrix;
  24269. private _getNegativeRotationToRef;
  24270. /**
  24271. * Get the position of the bone in local or world space
  24272. * @param space The space that the returned position is in
  24273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24274. * @returns The position of the bone
  24275. */
  24276. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24277. /**
  24278. * Copy the position of the bone to a vector3 in local or world space
  24279. * @param space The space that the returned position is in
  24280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24281. * @param result The vector3 to copy the position to
  24282. */
  24283. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  24284. /**
  24285. * Get the absolute position of the bone (world space)
  24286. * @param mesh The mesh that this bone is attached to
  24287. * @returns The absolute position of the bone
  24288. */
  24289. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  24290. /**
  24291. * Copy the absolute position of the bone (world space) to the result param
  24292. * @param mesh The mesh that this bone is attached to
  24293. * @param result The vector3 to copy the absolute position to
  24294. */
  24295. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  24296. /**
  24297. * Compute the absolute transforms of this bone and its children
  24298. */
  24299. computeAbsoluteTransforms(): void;
  24300. /**
  24301. * Get the world direction from an axis that is in the local space of the bone
  24302. * @param localAxis The local direction that is used to compute the world direction
  24303. * @param mesh The mesh that this bone is attached to
  24304. * @returns The world direction
  24305. */
  24306. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24307. /**
  24308. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  24309. * @param localAxis The local direction that is used to compute the world direction
  24310. * @param mesh The mesh that this bone is attached to
  24311. * @param result The vector3 that the world direction will be copied to
  24312. */
  24313. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24314. /**
  24315. * Get the euler rotation of the bone in local or world space
  24316. * @param space The space that the rotation should be in
  24317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24318. * @returns The euler rotation
  24319. */
  24320. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24321. /**
  24322. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  24323. * @param space The space that the rotation should be in
  24324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24325. * @param result The vector3 that the rotation should be copied to
  24326. */
  24327. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24328. /**
  24329. * Get the quaternion rotation of the bone in either local or world space
  24330. * @param space The space that the rotation should be in
  24331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24332. * @returns The quaternion rotation
  24333. */
  24334. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  24335. /**
  24336. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  24337. * @param space The space that the rotation should be in
  24338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24339. * @param result The quaternion that the rotation should be copied to
  24340. */
  24341. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  24342. /**
  24343. * Get the rotation matrix of the bone in local or world space
  24344. * @param space The space that the rotation should be in
  24345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24346. * @returns The rotation matrix
  24347. */
  24348. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  24349. /**
  24350. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  24351. * @param space The space that the rotation should be in
  24352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24353. * @param result The quaternion that the rotation should be copied to
  24354. */
  24355. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  24356. /**
  24357. * Get the world position of a point that is in the local space of the bone
  24358. * @param position The local position
  24359. * @param mesh The mesh that this bone is attached to
  24360. * @returns The world position
  24361. */
  24362. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24363. /**
  24364. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  24365. * @param position The local position
  24366. * @param mesh The mesh that this bone is attached to
  24367. * @param result The vector3 that the world position should be copied to
  24368. */
  24369. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24370. /**
  24371. * Get the local position of a point that is in world space
  24372. * @param position The world position
  24373. * @param mesh The mesh that this bone is attached to
  24374. * @returns The local position
  24375. */
  24376. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24377. /**
  24378. * Get the local position of a point that is in world space and copy it to the result param
  24379. * @param position The world position
  24380. * @param mesh The mesh that this bone is attached to
  24381. * @param result The vector3 that the local position should be copied to
  24382. */
  24383. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24384. }
  24385. }
  24386. declare module "babylonjs/Animations/animatable" {
  24387. import { Animation } from "babylonjs/Animations/animation";
  24388. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24389. import { Nullable } from "babylonjs/types";
  24390. import { Observable } from "babylonjs/Misc/observable";
  24391. import { Scene } from "babylonjs/scene";
  24392. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  24393. import { Node } from "babylonjs/node";
  24394. /**
  24395. * Class used to store an actual running animation
  24396. */
  24397. export class Animatable {
  24398. /** defines the target object */
  24399. target: any;
  24400. /** defines the starting frame number (default is 0) */
  24401. fromFrame: number;
  24402. /** defines the ending frame number (default is 100) */
  24403. toFrame: number;
  24404. /** defines if the animation must loop (default is false) */
  24405. loopAnimation: boolean;
  24406. /** defines a callback to call when animation ends if it is not looping */
  24407. onAnimationEnd?: (() => void) | null | undefined;
  24408. /** defines a callback to call when animation loops */
  24409. onAnimationLoop?: (() => void) | null | undefined;
  24410. private _localDelayOffset;
  24411. private _pausedDelay;
  24412. private _runtimeAnimations;
  24413. private _paused;
  24414. private _scene;
  24415. private _speedRatio;
  24416. private _weight;
  24417. private _syncRoot;
  24418. /**
  24419. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24420. * This will only apply for non looping animation (default is true)
  24421. */
  24422. disposeOnEnd: boolean;
  24423. /**
  24424. * Gets a boolean indicating if the animation has started
  24425. */
  24426. animationStarted: boolean;
  24427. /**
  24428. * Observer raised when the animation ends
  24429. */
  24430. onAnimationEndObservable: Observable<Animatable>;
  24431. /**
  24432. * Observer raised when the animation loops
  24433. */
  24434. onAnimationLoopObservable: Observable<Animatable>;
  24435. /**
  24436. * Gets the root Animatable used to synchronize and normalize animations
  24437. */
  24438. readonly syncRoot: Animatable;
  24439. /**
  24440. * Gets the current frame of the first RuntimeAnimation
  24441. * Used to synchronize Animatables
  24442. */
  24443. readonly masterFrame: number;
  24444. /**
  24445. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24446. */
  24447. weight: number;
  24448. /**
  24449. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24450. */
  24451. speedRatio: number;
  24452. /**
  24453. * Creates a new Animatable
  24454. * @param scene defines the hosting scene
  24455. * @param target defines the target object
  24456. * @param fromFrame defines the starting frame number (default is 0)
  24457. * @param toFrame defines the ending frame number (default is 100)
  24458. * @param loopAnimation defines if the animation must loop (default is false)
  24459. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24460. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24461. * @param animations defines a group of animation to add to the new Animatable
  24462. * @param onAnimationLoop defines a callback to call when animation loops
  24463. */
  24464. constructor(scene: Scene,
  24465. /** defines the target object */
  24466. target: any,
  24467. /** defines the starting frame number (default is 0) */
  24468. fromFrame?: number,
  24469. /** defines the ending frame number (default is 100) */
  24470. toFrame?: number,
  24471. /** defines if the animation must loop (default is false) */
  24472. loopAnimation?: boolean, speedRatio?: number,
  24473. /** defines a callback to call when animation ends if it is not looping */
  24474. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24475. /** defines a callback to call when animation loops */
  24476. onAnimationLoop?: (() => void) | null | undefined);
  24477. /**
  24478. * Synchronize and normalize current Animatable with a source Animatable
  24479. * This is useful when using animation weights and when animations are not of the same length
  24480. * @param root defines the root Animatable to synchronize with
  24481. * @returns the current Animatable
  24482. */
  24483. syncWith(root: Animatable): Animatable;
  24484. /**
  24485. * Gets the list of runtime animations
  24486. * @returns an array of RuntimeAnimation
  24487. */
  24488. getAnimations(): RuntimeAnimation[];
  24489. /**
  24490. * Adds more animations to the current animatable
  24491. * @param target defines the target of the animations
  24492. * @param animations defines the new animations to add
  24493. */
  24494. appendAnimations(target: any, animations: Animation[]): void;
  24495. /**
  24496. * Gets the source animation for a specific property
  24497. * @param property defines the propertyu to look for
  24498. * @returns null or the source animation for the given property
  24499. */
  24500. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24501. /**
  24502. * Gets the runtime animation for a specific property
  24503. * @param property defines the propertyu to look for
  24504. * @returns null or the runtime animation for the given property
  24505. */
  24506. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24507. /**
  24508. * Resets the animatable to its original state
  24509. */
  24510. reset(): void;
  24511. /**
  24512. * Allows the animatable to blend with current running animations
  24513. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24514. * @param blendingSpeed defines the blending speed to use
  24515. */
  24516. enableBlending(blendingSpeed: number): void;
  24517. /**
  24518. * Disable animation blending
  24519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24520. */
  24521. disableBlending(): void;
  24522. /**
  24523. * Jump directly to a given frame
  24524. * @param frame defines the frame to jump to
  24525. */
  24526. goToFrame(frame: number): void;
  24527. /**
  24528. * Pause the animation
  24529. */
  24530. pause(): void;
  24531. /**
  24532. * Restart the animation
  24533. */
  24534. restart(): void;
  24535. private _raiseOnAnimationEnd;
  24536. /**
  24537. * Stop and delete the current animation
  24538. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24539. * @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)
  24540. */
  24541. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24542. /**
  24543. * Wait asynchronously for the animation to end
  24544. * @returns a promise which will be fullfilled when the animation ends
  24545. */
  24546. waitAsync(): Promise<Animatable>;
  24547. /** @hidden */
  24548. _animate(delay: number): boolean;
  24549. }
  24550. module "babylonjs/scene" {
  24551. interface Scene {
  24552. /** @hidden */
  24553. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24554. /** @hidden */
  24555. _processLateAnimationBindingsForMatrices(holder: {
  24556. totalWeight: number;
  24557. animations: RuntimeAnimation[];
  24558. originalValue: Matrix;
  24559. }): any;
  24560. /** @hidden */
  24561. _processLateAnimationBindingsForQuaternions(holder: {
  24562. totalWeight: number;
  24563. animations: RuntimeAnimation[];
  24564. originalValue: Quaternion;
  24565. }, refQuaternion: Quaternion): Quaternion;
  24566. /** @hidden */
  24567. _processLateAnimationBindings(): void;
  24568. /**
  24569. * Will start the animation sequence of a given target
  24570. * @param target defines the target
  24571. * @param from defines from which frame should animation start
  24572. * @param to defines until which frame should animation run.
  24573. * @param weight defines the weight to apply to the animation (1.0 by default)
  24574. * @param loop defines if the animation loops
  24575. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24576. * @param onAnimationEnd defines the function to be executed when the animation ends
  24577. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24578. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24579. * @param onAnimationLoop defines the callback to call when an animation loops
  24580. * @returns the animatable object created for this animation
  24581. */
  24582. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24583. /**
  24584. * Will start the animation sequence of a given target
  24585. * @param target defines the target
  24586. * @param from defines from which frame should animation start
  24587. * @param to defines until which frame should animation run.
  24588. * @param loop defines if the animation loops
  24589. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24590. * @param onAnimationEnd defines the function to be executed when the animation ends
  24591. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24592. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24593. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24594. * @param onAnimationLoop defines the callback to call when an animation loops
  24595. * @returns the animatable object created for this animation
  24596. */
  24597. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24598. /**
  24599. * Will start the animation sequence of a given target and its hierarchy
  24600. * @param target defines the target
  24601. * @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.
  24602. * @param from defines from which frame should animation start
  24603. * @param to defines until which frame should animation run.
  24604. * @param loop defines if the animation loops
  24605. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24606. * @param onAnimationEnd defines the function to be executed when the animation ends
  24607. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24608. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24609. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24610. * @param onAnimationLoop defines the callback to call when an animation loops
  24611. * @returns the list of created animatables
  24612. */
  24613. 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[];
  24614. /**
  24615. * Begin a new animation on a given node
  24616. * @param target defines the target where the animation will take place
  24617. * @param animations defines the list of animations to start
  24618. * @param from defines the initial value
  24619. * @param to defines the final value
  24620. * @param loop defines if you want animation to loop (off by default)
  24621. * @param speedRatio defines the speed ratio to apply to all animations
  24622. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24623. * @param onAnimationLoop defines the callback to call when an animation loops
  24624. * @returns the list of created animatables
  24625. */
  24626. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24627. /**
  24628. * Begin a new animation on a given node and its hierarchy
  24629. * @param target defines the root node where the animation will take place
  24630. * @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.
  24631. * @param animations defines the list of animations to start
  24632. * @param from defines the initial value
  24633. * @param to defines the final value
  24634. * @param loop defines if you want animation to loop (off by default)
  24635. * @param speedRatio defines the speed ratio to apply to all animations
  24636. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24637. * @param onAnimationLoop defines the callback to call when an animation loops
  24638. * @returns the list of animatables created for all nodes
  24639. */
  24640. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24641. /**
  24642. * Gets the animatable associated with a specific target
  24643. * @param target defines the target of the animatable
  24644. * @returns the required animatable if found
  24645. */
  24646. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24647. /**
  24648. * Gets all animatables associated with a given target
  24649. * @param target defines the target to look animatables for
  24650. * @returns an array of Animatables
  24651. */
  24652. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24653. /**
  24654. * Will stop the animation of the given target
  24655. * @param target - the target
  24656. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24657. * @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)
  24658. */
  24659. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24660. /**
  24661. * Stops and removes all animations that have been applied to the scene
  24662. */
  24663. stopAllAnimations(): void;
  24664. }
  24665. }
  24666. module "babylonjs/Bones/bone" {
  24667. interface Bone {
  24668. /**
  24669. * Copy an animation range from another bone
  24670. * @param source defines the source bone
  24671. * @param rangeName defines the range name to copy
  24672. * @param frameOffset defines the frame offset
  24673. * @param rescaleAsRequired defines if rescaling must be applied if required
  24674. * @param skelDimensionsRatio defines the scaling ratio
  24675. * @returns true if operation was successful
  24676. */
  24677. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24678. }
  24679. }
  24680. }
  24681. declare module "babylonjs/node" {
  24682. import { Scene } from "babylonjs/scene";
  24683. import { Nullable } from "babylonjs/types";
  24684. import { Matrix } from "babylonjs/Maths/math";
  24685. import { Engine } from "babylonjs/Engines/engine";
  24686. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24687. import { Observable } from "babylonjs/Misc/observable";
  24688. import { Animatable } from "babylonjs/Animations/animatable";
  24689. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24690. import { Animation } from "babylonjs/Animations/animation";
  24691. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24693. /**
  24694. * Defines how a node can be built from a string name.
  24695. */
  24696. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24697. /**
  24698. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24699. */
  24700. export class Node implements IBehaviorAware<Node> {
  24701. /** @hidden */
  24702. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24703. private static _NodeConstructors;
  24704. /**
  24705. * Add a new node constructor
  24706. * @param type defines the type name of the node to construct
  24707. * @param constructorFunc defines the constructor function
  24708. */
  24709. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24710. /**
  24711. * Returns a node constructor based on type name
  24712. * @param type defines the type name
  24713. * @param name defines the new node name
  24714. * @param scene defines the hosting scene
  24715. * @param options defines optional options to transmit to constructors
  24716. * @returns the new constructor or null
  24717. */
  24718. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24719. /**
  24720. * Gets or sets the name of the node
  24721. */
  24722. name: string;
  24723. /**
  24724. * Gets or sets the id of the node
  24725. */
  24726. id: string;
  24727. /**
  24728. * Gets or sets the unique id of the node
  24729. */
  24730. uniqueId: number;
  24731. /**
  24732. * Gets or sets a string used to store user defined state for the node
  24733. */
  24734. state: string;
  24735. /**
  24736. * Gets or sets an object used to store user defined information for the node
  24737. */
  24738. metadata: any;
  24739. /**
  24740. * For internal use only. Please do not use.
  24741. */
  24742. reservedDataStore: any;
  24743. /**
  24744. * Gets or sets a boolean used to define if the node must be serialized
  24745. */
  24746. doNotSerialize: boolean;
  24747. /** @hidden */
  24748. _isDisposed: boolean;
  24749. /**
  24750. * Gets a list of Animations associated with the node
  24751. */
  24752. animations: import("babylonjs/Animations/animation").Animation[];
  24753. protected _ranges: {
  24754. [name: string]: Nullable<AnimationRange>;
  24755. };
  24756. /**
  24757. * Callback raised when the node is ready to be used
  24758. */
  24759. onReady: (node: Node) => void;
  24760. private _isEnabled;
  24761. private _isParentEnabled;
  24762. private _isReady;
  24763. /** @hidden */
  24764. _currentRenderId: number;
  24765. private _parentRenderId;
  24766. protected _childRenderId: number;
  24767. /** @hidden */
  24768. _waitingParentId: Nullable<string>;
  24769. /** @hidden */
  24770. _scene: Scene;
  24771. /** @hidden */
  24772. _cache: any;
  24773. private _parentNode;
  24774. private _children;
  24775. /** @hidden */
  24776. _worldMatrix: Matrix;
  24777. /** @hidden */
  24778. _worldMatrixDeterminant: number;
  24779. /** @hidden */
  24780. private _sceneRootNodesIndex;
  24781. /**
  24782. * Gets a boolean indicating if the node has been disposed
  24783. * @returns true if the node was disposed
  24784. */
  24785. isDisposed(): boolean;
  24786. /**
  24787. * Gets or sets the parent of the node
  24788. */
  24789. parent: Nullable<Node>;
  24790. private addToSceneRootNodes;
  24791. private removeFromSceneRootNodes;
  24792. private _animationPropertiesOverride;
  24793. /**
  24794. * Gets or sets the animation properties override
  24795. */
  24796. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24797. /**
  24798. * Gets a string idenfifying the name of the class
  24799. * @returns "Node" string
  24800. */
  24801. getClassName(): string;
  24802. /** @hidden */
  24803. readonly _isNode: boolean;
  24804. /**
  24805. * An event triggered when the mesh is disposed
  24806. */
  24807. onDisposeObservable: Observable<Node>;
  24808. private _onDisposeObserver;
  24809. /**
  24810. * Sets a callback that will be raised when the node will be disposed
  24811. */
  24812. onDispose: () => void;
  24813. /**
  24814. * Creates a new Node
  24815. * @param name the name and id to be given to this node
  24816. * @param scene the scene this node will be added to
  24817. * @param addToRootNodes the node will be added to scene.rootNodes
  24818. */
  24819. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24820. /**
  24821. * Gets the scene of the node
  24822. * @returns a scene
  24823. */
  24824. getScene(): Scene;
  24825. /**
  24826. * Gets the engine of the node
  24827. * @returns a Engine
  24828. */
  24829. getEngine(): Engine;
  24830. private _behaviors;
  24831. /**
  24832. * Attach a behavior to the node
  24833. * @see http://doc.babylonjs.com/features/behaviour
  24834. * @param behavior defines the behavior to attach
  24835. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24836. * @returns the current Node
  24837. */
  24838. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24839. /**
  24840. * Remove an attached behavior
  24841. * @see http://doc.babylonjs.com/features/behaviour
  24842. * @param behavior defines the behavior to attach
  24843. * @returns the current Node
  24844. */
  24845. removeBehavior(behavior: Behavior<Node>): Node;
  24846. /**
  24847. * Gets the list of attached behaviors
  24848. * @see http://doc.babylonjs.com/features/behaviour
  24849. */
  24850. readonly behaviors: Behavior<Node>[];
  24851. /**
  24852. * Gets an attached behavior by name
  24853. * @param name defines the name of the behavior to look for
  24854. * @see http://doc.babylonjs.com/features/behaviour
  24855. * @returns null if behavior was not found else the requested behavior
  24856. */
  24857. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24858. /**
  24859. * Returns the latest update of the World matrix
  24860. * @returns a Matrix
  24861. */
  24862. getWorldMatrix(): Matrix;
  24863. /** @hidden */
  24864. _getWorldMatrixDeterminant(): number;
  24865. /**
  24866. * Returns directly the latest state of the mesh World matrix.
  24867. * A Matrix is returned.
  24868. */
  24869. readonly worldMatrixFromCache: Matrix;
  24870. /** @hidden */
  24871. _initCache(): void;
  24872. /** @hidden */
  24873. updateCache(force?: boolean): void;
  24874. /** @hidden */
  24875. _updateCache(ignoreParentClass?: boolean): void;
  24876. /** @hidden */
  24877. _isSynchronized(): boolean;
  24878. /** @hidden */
  24879. _markSyncedWithParent(): void;
  24880. /** @hidden */
  24881. isSynchronizedWithParent(): boolean;
  24882. /** @hidden */
  24883. isSynchronized(): boolean;
  24884. /**
  24885. * Is this node ready to be used/rendered
  24886. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24887. * @return true if the node is ready
  24888. */
  24889. isReady(completeCheck?: boolean): boolean;
  24890. /**
  24891. * Is this node enabled?
  24892. * 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
  24893. * @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
  24894. * @return whether this node (and its parent) is enabled
  24895. */
  24896. isEnabled(checkAncestors?: boolean): boolean;
  24897. /** @hidden */
  24898. protected _syncParentEnabledState(): void;
  24899. /**
  24900. * Set the enabled state of this node
  24901. * @param value defines the new enabled state
  24902. */
  24903. setEnabled(value: boolean): void;
  24904. /**
  24905. * Is this node a descendant of the given node?
  24906. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24907. * @param ancestor defines the parent node to inspect
  24908. * @returns a boolean indicating if this node is a descendant of the given node
  24909. */
  24910. isDescendantOf(ancestor: Node): boolean;
  24911. /** @hidden */
  24912. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24913. /**
  24914. * Will return all nodes that have this node as ascendant
  24915. * @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
  24916. * @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
  24917. * @return all children nodes of all types
  24918. */
  24919. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24920. /**
  24921. * Get all child-meshes of this node
  24922. * @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)
  24923. * @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
  24924. * @returns an array of AbstractMesh
  24925. */
  24926. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24927. /**
  24928. * Get all direct children of this node
  24929. * @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
  24930. * @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)
  24931. * @returns an array of Node
  24932. */
  24933. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24934. /** @hidden */
  24935. _setReady(state: boolean): void;
  24936. /**
  24937. * Get an animation by name
  24938. * @param name defines the name of the animation to look for
  24939. * @returns null if not found else the requested animation
  24940. */
  24941. getAnimationByName(name: string): Nullable<Animation>;
  24942. /**
  24943. * Creates an animation range for this node
  24944. * @param name defines the name of the range
  24945. * @param from defines the starting key
  24946. * @param to defines the end key
  24947. */
  24948. createAnimationRange(name: string, from: number, to: number): void;
  24949. /**
  24950. * Delete a specific animation range
  24951. * @param name defines the name of the range to delete
  24952. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24953. */
  24954. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24955. /**
  24956. * Get an animation range by name
  24957. * @param name defines the name of the animation range to look for
  24958. * @returns null if not found else the requested animation range
  24959. */
  24960. getAnimationRange(name: string): Nullable<AnimationRange>;
  24961. /**
  24962. * Will start the animation sequence
  24963. * @param name defines the range frames for animation sequence
  24964. * @param loop defines if the animation should loop (false by default)
  24965. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24966. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24967. * @returns the object created for this animation. If range does not exist, it will return null
  24968. */
  24969. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24970. /**
  24971. * Serialize animation ranges into a JSON compatible object
  24972. * @returns serialization object
  24973. */
  24974. serializeAnimationRanges(): any;
  24975. /**
  24976. * Computes the world matrix of the node
  24977. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24978. * @returns the world matrix
  24979. */
  24980. computeWorldMatrix(force?: boolean): Matrix;
  24981. /**
  24982. * Releases resources associated with this node.
  24983. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24984. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24985. */
  24986. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24987. /**
  24988. * Parse animation range data from a serialization object and store them into a given node
  24989. * @param node defines where to store the animation ranges
  24990. * @param parsedNode defines the serialization object to read data from
  24991. * @param scene defines the hosting scene
  24992. */
  24993. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24994. }
  24995. }
  24996. declare module "babylonjs/Animations/animation" {
  24997. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  24998. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  24999. import { Nullable } from "babylonjs/types";
  25000. import { Scene } from "babylonjs/scene";
  25001. import { IAnimatable } from "babylonjs/Misc/tools";
  25002. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25003. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25004. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25005. import { Node } from "babylonjs/node";
  25006. import { Animatable } from "babylonjs/Animations/animatable";
  25007. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25008. /**
  25009. * Class used to store any kind of animation
  25010. */
  25011. export class Animation {
  25012. /**Name of the animation */
  25013. name: string;
  25014. /**Property to animate */
  25015. targetProperty: string;
  25016. /**The frames per second of the animation */
  25017. framePerSecond: number;
  25018. /**The data type of the animation */
  25019. dataType: number;
  25020. /**The loop mode of the animation */
  25021. loopMode?: number | undefined;
  25022. /**Specifies if blending should be enabled */
  25023. enableBlending?: boolean | undefined;
  25024. /**
  25025. * Use matrix interpolation instead of using direct key value when animating matrices
  25026. */
  25027. static AllowMatricesInterpolation: boolean;
  25028. /**
  25029. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25030. */
  25031. static AllowMatrixDecomposeForInterpolation: boolean;
  25032. /**
  25033. * Stores the key frames of the animation
  25034. */
  25035. private _keys;
  25036. /**
  25037. * Stores the easing function of the animation
  25038. */
  25039. private _easingFunction;
  25040. /**
  25041. * @hidden Internal use only
  25042. */
  25043. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25044. /**
  25045. * The set of event that will be linked to this animation
  25046. */
  25047. private _events;
  25048. /**
  25049. * Stores an array of target property paths
  25050. */
  25051. targetPropertyPath: string[];
  25052. /**
  25053. * Stores the blending speed of the animation
  25054. */
  25055. blendingSpeed: number;
  25056. /**
  25057. * Stores the animation ranges for the animation
  25058. */
  25059. private _ranges;
  25060. /**
  25061. * @hidden Internal use
  25062. */
  25063. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25064. /**
  25065. * Sets up an animation
  25066. * @param property The property to animate
  25067. * @param animationType The animation type to apply
  25068. * @param framePerSecond The frames per second of the animation
  25069. * @param easingFunction The easing function used in the animation
  25070. * @returns The created animation
  25071. */
  25072. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25073. /**
  25074. * Create and start an animation on a node
  25075. * @param name defines the name of the global animation that will be run on all nodes
  25076. * @param node defines the root node where the animation will take place
  25077. * @param targetProperty defines property to animate
  25078. * @param framePerSecond defines the number of frame per second yo use
  25079. * @param totalFrame defines the number of frames in total
  25080. * @param from defines the initial value
  25081. * @param to defines the final value
  25082. * @param loopMode defines which loop mode you want to use (off by default)
  25083. * @param easingFunction defines the easing function to use (linear by default)
  25084. * @param onAnimationEnd defines the callback to call when animation end
  25085. * @returns the animatable created for this animation
  25086. */
  25087. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25088. /**
  25089. * Create and start an animation on a node and its descendants
  25090. * @param name defines the name of the global animation that will be run on all nodes
  25091. * @param node defines the root node where the animation will take place
  25092. * @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
  25093. * @param targetProperty defines property to animate
  25094. * @param framePerSecond defines the number of frame per second to use
  25095. * @param totalFrame defines the number of frames in total
  25096. * @param from defines the initial value
  25097. * @param to defines the final value
  25098. * @param loopMode defines which loop mode you want to use (off by default)
  25099. * @param easingFunction defines the easing function to use (linear by default)
  25100. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25101. * @returns the list of animatables created for all nodes
  25102. * @example https://www.babylonjs-playground.com/#MH0VLI
  25103. */
  25104. 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[]>;
  25105. /**
  25106. * Creates a new animation, merges it with the existing animations and starts it
  25107. * @param name Name of the animation
  25108. * @param node Node which contains the scene that begins the animations
  25109. * @param targetProperty Specifies which property to animate
  25110. * @param framePerSecond The frames per second of the animation
  25111. * @param totalFrame The total number of frames
  25112. * @param from The frame at the beginning of the animation
  25113. * @param to The frame at the end of the animation
  25114. * @param loopMode Specifies the loop mode of the animation
  25115. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25116. * @param onAnimationEnd Callback to run once the animation is complete
  25117. * @returns Nullable animation
  25118. */
  25119. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25120. /**
  25121. * Transition property of an host to the target Value
  25122. * @param property The property to transition
  25123. * @param targetValue The target Value of the property
  25124. * @param host The object where the property to animate belongs
  25125. * @param scene Scene used to run the animation
  25126. * @param frameRate Framerate (in frame/s) to use
  25127. * @param transition The transition type we want to use
  25128. * @param duration The duration of the animation, in milliseconds
  25129. * @param onAnimationEnd Callback trigger at the end of the animation
  25130. * @returns Nullable animation
  25131. */
  25132. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25133. /**
  25134. * Return the array of runtime animations currently using this animation
  25135. */
  25136. readonly runtimeAnimations: RuntimeAnimation[];
  25137. /**
  25138. * Specifies if any of the runtime animations are currently running
  25139. */
  25140. readonly hasRunningRuntimeAnimations: boolean;
  25141. /**
  25142. * Initializes the animation
  25143. * @param name Name of the animation
  25144. * @param targetProperty Property to animate
  25145. * @param framePerSecond The frames per second of the animation
  25146. * @param dataType The data type of the animation
  25147. * @param loopMode The loop mode of the animation
  25148. * @param enableBlending Specifies if blending should be enabled
  25149. */
  25150. constructor(
  25151. /**Name of the animation */
  25152. name: string,
  25153. /**Property to animate */
  25154. targetProperty: string,
  25155. /**The frames per second of the animation */
  25156. framePerSecond: number,
  25157. /**The data type of the animation */
  25158. dataType: number,
  25159. /**The loop mode of the animation */
  25160. loopMode?: number | undefined,
  25161. /**Specifies if blending should be enabled */
  25162. enableBlending?: boolean | undefined);
  25163. /**
  25164. * Converts the animation to a string
  25165. * @param fullDetails support for multiple levels of logging within scene loading
  25166. * @returns String form of the animation
  25167. */
  25168. toString(fullDetails?: boolean): string;
  25169. /**
  25170. * Add an event to this animation
  25171. * @param event Event to add
  25172. */
  25173. addEvent(event: AnimationEvent): void;
  25174. /**
  25175. * Remove all events found at the given frame
  25176. * @param frame The frame to remove events from
  25177. */
  25178. removeEvents(frame: number): void;
  25179. /**
  25180. * Retrieves all the events from the animation
  25181. * @returns Events from the animation
  25182. */
  25183. getEvents(): AnimationEvent[];
  25184. /**
  25185. * Creates an animation range
  25186. * @param name Name of the animation range
  25187. * @param from Starting frame of the animation range
  25188. * @param to Ending frame of the animation
  25189. */
  25190. createRange(name: string, from: number, to: number): void;
  25191. /**
  25192. * Deletes an animation range by name
  25193. * @param name Name of the animation range to delete
  25194. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25195. */
  25196. deleteRange(name: string, deleteFrames?: boolean): void;
  25197. /**
  25198. * Gets the animation range by name, or null if not defined
  25199. * @param name Name of the animation range
  25200. * @returns Nullable animation range
  25201. */
  25202. getRange(name: string): Nullable<AnimationRange>;
  25203. /**
  25204. * Gets the key frames from the animation
  25205. * @returns The key frames of the animation
  25206. */
  25207. getKeys(): Array<IAnimationKey>;
  25208. /**
  25209. * Gets the highest frame rate of the animation
  25210. * @returns Highest frame rate of the animation
  25211. */
  25212. getHighestFrame(): number;
  25213. /**
  25214. * Gets the easing function of the animation
  25215. * @returns Easing function of the animation
  25216. */
  25217. getEasingFunction(): IEasingFunction;
  25218. /**
  25219. * Sets the easing function of the animation
  25220. * @param easingFunction A custom mathematical formula for animation
  25221. */
  25222. setEasingFunction(easingFunction: EasingFunction): void;
  25223. /**
  25224. * Interpolates a scalar linearly
  25225. * @param startValue Start value of the animation curve
  25226. * @param endValue End value of the animation curve
  25227. * @param gradient Scalar amount to interpolate
  25228. * @returns Interpolated scalar value
  25229. */
  25230. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25231. /**
  25232. * Interpolates a scalar cubically
  25233. * @param startValue Start value of the animation curve
  25234. * @param outTangent End tangent of the animation
  25235. * @param endValue End value of the animation curve
  25236. * @param inTangent Start tangent of the animation curve
  25237. * @param gradient Scalar amount to interpolate
  25238. * @returns Interpolated scalar value
  25239. */
  25240. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25241. /**
  25242. * Interpolates a quaternion using a spherical linear interpolation
  25243. * @param startValue Start value of the animation curve
  25244. * @param endValue End value of the animation curve
  25245. * @param gradient Scalar amount to interpolate
  25246. * @returns Interpolated quaternion value
  25247. */
  25248. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25249. /**
  25250. * Interpolates a quaternion cubically
  25251. * @param startValue Start value of the animation curve
  25252. * @param outTangent End tangent of the animation curve
  25253. * @param endValue End value of the animation curve
  25254. * @param inTangent Start tangent of the animation curve
  25255. * @param gradient Scalar amount to interpolate
  25256. * @returns Interpolated quaternion value
  25257. */
  25258. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25259. /**
  25260. * Interpolates a Vector3 linearl
  25261. * @param startValue Start value of the animation curve
  25262. * @param endValue End value of the animation curve
  25263. * @param gradient Scalar amount to interpolate
  25264. * @returns Interpolated scalar value
  25265. */
  25266. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25267. /**
  25268. * Interpolates a Vector3 cubically
  25269. * @param startValue Start value of the animation curve
  25270. * @param outTangent End tangent of the animation
  25271. * @param endValue End value of the animation curve
  25272. * @param inTangent Start tangent of the animation curve
  25273. * @param gradient Scalar amount to interpolate
  25274. * @returns InterpolatedVector3 value
  25275. */
  25276. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25277. /**
  25278. * Interpolates a Vector2 linearly
  25279. * @param startValue Start value of the animation curve
  25280. * @param endValue End value of the animation curve
  25281. * @param gradient Scalar amount to interpolate
  25282. * @returns Interpolated Vector2 value
  25283. */
  25284. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25285. /**
  25286. * Interpolates a Vector2 cubically
  25287. * @param startValue Start value of the animation curve
  25288. * @param outTangent End tangent of the animation
  25289. * @param endValue End value of the animation curve
  25290. * @param inTangent Start tangent of the animation curve
  25291. * @param gradient Scalar amount to interpolate
  25292. * @returns Interpolated Vector2 value
  25293. */
  25294. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25295. /**
  25296. * Interpolates a size linearly
  25297. * @param startValue Start value of the animation curve
  25298. * @param endValue End value of the animation curve
  25299. * @param gradient Scalar amount to interpolate
  25300. * @returns Interpolated Size value
  25301. */
  25302. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25303. /**
  25304. * Interpolates a Color3 linearly
  25305. * @param startValue Start value of the animation curve
  25306. * @param endValue End value of the animation curve
  25307. * @param gradient Scalar amount to interpolate
  25308. * @returns Interpolated Color3 value
  25309. */
  25310. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25311. /**
  25312. * @hidden Internal use only
  25313. */
  25314. _getKeyValue(value: any): any;
  25315. /**
  25316. * @hidden Internal use only
  25317. */
  25318. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25319. /**
  25320. * Defines the function to use to interpolate matrices
  25321. * @param startValue defines the start matrix
  25322. * @param endValue defines the end matrix
  25323. * @param gradient defines the gradient between both matrices
  25324. * @param result defines an optional target matrix where to store the interpolation
  25325. * @returns the interpolated matrix
  25326. */
  25327. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25328. /**
  25329. * Makes a copy of the animation
  25330. * @returns Cloned animation
  25331. */
  25332. clone(): Animation;
  25333. /**
  25334. * Sets the key frames of the animation
  25335. * @param values The animation key frames to set
  25336. */
  25337. setKeys(values: Array<IAnimationKey>): void;
  25338. /**
  25339. * Serializes the animation to an object
  25340. * @returns Serialized object
  25341. */
  25342. serialize(): any;
  25343. /**
  25344. * Float animation type
  25345. */
  25346. private static _ANIMATIONTYPE_FLOAT;
  25347. /**
  25348. * Vector3 animation type
  25349. */
  25350. private static _ANIMATIONTYPE_VECTOR3;
  25351. /**
  25352. * Quaternion animation type
  25353. */
  25354. private static _ANIMATIONTYPE_QUATERNION;
  25355. /**
  25356. * Matrix animation type
  25357. */
  25358. private static _ANIMATIONTYPE_MATRIX;
  25359. /**
  25360. * Color3 animation type
  25361. */
  25362. private static _ANIMATIONTYPE_COLOR3;
  25363. /**
  25364. * Vector2 animation type
  25365. */
  25366. private static _ANIMATIONTYPE_VECTOR2;
  25367. /**
  25368. * Size animation type
  25369. */
  25370. private static _ANIMATIONTYPE_SIZE;
  25371. /**
  25372. * Relative Loop Mode
  25373. */
  25374. private static _ANIMATIONLOOPMODE_RELATIVE;
  25375. /**
  25376. * Cycle Loop Mode
  25377. */
  25378. private static _ANIMATIONLOOPMODE_CYCLE;
  25379. /**
  25380. * Constant Loop Mode
  25381. */
  25382. private static _ANIMATIONLOOPMODE_CONSTANT;
  25383. /**
  25384. * Get the float animation type
  25385. */
  25386. static readonly ANIMATIONTYPE_FLOAT: number;
  25387. /**
  25388. * Get the Vector3 animation type
  25389. */
  25390. static readonly ANIMATIONTYPE_VECTOR3: number;
  25391. /**
  25392. * Get the Vector2 animation type
  25393. */
  25394. static readonly ANIMATIONTYPE_VECTOR2: number;
  25395. /**
  25396. * Get the Size animation type
  25397. */
  25398. static readonly ANIMATIONTYPE_SIZE: number;
  25399. /**
  25400. * Get the Quaternion animation type
  25401. */
  25402. static readonly ANIMATIONTYPE_QUATERNION: number;
  25403. /**
  25404. * Get the Matrix animation type
  25405. */
  25406. static readonly ANIMATIONTYPE_MATRIX: number;
  25407. /**
  25408. * Get the Color3 animation type
  25409. */
  25410. static readonly ANIMATIONTYPE_COLOR3: number;
  25411. /**
  25412. * Get the Relative Loop Mode
  25413. */
  25414. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25415. /**
  25416. * Get the Cycle Loop Mode
  25417. */
  25418. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25419. /**
  25420. * Get the Constant Loop Mode
  25421. */
  25422. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25423. /** @hidden */
  25424. static _UniversalLerp(left: any, right: any, amount: number): any;
  25425. /**
  25426. * Parses an animation object and creates an animation
  25427. * @param parsedAnimation Parsed animation object
  25428. * @returns Animation object
  25429. */
  25430. static Parse(parsedAnimation: any): Animation;
  25431. /**
  25432. * Appends the serialized animations from the source animations
  25433. * @param source Source containing the animations
  25434. * @param destination Target to store the animations
  25435. */
  25436. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25437. }
  25438. }
  25439. declare module "babylonjs/Materials/Textures/baseTexture" {
  25440. import { Observable } from "babylonjs/Misc/observable";
  25441. import { IAnimatable } from "babylonjs/Misc/tools";
  25442. import { Nullable } from "babylonjs/types";
  25443. import { Scene } from "babylonjs/scene";
  25444. import { Matrix, ISize } from "babylonjs/Maths/math";
  25445. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25447. /**
  25448. * Base class of all the textures in babylon.
  25449. * It groups all the common properties the materials, post process, lights... might need
  25450. * in order to make a correct use of the texture.
  25451. */
  25452. export class BaseTexture implements IAnimatable {
  25453. /**
  25454. * Default anisotropic filtering level for the application.
  25455. * It is set to 4 as a good tradeoff between perf and quality.
  25456. */
  25457. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25458. /**
  25459. * Gets or sets the unique id of the texture
  25460. */
  25461. uniqueId: number;
  25462. /**
  25463. * Define the name of the texture.
  25464. */
  25465. name: string;
  25466. /**
  25467. * Gets or sets an object used to store user defined information.
  25468. */
  25469. metadata: any;
  25470. /**
  25471. * For internal use only. Please do not use.
  25472. */
  25473. reservedDataStore: any;
  25474. private _hasAlpha;
  25475. /**
  25476. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25477. */
  25478. hasAlpha: boolean;
  25479. /**
  25480. * Defines if the alpha value should be determined via the rgb values.
  25481. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25482. */
  25483. getAlphaFromRGB: boolean;
  25484. /**
  25485. * Intensity or strength of the texture.
  25486. * It is commonly used by materials to fine tune the intensity of the texture
  25487. */
  25488. level: number;
  25489. /**
  25490. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25491. * This is part of the texture as textures usually maps to one uv set.
  25492. */
  25493. coordinatesIndex: number;
  25494. private _coordinatesMode;
  25495. /**
  25496. * How a texture is mapped.
  25497. *
  25498. * | Value | Type | Description |
  25499. * | ----- | ----------------------------------- | ----------- |
  25500. * | 0 | EXPLICIT_MODE | |
  25501. * | 1 | SPHERICAL_MODE | |
  25502. * | 2 | PLANAR_MODE | |
  25503. * | 3 | CUBIC_MODE | |
  25504. * | 4 | PROJECTION_MODE | |
  25505. * | 5 | SKYBOX_MODE | |
  25506. * | 6 | INVCUBIC_MODE | |
  25507. * | 7 | EQUIRECTANGULAR_MODE | |
  25508. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25509. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25510. */
  25511. coordinatesMode: number;
  25512. /**
  25513. * | Value | Type | Description |
  25514. * | ----- | ------------------ | ----------- |
  25515. * | 0 | CLAMP_ADDRESSMODE | |
  25516. * | 1 | WRAP_ADDRESSMODE | |
  25517. * | 2 | MIRROR_ADDRESSMODE | |
  25518. */
  25519. wrapU: number;
  25520. /**
  25521. * | Value | Type | Description |
  25522. * | ----- | ------------------ | ----------- |
  25523. * | 0 | CLAMP_ADDRESSMODE | |
  25524. * | 1 | WRAP_ADDRESSMODE | |
  25525. * | 2 | MIRROR_ADDRESSMODE | |
  25526. */
  25527. wrapV: number;
  25528. /**
  25529. * | Value | Type | Description |
  25530. * | ----- | ------------------ | ----------- |
  25531. * | 0 | CLAMP_ADDRESSMODE | |
  25532. * | 1 | WRAP_ADDRESSMODE | |
  25533. * | 2 | MIRROR_ADDRESSMODE | |
  25534. */
  25535. wrapR: number;
  25536. /**
  25537. * With compliant hardware and browser (supporting anisotropic filtering)
  25538. * this defines the level of anisotropic filtering in the texture.
  25539. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25540. */
  25541. anisotropicFilteringLevel: number;
  25542. /**
  25543. * Define if the texture is a cube texture or if false a 2d texture.
  25544. */
  25545. isCube: boolean;
  25546. /**
  25547. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25548. */
  25549. is3D: boolean;
  25550. /**
  25551. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25552. * HDR texture are usually stored in linear space.
  25553. * This only impacts the PBR and Background materials
  25554. */
  25555. gammaSpace: boolean;
  25556. /**
  25557. * Gets whether or not the texture contains RGBD data.
  25558. */
  25559. readonly isRGBD: boolean;
  25560. /**
  25561. * Is Z inverted in the texture (useful in a cube texture).
  25562. */
  25563. invertZ: boolean;
  25564. /**
  25565. * Are mip maps generated for this texture or not.
  25566. */
  25567. readonly noMipmap: boolean;
  25568. /**
  25569. * @hidden
  25570. */
  25571. lodLevelInAlpha: boolean;
  25572. /**
  25573. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25574. */
  25575. lodGenerationOffset: number;
  25576. /**
  25577. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25578. */
  25579. lodGenerationScale: number;
  25580. /**
  25581. * Define if the texture is a render target.
  25582. */
  25583. isRenderTarget: boolean;
  25584. /**
  25585. * Define the unique id of the texture in the scene.
  25586. */
  25587. readonly uid: string;
  25588. /**
  25589. * Return a string representation of the texture.
  25590. * @returns the texture as a string
  25591. */
  25592. toString(): string;
  25593. /**
  25594. * Get the class name of the texture.
  25595. * @returns "BaseTexture"
  25596. */
  25597. getClassName(): string;
  25598. /**
  25599. * Define the list of animation attached to the texture.
  25600. */
  25601. animations: import("babylonjs/Animations/animation").Animation[];
  25602. /**
  25603. * An event triggered when the texture is disposed.
  25604. */
  25605. onDisposeObservable: Observable<BaseTexture>;
  25606. private _onDisposeObserver;
  25607. /**
  25608. * Callback triggered when the texture has been disposed.
  25609. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25610. */
  25611. onDispose: () => void;
  25612. /**
  25613. * Define the current state of the loading sequence when in delayed load mode.
  25614. */
  25615. delayLoadState: number;
  25616. private _scene;
  25617. /** @hidden */
  25618. _texture: Nullable<InternalTexture>;
  25619. private _uid;
  25620. /**
  25621. * Define if the texture is preventinga material to render or not.
  25622. * If not and the texture is not ready, the engine will use a default black texture instead.
  25623. */
  25624. readonly isBlocking: boolean;
  25625. /**
  25626. * Instantiates a new BaseTexture.
  25627. * Base class of all the textures in babylon.
  25628. * It groups all the common properties the materials, post process, lights... might need
  25629. * in order to make a correct use of the texture.
  25630. * @param scene Define the scene the texture blongs to
  25631. */
  25632. constructor(scene: Nullable<Scene>);
  25633. /**
  25634. * Get the scene the texture belongs to.
  25635. * @returns the scene or null if undefined
  25636. */
  25637. getScene(): Nullable<Scene>;
  25638. /**
  25639. * Get the texture transform matrix used to offset tile the texture for istance.
  25640. * @returns the transformation matrix
  25641. */
  25642. getTextureMatrix(): Matrix;
  25643. /**
  25644. * Get the texture reflection matrix used to rotate/transform the reflection.
  25645. * @returns the reflection matrix
  25646. */
  25647. getReflectionTextureMatrix(): Matrix;
  25648. /**
  25649. * Get the underlying lower level texture from Babylon.
  25650. * @returns the insternal texture
  25651. */
  25652. getInternalTexture(): Nullable<InternalTexture>;
  25653. /**
  25654. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25655. * @returns true if ready or not blocking
  25656. */
  25657. isReadyOrNotBlocking(): boolean;
  25658. /**
  25659. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25660. * @returns true if fully ready
  25661. */
  25662. isReady(): boolean;
  25663. private _cachedSize;
  25664. /**
  25665. * Get the size of the texture.
  25666. * @returns the texture size.
  25667. */
  25668. getSize(): ISize;
  25669. /**
  25670. * Get the base size of the texture.
  25671. * It can be different from the size if the texture has been resized for POT for instance
  25672. * @returns the base size
  25673. */
  25674. getBaseSize(): ISize;
  25675. /**
  25676. * Update the sampling mode of the texture.
  25677. * Default is Trilinear mode.
  25678. *
  25679. * | Value | Type | Description |
  25680. * | ----- | ------------------ | ----------- |
  25681. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25682. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25683. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25684. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25685. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25686. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25687. * | 7 | NEAREST_LINEAR | |
  25688. * | 8 | NEAREST_NEAREST | |
  25689. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25690. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25691. * | 11 | LINEAR_LINEAR | |
  25692. * | 12 | LINEAR_NEAREST | |
  25693. *
  25694. * > _mag_: magnification filter (close to the viewer)
  25695. * > _min_: minification filter (far from the viewer)
  25696. * > _mip_: filter used between mip map levels
  25697. *@param samplingMode Define the new sampling mode of the texture
  25698. */
  25699. updateSamplingMode(samplingMode: number): void;
  25700. /**
  25701. * Scales the texture if is `canRescale()`
  25702. * @param ratio the resize factor we want to use to rescale
  25703. */
  25704. scale(ratio: number): void;
  25705. /**
  25706. * Get if the texture can rescale.
  25707. */
  25708. readonly canRescale: boolean;
  25709. /** @hidden */
  25710. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25711. /** @hidden */
  25712. _rebuild(): void;
  25713. /**
  25714. * Triggers the load sequence in delayed load mode.
  25715. */
  25716. delayLoad(): void;
  25717. /**
  25718. * Clones the texture.
  25719. * @returns the cloned texture
  25720. */
  25721. clone(): Nullable<BaseTexture>;
  25722. /**
  25723. * Get the texture underlying type (INT, FLOAT...)
  25724. */
  25725. readonly textureType: number;
  25726. /**
  25727. * Get the texture underlying format (RGB, RGBA...)
  25728. */
  25729. readonly textureFormat: number;
  25730. /**
  25731. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25732. * This will returns an RGBA array buffer containing either in values (0-255) or
  25733. * float values (0-1) depending of the underlying buffer type.
  25734. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25735. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25736. * @param buffer defines a user defined buffer to fill with data (can be null)
  25737. * @returns The Array buffer containing the pixels data.
  25738. */
  25739. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25740. /**
  25741. * Release and destroy the underlying lower level texture aka internalTexture.
  25742. */
  25743. releaseInternalTexture(): void;
  25744. /**
  25745. * Get the polynomial representation of the texture data.
  25746. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25747. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25748. */
  25749. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25750. /** @hidden */
  25751. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25752. /** @hidden */
  25753. readonly _lodTextureMid: Nullable<BaseTexture>;
  25754. /** @hidden */
  25755. readonly _lodTextureLow: Nullable<BaseTexture>;
  25756. /**
  25757. * Dispose the texture and release its associated resources.
  25758. */
  25759. dispose(): void;
  25760. /**
  25761. * Serialize the texture into a JSON representation that can be parsed later on.
  25762. * @returns the JSON representation of the texture
  25763. */
  25764. serialize(): any;
  25765. /**
  25766. * Helper function to be called back once a list of texture contains only ready textures.
  25767. * @param textures Define the list of textures to wait for
  25768. * @param callback Define the callback triggered once the entire list will be ready
  25769. */
  25770. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25771. }
  25772. }
  25773. declare module "babylonjs/Materials/uniformBuffer" {
  25774. import { Nullable, FloatArray } from "babylonjs/types";
  25775. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25776. import { Engine } from "babylonjs/Engines/engine";
  25777. import { Effect } from "babylonjs/Materials/effect";
  25778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25779. /**
  25780. * Uniform buffer objects.
  25781. *
  25782. * Handles blocks of uniform on the GPU.
  25783. *
  25784. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25785. *
  25786. * For more information, please refer to :
  25787. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25788. */
  25789. export class UniformBuffer {
  25790. private _engine;
  25791. private _buffer;
  25792. private _data;
  25793. private _bufferData;
  25794. private _dynamic?;
  25795. private _uniformLocations;
  25796. private _uniformSizes;
  25797. private _uniformLocationPointer;
  25798. private _needSync;
  25799. private _noUBO;
  25800. private _currentEffect;
  25801. private static _MAX_UNIFORM_SIZE;
  25802. private static _tempBuffer;
  25803. /**
  25804. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25805. * This is dynamic to allow compat with webgl 1 and 2.
  25806. * You will need to pass the name of the uniform as well as the value.
  25807. */
  25808. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25809. /**
  25810. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25811. * This is dynamic to allow compat with webgl 1 and 2.
  25812. * You will need to pass the name of the uniform as well as the value.
  25813. */
  25814. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25815. /**
  25816. * Lambda to Update a single float in a uniform buffer.
  25817. * This is dynamic to allow compat with webgl 1 and 2.
  25818. * You will need to pass the name of the uniform as well as the value.
  25819. */
  25820. updateFloat: (name: string, x: number) => void;
  25821. /**
  25822. * Lambda to Update a vec2 of float in a uniform buffer.
  25823. * This is dynamic to allow compat with webgl 1 and 2.
  25824. * You will need to pass the name of the uniform as well as the value.
  25825. */
  25826. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25827. /**
  25828. * Lambda to Update a vec3 of float in a uniform buffer.
  25829. * This is dynamic to allow compat with webgl 1 and 2.
  25830. * You will need to pass the name of the uniform as well as the value.
  25831. */
  25832. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25833. /**
  25834. * Lambda to Update a vec4 of float in a uniform buffer.
  25835. * This is dynamic to allow compat with webgl 1 and 2.
  25836. * You will need to pass the name of the uniform as well as the value.
  25837. */
  25838. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25839. /**
  25840. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25841. * This is dynamic to allow compat with webgl 1 and 2.
  25842. * You will need to pass the name of the uniform as well as the value.
  25843. */
  25844. updateMatrix: (name: string, mat: Matrix) => void;
  25845. /**
  25846. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25847. * This is dynamic to allow compat with webgl 1 and 2.
  25848. * You will need to pass the name of the uniform as well as the value.
  25849. */
  25850. updateVector3: (name: string, vector: Vector3) => void;
  25851. /**
  25852. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25853. * This is dynamic to allow compat with webgl 1 and 2.
  25854. * You will need to pass the name of the uniform as well as the value.
  25855. */
  25856. updateVector4: (name: string, vector: Vector4) => void;
  25857. /**
  25858. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25859. * This is dynamic to allow compat with webgl 1 and 2.
  25860. * You will need to pass the name of the uniform as well as the value.
  25861. */
  25862. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25863. /**
  25864. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25865. * This is dynamic to allow compat with webgl 1 and 2.
  25866. * You will need to pass the name of the uniform as well as the value.
  25867. */
  25868. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25869. /**
  25870. * Instantiates a new Uniform buffer objects.
  25871. *
  25872. * Handles blocks of uniform on the GPU.
  25873. *
  25874. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25875. *
  25876. * For more information, please refer to :
  25877. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25878. * @param engine Define the engine the buffer is associated with
  25879. * @param data Define the data contained in the buffer
  25880. * @param dynamic Define if the buffer is updatable
  25881. */
  25882. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25883. /**
  25884. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25885. * or just falling back on setUniformXXX calls.
  25886. */
  25887. readonly useUbo: boolean;
  25888. /**
  25889. * Indicates if the WebGL underlying uniform buffer is in sync
  25890. * with the javascript cache data.
  25891. */
  25892. readonly isSync: boolean;
  25893. /**
  25894. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25895. * Also, a dynamic UniformBuffer will disable cache verification and always
  25896. * update the underlying WebGL uniform buffer to the GPU.
  25897. * @returns if Dynamic, otherwise false
  25898. */
  25899. isDynamic(): boolean;
  25900. /**
  25901. * The data cache on JS side.
  25902. * @returns the underlying data as a float array
  25903. */
  25904. getData(): Float32Array;
  25905. /**
  25906. * The underlying WebGL Uniform buffer.
  25907. * @returns the webgl buffer
  25908. */
  25909. getBuffer(): Nullable<WebGLBuffer>;
  25910. /**
  25911. * std140 layout specifies how to align data within an UBO structure.
  25912. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25913. * for specs.
  25914. */
  25915. private _fillAlignment;
  25916. /**
  25917. * Adds an uniform in the buffer.
  25918. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25919. * for the layout to be correct !
  25920. * @param name Name of the uniform, as used in the uniform block in the shader.
  25921. * @param size Data size, or data directly.
  25922. */
  25923. addUniform(name: string, size: number | number[]): void;
  25924. /**
  25925. * Adds a Matrix 4x4 to the uniform buffer.
  25926. * @param name Name of the uniform, as used in the uniform block in the shader.
  25927. * @param mat A 4x4 matrix.
  25928. */
  25929. addMatrix(name: string, mat: Matrix): void;
  25930. /**
  25931. * Adds a vec2 to the uniform buffer.
  25932. * @param name Name of the uniform, as used in the uniform block in the shader.
  25933. * @param x Define the x component value of the vec2
  25934. * @param y Define the y component value of the vec2
  25935. */
  25936. addFloat2(name: string, x: number, y: number): void;
  25937. /**
  25938. * Adds a vec3 to the uniform buffer.
  25939. * @param name Name of the uniform, as used in the uniform block in the shader.
  25940. * @param x Define the x component value of the vec3
  25941. * @param y Define the y component value of the vec3
  25942. * @param z Define the z component value of the vec3
  25943. */
  25944. addFloat3(name: string, x: number, y: number, z: number): void;
  25945. /**
  25946. * Adds a vec3 to the uniform buffer.
  25947. * @param name Name of the uniform, as used in the uniform block in the shader.
  25948. * @param color Define the vec3 from a Color
  25949. */
  25950. addColor3(name: string, color: Color3): void;
  25951. /**
  25952. * Adds a vec4 to the uniform buffer.
  25953. * @param name Name of the uniform, as used in the uniform block in the shader.
  25954. * @param color Define the rgb components from a Color
  25955. * @param alpha Define the a component of the vec4
  25956. */
  25957. addColor4(name: string, color: Color3, alpha: number): void;
  25958. /**
  25959. * Adds a vec3 to the uniform buffer.
  25960. * @param name Name of the uniform, as used in the uniform block in the shader.
  25961. * @param vector Define the vec3 components from a Vector
  25962. */
  25963. addVector3(name: string, vector: Vector3): void;
  25964. /**
  25965. * Adds a Matrix 3x3 to the uniform buffer.
  25966. * @param name Name of the uniform, as used in the uniform block in the shader.
  25967. */
  25968. addMatrix3x3(name: string): void;
  25969. /**
  25970. * Adds a Matrix 2x2 to the uniform buffer.
  25971. * @param name Name of the uniform, as used in the uniform block in the shader.
  25972. */
  25973. addMatrix2x2(name: string): void;
  25974. /**
  25975. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25976. */
  25977. create(): void;
  25978. /** @hidden */
  25979. _rebuild(): void;
  25980. /**
  25981. * Updates the WebGL Uniform Buffer on the GPU.
  25982. * If the `dynamic` flag is set to true, no cache comparison is done.
  25983. * Otherwise, the buffer will be updated only if the cache differs.
  25984. */
  25985. update(): void;
  25986. /**
  25987. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25988. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25989. * @param data Define the flattened data
  25990. * @param size Define the size of the data.
  25991. */
  25992. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25993. private _updateMatrix3x3ForUniform;
  25994. private _updateMatrix3x3ForEffect;
  25995. private _updateMatrix2x2ForEffect;
  25996. private _updateMatrix2x2ForUniform;
  25997. private _updateFloatForEffect;
  25998. private _updateFloatForUniform;
  25999. private _updateFloat2ForEffect;
  26000. private _updateFloat2ForUniform;
  26001. private _updateFloat3ForEffect;
  26002. private _updateFloat3ForUniform;
  26003. private _updateFloat4ForEffect;
  26004. private _updateFloat4ForUniform;
  26005. private _updateMatrixForEffect;
  26006. private _updateMatrixForUniform;
  26007. private _updateVector3ForEffect;
  26008. private _updateVector3ForUniform;
  26009. private _updateVector4ForEffect;
  26010. private _updateVector4ForUniform;
  26011. private _updateColor3ForEffect;
  26012. private _updateColor3ForUniform;
  26013. private _updateColor4ForEffect;
  26014. private _updateColor4ForUniform;
  26015. /**
  26016. * Sets a sampler uniform on the effect.
  26017. * @param name Define the name of the sampler.
  26018. * @param texture Define the texture to set in the sampler
  26019. */
  26020. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26021. /**
  26022. * Directly updates the value of the uniform in the cache AND on the GPU.
  26023. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26024. * @param data Define the flattened data
  26025. */
  26026. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26027. /**
  26028. * Binds this uniform buffer to an effect.
  26029. * @param effect Define the effect to bind the buffer to
  26030. * @param name Name of the uniform block in the shader.
  26031. */
  26032. bindToEffect(effect: Effect, name: string): void;
  26033. /**
  26034. * Disposes the uniform buffer.
  26035. */
  26036. dispose(): void;
  26037. }
  26038. }
  26039. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26040. import { Nullable } from "babylonjs/types";
  26041. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26042. /**
  26043. * This represents the required contract to create a new type of texture loader.
  26044. */
  26045. export interface IInternalTextureLoader {
  26046. /**
  26047. * Defines wether the loader supports cascade loading the different faces.
  26048. */
  26049. supportCascades: boolean;
  26050. /**
  26051. * This returns if the loader support the current file information.
  26052. * @param extension defines the file extension of the file being loaded
  26053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26054. * @param fallback defines the fallback internal texture if any
  26055. * @param isBase64 defines whether the texture is encoded as a base64
  26056. * @param isBuffer defines whether the texture data are stored as a buffer
  26057. * @returns true if the loader can load the specified file
  26058. */
  26059. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26060. /**
  26061. * Transform the url before loading if required.
  26062. * @param rootUrl the url of the texture
  26063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26064. * @returns the transformed texture
  26065. */
  26066. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26067. /**
  26068. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26069. * @param rootUrl the url of the texture
  26070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26071. * @returns the fallback texture
  26072. */
  26073. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26074. /**
  26075. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26076. * @param data contains the texture data
  26077. * @param texture defines the BabylonJS internal texture
  26078. * @param createPolynomials will be true if polynomials have been requested
  26079. * @param onLoad defines the callback to trigger once the texture is ready
  26080. * @param onError defines the callback to trigger in case of error
  26081. */
  26082. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26083. /**
  26084. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26085. * @param data contains the texture data
  26086. * @param texture defines the BabylonJS internal texture
  26087. * @param callback defines the method to call once ready to upload
  26088. */
  26089. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26090. }
  26091. }
  26092. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26093. import { Scene } from "babylonjs/scene";
  26094. import { Engine } from "babylonjs/Engines/engine";
  26095. import { Texture } from "babylonjs/Materials/Textures/texture";
  26096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26097. /**
  26098. * Creation options of the multi render target texture.
  26099. */
  26100. export interface IMultiRenderTargetOptions {
  26101. /**
  26102. * Define if the texture needs to create mip maps after render.
  26103. */
  26104. generateMipMaps?: boolean;
  26105. /**
  26106. * Define the types of all the draw buffers we want to create
  26107. */
  26108. types?: number[];
  26109. /**
  26110. * Define the sampling modes of all the draw buffers we want to create
  26111. */
  26112. samplingModes?: number[];
  26113. /**
  26114. * Define if a depth buffer is required
  26115. */
  26116. generateDepthBuffer?: boolean;
  26117. /**
  26118. * Define if a stencil buffer is required
  26119. */
  26120. generateStencilBuffer?: boolean;
  26121. /**
  26122. * Define if a depth texture is required instead of a depth buffer
  26123. */
  26124. generateDepthTexture?: boolean;
  26125. /**
  26126. * Define the number of desired draw buffers
  26127. */
  26128. textureCount?: number;
  26129. /**
  26130. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26131. */
  26132. doNotChangeAspectRatio?: boolean;
  26133. /**
  26134. * Define the default type of the buffers we are creating
  26135. */
  26136. defaultType?: number;
  26137. }
  26138. /**
  26139. * A multi render target, like a render target provides the ability to render to a texture.
  26140. * Unlike the render target, it can render to several draw buffers in one draw.
  26141. * This is specially interesting in deferred rendering or for any effects requiring more than
  26142. * just one color from a single pass.
  26143. */
  26144. export class MultiRenderTarget extends RenderTargetTexture {
  26145. private _internalTextures;
  26146. private _textures;
  26147. private _multiRenderTargetOptions;
  26148. /**
  26149. * Get if draw buffers are currently supported by the used hardware and browser.
  26150. */
  26151. readonly isSupported: boolean;
  26152. /**
  26153. * Get the list of textures generated by the multi render target.
  26154. */
  26155. readonly textures: Texture[];
  26156. /**
  26157. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26158. */
  26159. readonly depthTexture: Texture;
  26160. /**
  26161. * Set the wrapping mode on U of all the textures we are rendering to.
  26162. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26163. */
  26164. wrapU: number;
  26165. /**
  26166. * Set the wrapping mode on V of all the textures we are rendering to.
  26167. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26168. */
  26169. wrapV: number;
  26170. /**
  26171. * Instantiate a new multi render target texture.
  26172. * A multi render target, like a render target provides the ability to render to a texture.
  26173. * Unlike the render target, it can render to several draw buffers in one draw.
  26174. * This is specially interesting in deferred rendering or for any effects requiring more than
  26175. * just one color from a single pass.
  26176. * @param name Define the name of the texture
  26177. * @param size Define the size of the buffers to render to
  26178. * @param count Define the number of target we are rendering into
  26179. * @param scene Define the scene the texture belongs to
  26180. * @param options Define the options used to create the multi render target
  26181. */
  26182. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26183. /** @hidden */
  26184. _rebuild(): void;
  26185. private _createInternalTextures;
  26186. private _createTextures;
  26187. /**
  26188. * Define the number of samples used if MSAA is enabled.
  26189. */
  26190. samples: number;
  26191. /**
  26192. * Resize all the textures in the multi render target.
  26193. * Be carrefull as it will recreate all the data in the new texture.
  26194. * @param size Define the new size
  26195. */
  26196. resize(size: any): void;
  26197. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26198. /**
  26199. * Dispose the render targets and their associated resources
  26200. */
  26201. dispose(): void;
  26202. /**
  26203. * Release all the underlying texture used as draw buffers.
  26204. */
  26205. releaseInternalTextures(): void;
  26206. }
  26207. }
  26208. declare module "babylonjs/Audio/analyser" {
  26209. import { Scene } from "babylonjs/scene";
  26210. /**
  26211. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26213. */
  26214. export class Analyser {
  26215. /**
  26216. * Gets or sets the smoothing
  26217. * @ignorenaming
  26218. */
  26219. SMOOTHING: number;
  26220. /**
  26221. * Gets or sets the FFT table size
  26222. * @ignorenaming
  26223. */
  26224. FFT_SIZE: number;
  26225. /**
  26226. * Gets or sets the bar graph amplitude
  26227. * @ignorenaming
  26228. */
  26229. BARGRAPHAMPLITUDE: number;
  26230. /**
  26231. * Gets or sets the position of the debug canvas
  26232. * @ignorenaming
  26233. */
  26234. DEBUGCANVASPOS: {
  26235. x: number;
  26236. y: number;
  26237. };
  26238. /**
  26239. * Gets or sets the debug canvas size
  26240. * @ignorenaming
  26241. */
  26242. DEBUGCANVASSIZE: {
  26243. width: number;
  26244. height: number;
  26245. };
  26246. private _byteFreqs;
  26247. private _byteTime;
  26248. private _floatFreqs;
  26249. private _webAudioAnalyser;
  26250. private _debugCanvas;
  26251. private _debugCanvasContext;
  26252. private _scene;
  26253. private _registerFunc;
  26254. private _audioEngine;
  26255. /**
  26256. * Creates a new analyser
  26257. * @param scene defines hosting scene
  26258. */
  26259. constructor(scene: Scene);
  26260. /**
  26261. * Get the number of data values you will have to play with for the visualization
  26262. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26263. * @returns a number
  26264. */
  26265. getFrequencyBinCount(): number;
  26266. /**
  26267. * Gets the current frequency data as a byte array
  26268. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26269. * @returns a Uint8Array
  26270. */
  26271. getByteFrequencyData(): Uint8Array;
  26272. /**
  26273. * Gets the current waveform as a byte array
  26274. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26275. * @returns a Uint8Array
  26276. */
  26277. getByteTimeDomainData(): Uint8Array;
  26278. /**
  26279. * Gets the current frequency data as a float array
  26280. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26281. * @returns a Float32Array
  26282. */
  26283. getFloatFrequencyData(): Float32Array;
  26284. /**
  26285. * Renders the debug canvas
  26286. */
  26287. drawDebugCanvas(): void;
  26288. /**
  26289. * Stops rendering the debug canvas and removes it
  26290. */
  26291. stopDebugCanvas(): void;
  26292. /**
  26293. * Connects two audio nodes
  26294. * @param inputAudioNode defines first node to connect
  26295. * @param outputAudioNode defines second node to connect
  26296. */
  26297. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26298. /**
  26299. * Releases all associated resources
  26300. */
  26301. dispose(): void;
  26302. }
  26303. }
  26304. declare module "babylonjs/Audio/audioEngine" {
  26305. import { IDisposable } from "babylonjs/scene";
  26306. import { Analyser } from "babylonjs/Audio/analyser";
  26307. import { Nullable } from "babylonjs/types";
  26308. import { Observable } from "babylonjs/Misc/observable";
  26309. /**
  26310. * This represents an audio engine and it is responsible
  26311. * to play, synchronize and analyse sounds throughout the application.
  26312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26313. */
  26314. export interface IAudioEngine extends IDisposable {
  26315. /**
  26316. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26317. */
  26318. readonly canUseWebAudio: boolean;
  26319. /**
  26320. * Gets the current AudioContext if available.
  26321. */
  26322. readonly audioContext: Nullable<AudioContext>;
  26323. /**
  26324. * The master gain node defines the global audio volume of your audio engine.
  26325. */
  26326. readonly masterGain: GainNode;
  26327. /**
  26328. * Gets whether or not mp3 are supported by your browser.
  26329. */
  26330. readonly isMP3supported: boolean;
  26331. /**
  26332. * Gets whether or not ogg are supported by your browser.
  26333. */
  26334. readonly isOGGsupported: boolean;
  26335. /**
  26336. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26337. * @ignoreNaming
  26338. */
  26339. WarnedWebAudioUnsupported: boolean;
  26340. /**
  26341. * Defines if the audio engine relies on a custom unlocked button.
  26342. * In this case, the embedded button will not be displayed.
  26343. */
  26344. useCustomUnlockedButton: boolean;
  26345. /**
  26346. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26347. */
  26348. readonly unlocked: boolean;
  26349. /**
  26350. * Event raised when audio has been unlocked on the browser.
  26351. */
  26352. onAudioUnlockedObservable: Observable<AudioEngine>;
  26353. /**
  26354. * Event raised when audio has been locked on the browser.
  26355. */
  26356. onAudioLockedObservable: Observable<AudioEngine>;
  26357. /**
  26358. * Flags the audio engine in Locked state.
  26359. * This happens due to new browser policies preventing audio to autoplay.
  26360. */
  26361. lock(): void;
  26362. /**
  26363. * Unlocks the audio engine once a user action has been done on the dom.
  26364. * This is helpful to resume play once browser policies have been satisfied.
  26365. */
  26366. unlock(): void;
  26367. }
  26368. /**
  26369. * This represents the default audio engine used in babylon.
  26370. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26372. */
  26373. export class AudioEngine implements IAudioEngine {
  26374. private _audioContext;
  26375. private _audioContextInitialized;
  26376. private _muteButton;
  26377. private _hostElement;
  26378. /**
  26379. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26380. */
  26381. canUseWebAudio: boolean;
  26382. /**
  26383. * The master gain node defines the global audio volume of your audio engine.
  26384. */
  26385. masterGain: GainNode;
  26386. /**
  26387. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26388. * @ignoreNaming
  26389. */
  26390. WarnedWebAudioUnsupported: boolean;
  26391. /**
  26392. * Gets whether or not mp3 are supported by your browser.
  26393. */
  26394. isMP3supported: boolean;
  26395. /**
  26396. * Gets whether or not ogg are supported by your browser.
  26397. */
  26398. isOGGsupported: boolean;
  26399. /**
  26400. * Gets whether audio has been unlocked on the device.
  26401. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26402. * a user interaction has happened.
  26403. */
  26404. unlocked: boolean;
  26405. /**
  26406. * Defines if the audio engine relies on a custom unlocked button.
  26407. * In this case, the embedded button will not be displayed.
  26408. */
  26409. useCustomUnlockedButton: boolean;
  26410. /**
  26411. * Event raised when audio has been unlocked on the browser.
  26412. */
  26413. onAudioUnlockedObservable: Observable<AudioEngine>;
  26414. /**
  26415. * Event raised when audio has been locked on the browser.
  26416. */
  26417. onAudioLockedObservable: Observable<AudioEngine>;
  26418. /**
  26419. * Gets the current AudioContext if available.
  26420. */
  26421. readonly audioContext: Nullable<AudioContext>;
  26422. private _connectedAnalyser;
  26423. /**
  26424. * Instantiates a new audio engine.
  26425. *
  26426. * There should be only one per page as some browsers restrict the number
  26427. * of audio contexts you can create.
  26428. * @param hostElement defines the host element where to display the mute icon if necessary
  26429. */
  26430. constructor(hostElement?: Nullable<HTMLElement>);
  26431. /**
  26432. * Flags the audio engine in Locked state.
  26433. * This happens due to new browser policies preventing audio to autoplay.
  26434. */
  26435. lock(): void;
  26436. /**
  26437. * Unlocks the audio engine once a user action has been done on the dom.
  26438. * This is helpful to resume play once browser policies have been satisfied.
  26439. */
  26440. unlock(): void;
  26441. private _resumeAudioContext;
  26442. private _initializeAudioContext;
  26443. private _tryToRun;
  26444. private _triggerRunningState;
  26445. private _triggerSuspendedState;
  26446. private _displayMuteButton;
  26447. private _moveButtonToTopLeft;
  26448. private _onResize;
  26449. private _hideMuteButton;
  26450. /**
  26451. * Destroy and release the resources associated with the audio ccontext.
  26452. */
  26453. dispose(): void;
  26454. /**
  26455. * Gets the global volume sets on the master gain.
  26456. * @returns the global volume if set or -1 otherwise
  26457. */
  26458. getGlobalVolume(): number;
  26459. /**
  26460. * Sets the global volume of your experience (sets on the master gain).
  26461. * @param newVolume Defines the new global volume of the application
  26462. */
  26463. setGlobalVolume(newVolume: number): void;
  26464. /**
  26465. * Connect the audio engine to an audio analyser allowing some amazing
  26466. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26468. * @param analyser The analyser to connect to the engine
  26469. */
  26470. connectToAnalyser(analyser: Analyser): void;
  26471. }
  26472. }
  26473. declare module "babylonjs/Loading/loadingScreen" {
  26474. /**
  26475. * Interface used to present a loading screen while loading a scene
  26476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26477. */
  26478. export interface ILoadingScreen {
  26479. /**
  26480. * Function called to display the loading screen
  26481. */
  26482. displayLoadingUI: () => void;
  26483. /**
  26484. * Function called to hide the loading screen
  26485. */
  26486. hideLoadingUI: () => void;
  26487. /**
  26488. * Gets or sets the color to use for the background
  26489. */
  26490. loadingUIBackgroundColor: string;
  26491. /**
  26492. * Gets or sets the text to display while loading
  26493. */
  26494. loadingUIText: string;
  26495. }
  26496. /**
  26497. * Class used for the default loading screen
  26498. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26499. */
  26500. export class DefaultLoadingScreen implements ILoadingScreen {
  26501. private _renderingCanvas;
  26502. private _loadingText;
  26503. private _loadingDivBackgroundColor;
  26504. private _loadingDiv;
  26505. private _loadingTextDiv;
  26506. /**
  26507. * Creates a new default loading screen
  26508. * @param _renderingCanvas defines the canvas used to render the scene
  26509. * @param _loadingText defines the default text to display
  26510. * @param _loadingDivBackgroundColor defines the default background color
  26511. */
  26512. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26513. /**
  26514. * Function called to display the loading screen
  26515. */
  26516. displayLoadingUI(): void;
  26517. /**
  26518. * Function called to hide the loading screen
  26519. */
  26520. hideLoadingUI(): void;
  26521. /**
  26522. * Gets or sets the text to display while loading
  26523. */
  26524. loadingUIText: string;
  26525. /**
  26526. * Gets or sets the color to use for the background
  26527. */
  26528. loadingUIBackgroundColor: string;
  26529. private _resizeLoadingUI;
  26530. }
  26531. }
  26532. declare module "babylonjs/Materials/Textures/videoTexture" {
  26533. import { Observable } from "babylonjs/Misc/observable";
  26534. import { Nullable } from "babylonjs/types";
  26535. import { Scene } from "babylonjs/scene";
  26536. import { Texture } from "babylonjs/Materials/Textures/texture";
  26537. /**
  26538. * Settings for finer control over video usage
  26539. */
  26540. export interface VideoTextureSettings {
  26541. /**
  26542. * Applies `autoplay` to video, if specified
  26543. */
  26544. autoPlay?: boolean;
  26545. /**
  26546. * Applies `loop` to video, if specified
  26547. */
  26548. loop?: boolean;
  26549. /**
  26550. * Automatically updates internal texture from video at every frame in the render loop
  26551. */
  26552. autoUpdateTexture: boolean;
  26553. /**
  26554. * Image src displayed during the video loading or until the user interacts with the video.
  26555. */
  26556. poster?: string;
  26557. }
  26558. /**
  26559. * If you want to display a video in your scene, this is the special texture for that.
  26560. * This special texture works similar to other textures, with the exception of a few parameters.
  26561. * @see https://doc.babylonjs.com/how_to/video_texture
  26562. */
  26563. export class VideoTexture extends Texture {
  26564. /**
  26565. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26566. */
  26567. readonly autoUpdateTexture: boolean;
  26568. /**
  26569. * The video instance used by the texture internally
  26570. */
  26571. readonly video: HTMLVideoElement;
  26572. private _onUserActionRequestedObservable;
  26573. /**
  26574. * Event triggerd when a dom action is required by the user to play the video.
  26575. * This happens due to recent changes in browser policies preventing video to auto start.
  26576. */
  26577. readonly onUserActionRequestedObservable: Observable<Texture>;
  26578. private _generateMipMaps;
  26579. private _engine;
  26580. private _stillImageCaptured;
  26581. private _displayingPosterTexture;
  26582. private _settings;
  26583. private _createInternalTextureOnEvent;
  26584. /**
  26585. * Creates a video texture.
  26586. * If you want to display a video in your scene, this is the special texture for that.
  26587. * This special texture works similar to other textures, with the exception of a few parameters.
  26588. * @see https://doc.babylonjs.com/how_to/video_texture
  26589. * @param name optional name, will detect from video source, if not defined
  26590. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26591. * @param scene is obviously the current scene.
  26592. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26593. * @param invertY is false by default but can be used to invert video on Y axis
  26594. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26595. * @param settings allows finer control over video usage
  26596. */
  26597. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26598. private _getName;
  26599. private _getVideo;
  26600. private _createInternalTexture;
  26601. private reset;
  26602. /**
  26603. * @hidden Internal method to initiate `update`.
  26604. */
  26605. _rebuild(): void;
  26606. /**
  26607. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26608. */
  26609. update(): void;
  26610. /**
  26611. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26612. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26613. */
  26614. updateTexture(isVisible: boolean): void;
  26615. protected _updateInternalTexture: () => void;
  26616. /**
  26617. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26618. * @param url New url.
  26619. */
  26620. updateURL(url: string): void;
  26621. /**
  26622. * Dispose the texture and release its associated resources.
  26623. */
  26624. dispose(): void;
  26625. /**
  26626. * Creates a video texture straight from your WebCam video feed.
  26627. * @param scene Define the scene the texture should be created in
  26628. * @param onReady Define a callback to triggered once the texture will be ready
  26629. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26630. */
  26631. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26632. minWidth: number;
  26633. maxWidth: number;
  26634. minHeight: number;
  26635. maxHeight: number;
  26636. deviceId: string;
  26637. }): void;
  26638. }
  26639. }
  26640. declare module "babylonjs/Engines/engine" {
  26641. import { Observable } from "babylonjs/Misc/observable";
  26642. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26643. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26644. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26645. import { Camera } from "babylonjs/Cameras/camera";
  26646. import { Scene } from "babylonjs/scene";
  26647. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26648. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26649. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26650. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26651. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26652. import { Material } from "babylonjs/Materials/material";
  26653. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26656. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26657. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26658. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26659. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26660. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26661. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26664. /**
  26665. * Interface for attribute information associated with buffer instanciation
  26666. */
  26667. export class InstancingAttributeInfo {
  26668. /**
  26669. * Index/offset of the attribute in the vertex shader
  26670. */
  26671. index: number;
  26672. /**
  26673. * size of the attribute, 1, 2, 3 or 4
  26674. */
  26675. attributeSize: number;
  26676. /**
  26677. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26678. * default is FLOAT
  26679. */
  26680. attribyteType: number;
  26681. /**
  26682. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26683. */
  26684. normalized: boolean;
  26685. /**
  26686. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26687. */
  26688. offset: number;
  26689. /**
  26690. * Name of the GLSL attribute, for debugging purpose only
  26691. */
  26692. attributeName: string;
  26693. }
  26694. /**
  26695. * Define options used to create a depth texture
  26696. */
  26697. export class DepthTextureCreationOptions {
  26698. /** Specifies whether or not a stencil should be allocated in the texture */
  26699. generateStencil?: boolean;
  26700. /** Specifies whether or not bilinear filtering is enable on the texture */
  26701. bilinearFiltering?: boolean;
  26702. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26703. comparisonFunction?: number;
  26704. /** Specifies if the created texture is a cube texture */
  26705. isCube?: boolean;
  26706. }
  26707. /**
  26708. * Class used to describe the capabilities of the engine relatively to the current browser
  26709. */
  26710. export class EngineCapabilities {
  26711. /** Maximum textures units per fragment shader */
  26712. maxTexturesImageUnits: number;
  26713. /** Maximum texture units per vertex shader */
  26714. maxVertexTextureImageUnits: number;
  26715. /** Maximum textures units in the entire pipeline */
  26716. maxCombinedTexturesImageUnits: number;
  26717. /** Maximum texture size */
  26718. maxTextureSize: number;
  26719. /** Maximum cube texture size */
  26720. maxCubemapTextureSize: number;
  26721. /** Maximum render texture size */
  26722. maxRenderTextureSize: number;
  26723. /** Maximum number of vertex attributes */
  26724. maxVertexAttribs: number;
  26725. /** Maximum number of varyings */
  26726. maxVaryingVectors: number;
  26727. /** Maximum number of uniforms per vertex shader */
  26728. maxVertexUniformVectors: number;
  26729. /** Maximum number of uniforms per fragment shader */
  26730. maxFragmentUniformVectors: number;
  26731. /** Defines if standard derivates (dx/dy) are supported */
  26732. standardDerivatives: boolean;
  26733. /** Defines if s3tc texture compression is supported */
  26734. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26735. /** Defines if pvrtc texture compression is supported */
  26736. pvrtc: any;
  26737. /** Defines if etc1 texture compression is supported */
  26738. etc1: any;
  26739. /** Defines if etc2 texture compression is supported */
  26740. etc2: any;
  26741. /** Defines if astc texture compression is supported */
  26742. astc: any;
  26743. /** Defines if float textures are supported */
  26744. textureFloat: boolean;
  26745. /** Defines if vertex array objects are supported */
  26746. vertexArrayObject: boolean;
  26747. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26748. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26749. /** Gets the maximum level of anisotropy supported */
  26750. maxAnisotropy: number;
  26751. /** Defines if instancing is supported */
  26752. instancedArrays: boolean;
  26753. /** Defines if 32 bits indices are supported */
  26754. uintIndices: boolean;
  26755. /** Defines if high precision shaders are supported */
  26756. highPrecisionShaderSupported: boolean;
  26757. /** Defines if depth reading in the fragment shader is supported */
  26758. fragmentDepthSupported: boolean;
  26759. /** Defines if float texture linear filtering is supported*/
  26760. textureFloatLinearFiltering: boolean;
  26761. /** Defines if rendering to float textures is supported */
  26762. textureFloatRender: boolean;
  26763. /** Defines if half float textures are supported*/
  26764. textureHalfFloat: boolean;
  26765. /** Defines if half float texture linear filtering is supported*/
  26766. textureHalfFloatLinearFiltering: boolean;
  26767. /** Defines if rendering to half float textures is supported */
  26768. textureHalfFloatRender: boolean;
  26769. /** Defines if textureLOD shader command is supported */
  26770. textureLOD: boolean;
  26771. /** Defines if draw buffers extension is supported */
  26772. drawBuffersExtension: boolean;
  26773. /** Defines if depth textures are supported */
  26774. depthTextureExtension: boolean;
  26775. /** Defines if float color buffer are supported */
  26776. colorBufferFloat: boolean;
  26777. /** Gets disjoint timer query extension (null if not supported) */
  26778. timerQuery: EXT_disjoint_timer_query;
  26779. /** Defines if timestamp can be used with timer query */
  26780. canUseTimestampForTimerQuery: boolean;
  26781. /** Function used to let the system compiles shaders in background */
  26782. parallelShaderCompile: {
  26783. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26784. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26785. COMPLETION_STATUS_KHR: number;
  26786. };
  26787. }
  26788. /** Interface defining initialization parameters for Engine class */
  26789. export interface EngineOptions extends WebGLContextAttributes {
  26790. /**
  26791. * Defines if the engine should no exceed a specified device ratio
  26792. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26793. */
  26794. limitDeviceRatio?: number;
  26795. /**
  26796. * Defines if webvr should be enabled automatically
  26797. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26798. */
  26799. autoEnableWebVR?: boolean;
  26800. /**
  26801. * Defines if webgl2 should be turned off even if supported
  26802. * @see http://doc.babylonjs.com/features/webgl2
  26803. */
  26804. disableWebGL2Support?: boolean;
  26805. /**
  26806. * Defines if webaudio should be initialized as well
  26807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26808. */
  26809. audioEngine?: boolean;
  26810. /**
  26811. * Defines if animations should run using a deterministic lock step
  26812. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26813. */
  26814. deterministicLockstep?: boolean;
  26815. /** Defines the maximum steps to use with deterministic lock step mode */
  26816. lockstepMaxSteps?: number;
  26817. /**
  26818. * Defines that engine should ignore context lost events
  26819. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26820. */
  26821. doNotHandleContextLost?: boolean;
  26822. /**
  26823. * Defines that engine should ignore modifying touch action attribute and style
  26824. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26825. */
  26826. doNotHandleTouchAction?: boolean;
  26827. }
  26828. /**
  26829. * Defines the interface used by display changed events
  26830. */
  26831. export interface IDisplayChangedEventArgs {
  26832. /** Gets the vrDisplay object (if any) */
  26833. vrDisplay: Nullable<any>;
  26834. /** Gets a boolean indicating if webVR is supported */
  26835. vrSupported: boolean;
  26836. }
  26837. /**
  26838. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26839. */
  26840. export class Engine {
  26841. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26842. static ExceptionList: ({
  26843. key: string;
  26844. capture: string;
  26845. captureConstraint: number;
  26846. targets: string[];
  26847. } | {
  26848. key: string;
  26849. capture: null;
  26850. captureConstraint: null;
  26851. targets: string[];
  26852. })[];
  26853. /** Gets the list of created engines */
  26854. static readonly Instances: Engine[];
  26855. /**
  26856. * Gets the latest created engine
  26857. */
  26858. static readonly LastCreatedEngine: Nullable<Engine>;
  26859. /**
  26860. * Gets the latest created scene
  26861. */
  26862. static readonly LastCreatedScene: Nullable<Scene>;
  26863. /**
  26864. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26865. * @param flag defines which part of the materials must be marked as dirty
  26866. * @param predicate defines a predicate used to filter which materials should be affected
  26867. */
  26868. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26869. /**
  26870. * Hidden
  26871. */
  26872. static _TextureLoaders: IInternalTextureLoader[];
  26873. /** Defines that alpha blending is disabled */
  26874. static readonly ALPHA_DISABLE: number;
  26875. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26876. static readonly ALPHA_ADD: number;
  26877. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26878. static readonly ALPHA_COMBINE: number;
  26879. /** Defines that alpha blending to DEST - SRC * DEST */
  26880. static readonly ALPHA_SUBTRACT: number;
  26881. /** Defines that alpha blending to SRC * DEST */
  26882. static readonly ALPHA_MULTIPLY: number;
  26883. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26884. static readonly ALPHA_MAXIMIZED: number;
  26885. /** Defines that alpha blending to SRC + DEST */
  26886. static readonly ALPHA_ONEONE: number;
  26887. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26888. static readonly ALPHA_PREMULTIPLIED: number;
  26889. /**
  26890. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26891. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26892. */
  26893. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26894. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26895. static readonly ALPHA_INTERPOLATE: number;
  26896. /**
  26897. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26898. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26899. */
  26900. static readonly ALPHA_SCREENMODE: number;
  26901. /** Defines that the ressource is not delayed*/
  26902. static readonly DELAYLOADSTATE_NONE: number;
  26903. /** Defines that the ressource was successfully delay loaded */
  26904. static readonly DELAYLOADSTATE_LOADED: number;
  26905. /** Defines that the ressource is currently delay loading */
  26906. static readonly DELAYLOADSTATE_LOADING: number;
  26907. /** Defines that the ressource is delayed and has not started loading */
  26908. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26909. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26910. static readonly NEVER: number;
  26911. /** 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 */
  26912. static readonly ALWAYS: number;
  26913. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26914. static readonly LESS: number;
  26915. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26916. static readonly EQUAL: number;
  26917. /** 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 */
  26918. static readonly LEQUAL: number;
  26919. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26920. static readonly GREATER: number;
  26921. /** 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 */
  26922. static readonly GEQUAL: number;
  26923. /** 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 */
  26924. static readonly NOTEQUAL: number;
  26925. /** Passed to stencilOperation to specify that stencil value must be kept */
  26926. static readonly KEEP: number;
  26927. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26928. static readonly REPLACE: number;
  26929. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26930. static readonly INCR: number;
  26931. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26932. static readonly DECR: number;
  26933. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26934. static readonly INVERT: number;
  26935. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26936. static readonly INCR_WRAP: number;
  26937. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26938. static readonly DECR_WRAP: number;
  26939. /** Texture is not repeating outside of 0..1 UVs */
  26940. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26941. /** Texture is repeating outside of 0..1 UVs */
  26942. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26943. /** Texture is repeating and mirrored */
  26944. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26945. /** ALPHA */
  26946. static readonly TEXTUREFORMAT_ALPHA: number;
  26947. /** LUMINANCE */
  26948. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26949. /** LUMINANCE_ALPHA */
  26950. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26951. /** RGB */
  26952. static readonly TEXTUREFORMAT_RGB: number;
  26953. /** RGBA */
  26954. static readonly TEXTUREFORMAT_RGBA: number;
  26955. /** RED */
  26956. static readonly TEXTUREFORMAT_RED: number;
  26957. /** RED (2nd reference) */
  26958. static readonly TEXTUREFORMAT_R: number;
  26959. /** RG */
  26960. static readonly TEXTUREFORMAT_RG: number;
  26961. /** RED_INTEGER */
  26962. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26963. /** RED_INTEGER (2nd reference) */
  26964. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26965. /** RG_INTEGER */
  26966. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26967. /** RGB_INTEGER */
  26968. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26969. /** RGBA_INTEGER */
  26970. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26971. /** UNSIGNED_BYTE */
  26972. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26973. /** UNSIGNED_BYTE (2nd reference) */
  26974. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26975. /** FLOAT */
  26976. static readonly TEXTURETYPE_FLOAT: number;
  26977. /** HALF_FLOAT */
  26978. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26979. /** BYTE */
  26980. static readonly TEXTURETYPE_BYTE: number;
  26981. /** SHORT */
  26982. static readonly TEXTURETYPE_SHORT: number;
  26983. /** UNSIGNED_SHORT */
  26984. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26985. /** INT */
  26986. static readonly TEXTURETYPE_INT: number;
  26987. /** UNSIGNED_INT */
  26988. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26989. /** UNSIGNED_SHORT_4_4_4_4 */
  26990. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26991. /** UNSIGNED_SHORT_5_5_5_1 */
  26992. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26993. /** UNSIGNED_SHORT_5_6_5 */
  26994. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26995. /** UNSIGNED_INT_2_10_10_10_REV */
  26996. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26997. /** UNSIGNED_INT_24_8 */
  26998. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26999. /** UNSIGNED_INT_10F_11F_11F_REV */
  27000. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27001. /** UNSIGNED_INT_5_9_9_9_REV */
  27002. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27003. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27004. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27005. /** nearest is mag = nearest and min = nearest and mip = linear */
  27006. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27007. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27008. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27009. /** Trilinear is mag = linear and min = linear and mip = linear */
  27010. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27011. /** nearest is mag = nearest and min = nearest and mip = linear */
  27012. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27013. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27014. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27015. /** Trilinear is mag = linear and min = linear and mip = linear */
  27016. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27017. /** mag = nearest and min = nearest and mip = nearest */
  27018. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27019. /** mag = nearest and min = linear and mip = nearest */
  27020. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27021. /** mag = nearest and min = linear and mip = linear */
  27022. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27023. /** mag = nearest and min = linear and mip = none */
  27024. static readonly TEXTURE_NEAREST_LINEAR: number;
  27025. /** mag = nearest and min = nearest and mip = none */
  27026. static readonly TEXTURE_NEAREST_NEAREST: number;
  27027. /** mag = linear and min = nearest and mip = nearest */
  27028. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27029. /** mag = linear and min = nearest and mip = linear */
  27030. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27031. /** mag = linear and min = linear and mip = none */
  27032. static readonly TEXTURE_LINEAR_LINEAR: number;
  27033. /** mag = linear and min = nearest and mip = none */
  27034. static readonly TEXTURE_LINEAR_NEAREST: number;
  27035. /** Explicit coordinates mode */
  27036. static readonly TEXTURE_EXPLICIT_MODE: number;
  27037. /** Spherical coordinates mode */
  27038. static readonly TEXTURE_SPHERICAL_MODE: number;
  27039. /** Planar coordinates mode */
  27040. static readonly TEXTURE_PLANAR_MODE: number;
  27041. /** Cubic coordinates mode */
  27042. static readonly TEXTURE_CUBIC_MODE: number;
  27043. /** Projection coordinates mode */
  27044. static readonly TEXTURE_PROJECTION_MODE: number;
  27045. /** Skybox coordinates mode */
  27046. static readonly TEXTURE_SKYBOX_MODE: number;
  27047. /** Inverse Cubic coordinates mode */
  27048. static readonly TEXTURE_INVCUBIC_MODE: number;
  27049. /** Equirectangular coordinates mode */
  27050. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27051. /** Equirectangular Fixed coordinates mode */
  27052. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27053. /** Equirectangular Fixed Mirrored coordinates mode */
  27054. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27055. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27056. static readonly SCALEMODE_FLOOR: number;
  27057. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27058. static readonly SCALEMODE_NEAREST: number;
  27059. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27060. static readonly SCALEMODE_CEILING: number;
  27061. /**
  27062. * Returns the current version of the framework
  27063. */
  27064. static readonly Version: string;
  27065. /**
  27066. * Returns a string describing the current engine
  27067. */
  27068. readonly description: string;
  27069. /**
  27070. * Gets or sets the epsilon value used by collision engine
  27071. */
  27072. static CollisionsEpsilon: number;
  27073. /**
  27074. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27075. */
  27076. static ShadersRepository: string;
  27077. /**
  27078. * Method called to create the default loading screen.
  27079. * This can be overriden in your own app.
  27080. * @param canvas The rendering canvas element
  27081. * @returns The loading screen
  27082. */
  27083. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27084. /**
  27085. * Method called to create the default rescale post process on each engine.
  27086. */
  27087. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27088. /**
  27089. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27090. */
  27091. forcePOTTextures: boolean;
  27092. /**
  27093. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27094. */
  27095. isFullscreen: boolean;
  27096. /**
  27097. * Gets a boolean indicating if the pointer is currently locked
  27098. */
  27099. isPointerLock: boolean;
  27100. /**
  27101. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27102. */
  27103. cullBackFaces: boolean;
  27104. /**
  27105. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27106. */
  27107. renderEvenInBackground: boolean;
  27108. /**
  27109. * Gets or sets a boolean indicating that cache can be kept between frames
  27110. */
  27111. preventCacheWipeBetweenFrames: boolean;
  27112. /**
  27113. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27114. **/
  27115. enableOfflineSupport: boolean;
  27116. /**
  27117. * 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)
  27118. **/
  27119. disableManifestCheck: boolean;
  27120. /**
  27121. * Gets the list of created scenes
  27122. */
  27123. scenes: Scene[];
  27124. /**
  27125. * Event raised when a new scene is created
  27126. */
  27127. onNewSceneAddedObservable: Observable<Scene>;
  27128. /**
  27129. * Gets the list of created postprocesses
  27130. */
  27131. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27132. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27133. validateShaderPrograms: boolean;
  27134. /**
  27135. * Observable event triggered each time the rendering canvas is resized
  27136. */
  27137. onResizeObservable: Observable<Engine>;
  27138. /**
  27139. * Observable event triggered each time the canvas loses focus
  27140. */
  27141. onCanvasBlurObservable: Observable<Engine>;
  27142. /**
  27143. * Observable event triggered each time the canvas gains focus
  27144. */
  27145. onCanvasFocusObservable: Observable<Engine>;
  27146. /**
  27147. * Observable event triggered each time the canvas receives pointerout event
  27148. */
  27149. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27150. /**
  27151. * Observable event triggered before each texture is initialized
  27152. */
  27153. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27154. private _vrDisplay;
  27155. private _vrSupported;
  27156. private _oldSize;
  27157. private _oldHardwareScaleFactor;
  27158. private _vrExclusivePointerMode;
  27159. private _webVRInitPromise;
  27160. /**
  27161. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27162. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27163. */
  27164. readonly isInVRExclusivePointerMode: boolean;
  27165. /**
  27166. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27167. */
  27168. disableUniformBuffers: boolean;
  27169. /** @hidden */
  27170. _uniformBuffers: UniformBuffer[];
  27171. /**
  27172. * Gets a boolean indicating that the engine supports uniform buffers
  27173. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27174. */
  27175. readonly supportsUniformBuffers: boolean;
  27176. /**
  27177. * Observable raised when the engine begins a new frame
  27178. */
  27179. onBeginFrameObservable: Observable<Engine>;
  27180. /**
  27181. * If set, will be used to request the next animation frame for the render loop
  27182. */
  27183. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27184. /**
  27185. * Observable raised when the engine ends the current frame
  27186. */
  27187. onEndFrameObservable: Observable<Engine>;
  27188. /**
  27189. * Observable raised when the engine is about to compile a shader
  27190. */
  27191. onBeforeShaderCompilationObservable: Observable<Engine>;
  27192. /**
  27193. * Observable raised when the engine has jsut compiled a shader
  27194. */
  27195. onAfterShaderCompilationObservable: Observable<Engine>;
  27196. /** @hidden */
  27197. _gl: WebGLRenderingContext;
  27198. private _renderingCanvas;
  27199. private _windowIsBackground;
  27200. private _webGLVersion;
  27201. /**
  27202. * Gets a boolean indicating that only power of 2 textures are supported
  27203. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27204. */
  27205. readonly needPOTTextures: boolean;
  27206. /** @hidden */
  27207. _badOS: boolean;
  27208. /** @hidden */
  27209. _badDesktopOS: boolean;
  27210. /**
  27211. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27212. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27213. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27214. */
  27215. disableTextureBindingOptimization: boolean;
  27216. /**
  27217. * Gets the audio engine
  27218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27219. * @ignorenaming
  27220. */
  27221. static audioEngine: IAudioEngine;
  27222. /**
  27223. * Default AudioEngine factory responsible of creating the Audio Engine.
  27224. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27225. */
  27226. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27227. /**
  27228. * Default offline support factory responsible of creating a tool used to store data locally.
  27229. * By default, this will create a Database object if the workload has been embedded.
  27230. */
  27231. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27232. private _onFocus;
  27233. private _onBlur;
  27234. private _onCanvasPointerOut;
  27235. private _onCanvasBlur;
  27236. private _onCanvasFocus;
  27237. private _onFullscreenChange;
  27238. private _onPointerLockChange;
  27239. private _onVRDisplayPointerRestricted;
  27240. private _onVRDisplayPointerUnrestricted;
  27241. private _onVrDisplayConnect;
  27242. private _onVrDisplayDisconnect;
  27243. private _onVrDisplayPresentChange;
  27244. /**
  27245. * Observable signaled when VR display mode changes
  27246. */
  27247. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27248. /**
  27249. * Observable signaled when VR request present is complete
  27250. */
  27251. onVRRequestPresentComplete: Observable<boolean>;
  27252. /**
  27253. * Observable signaled when VR request present starts
  27254. */
  27255. onVRRequestPresentStart: Observable<Engine>;
  27256. private _hardwareScalingLevel;
  27257. /** @hidden */
  27258. protected _caps: EngineCapabilities;
  27259. private _pointerLockRequested;
  27260. private _isStencilEnable;
  27261. private _colorWrite;
  27262. private _loadingScreen;
  27263. /** @hidden */
  27264. _drawCalls: PerfCounter;
  27265. /** @hidden */
  27266. _textureCollisions: PerfCounter;
  27267. private _glVersion;
  27268. private _glRenderer;
  27269. private _glVendor;
  27270. private _videoTextureSupported;
  27271. private _renderingQueueLaunched;
  27272. private _activeRenderLoops;
  27273. private _deterministicLockstep;
  27274. private _lockstepMaxSteps;
  27275. /**
  27276. * Observable signaled when a context lost event is raised
  27277. */
  27278. onContextLostObservable: Observable<Engine>;
  27279. /**
  27280. * Observable signaled when a context restored event is raised
  27281. */
  27282. onContextRestoredObservable: Observable<Engine>;
  27283. private _onContextLost;
  27284. private _onContextRestored;
  27285. private _contextWasLost;
  27286. private _doNotHandleContextLost;
  27287. /**
  27288. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27289. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27290. */
  27291. doNotHandleContextLost: boolean;
  27292. private _performanceMonitor;
  27293. private _fps;
  27294. private _deltaTime;
  27295. /**
  27296. * Turn this value on if you want to pause FPS computation when in background
  27297. */
  27298. disablePerformanceMonitorInBackground: boolean;
  27299. /**
  27300. * Gets the performance monitor attached to this engine
  27301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27302. */
  27303. readonly performanceMonitor: PerformanceMonitor;
  27304. /** @hidden */
  27305. protected _depthCullingState: _DepthCullingState;
  27306. /** @hidden */
  27307. protected _stencilState: _StencilState;
  27308. /** @hidden */
  27309. protected _alphaState: _AlphaState;
  27310. /** @hidden */
  27311. protected _alphaMode: number;
  27312. protected _internalTexturesCache: InternalTexture[];
  27313. /** @hidden */
  27314. protected _activeChannel: number;
  27315. private _currentTextureChannel;
  27316. /** @hidden */
  27317. protected _boundTexturesCache: {
  27318. [key: string]: Nullable<InternalTexture>;
  27319. };
  27320. /** @hidden */
  27321. protected _currentEffect: Nullable<Effect>;
  27322. /** @hidden */
  27323. protected _currentProgram: Nullable<WebGLProgram>;
  27324. private _compiledEffects;
  27325. private _vertexAttribArraysEnabled;
  27326. /** @hidden */
  27327. protected _cachedViewport: Nullable<Viewport>;
  27328. private _cachedVertexArrayObject;
  27329. /** @hidden */
  27330. protected _cachedVertexBuffers: any;
  27331. /** @hidden */
  27332. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27333. /** @hidden */
  27334. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27335. /** @hidden */
  27336. protected _currentRenderTarget: Nullable<InternalTexture>;
  27337. private _uintIndicesCurrentlySet;
  27338. private _currentBoundBuffer;
  27339. /** @hidden */
  27340. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27341. private _currentBufferPointers;
  27342. private _currentInstanceLocations;
  27343. private _currentInstanceBuffers;
  27344. private _textureUnits;
  27345. private _firstBoundInternalTextureTracker;
  27346. private _lastBoundInternalTextureTracker;
  27347. private _workingCanvas;
  27348. private _workingContext;
  27349. private _rescalePostProcess;
  27350. private _dummyFramebuffer;
  27351. private _externalData;
  27352. private _bindedRenderFunction;
  27353. private _vaoRecordInProgress;
  27354. private _mustWipeVertexAttributes;
  27355. private _emptyTexture;
  27356. private _emptyCubeTexture;
  27357. private _emptyTexture3D;
  27358. /** @hidden */
  27359. _frameHandler: number;
  27360. private _nextFreeTextureSlots;
  27361. private _maxSimultaneousTextures;
  27362. private _activeRequests;
  27363. private _texturesSupported;
  27364. private _textureFormatInUse;
  27365. /**
  27366. * Gets the list of texture formats supported
  27367. */
  27368. readonly texturesSupported: Array<string>;
  27369. /**
  27370. * Gets the list of texture formats in use
  27371. */
  27372. readonly textureFormatInUse: Nullable<string>;
  27373. /**
  27374. * Gets the current viewport
  27375. */
  27376. readonly currentViewport: Nullable<Viewport>;
  27377. /**
  27378. * Gets the default empty texture
  27379. */
  27380. readonly emptyTexture: InternalTexture;
  27381. /**
  27382. * Gets the default empty 3D texture
  27383. */
  27384. readonly emptyTexture3D: InternalTexture;
  27385. /**
  27386. * Gets the default empty cube texture
  27387. */
  27388. readonly emptyCubeTexture: InternalTexture;
  27389. /**
  27390. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27391. */
  27392. readonly premultipliedAlpha: boolean;
  27393. /**
  27394. * Creates a new engine
  27395. * @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
  27396. * @param antialias defines enable antialiasing (default: false)
  27397. * @param options defines further options to be sent to the getContext() function
  27398. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27399. */
  27400. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27401. private _disableTouchAction;
  27402. private _rebuildInternalTextures;
  27403. private _rebuildEffects;
  27404. /**
  27405. * Gets a boolean indicating if all created effects are ready
  27406. * @returns true if all effects are ready
  27407. */
  27408. areAllEffectsReady(): boolean;
  27409. private _rebuildBuffers;
  27410. private _initGLContext;
  27411. /**
  27412. * Gets version of the current webGL context
  27413. */
  27414. readonly webGLVersion: number;
  27415. /**
  27416. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27417. */
  27418. readonly isStencilEnable: boolean;
  27419. private _prepareWorkingCanvas;
  27420. /**
  27421. * Reset the texture cache to empty state
  27422. */
  27423. resetTextureCache(): void;
  27424. /**
  27425. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27427. * @returns true if engine is in deterministic lock step mode
  27428. */
  27429. isDeterministicLockStep(): boolean;
  27430. /**
  27431. * Gets the max steps when engine is running in deterministic lock step
  27432. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27433. * @returns the max steps
  27434. */
  27435. getLockstepMaxSteps(): number;
  27436. /**
  27437. * Gets an object containing information about the current webGL context
  27438. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27439. */
  27440. getGlInfo(): {
  27441. vendor: string;
  27442. renderer: string;
  27443. version: string;
  27444. };
  27445. /**
  27446. * Gets current aspect ratio
  27447. * @param camera defines the camera to use to get the aspect ratio
  27448. * @param useScreen defines if screen size must be used (or the current render target if any)
  27449. * @returns a number defining the aspect ratio
  27450. */
  27451. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27452. /**
  27453. * Gets current screen aspect ratio
  27454. * @returns a number defining the aspect ratio
  27455. */
  27456. getScreenAspectRatio(): number;
  27457. /**
  27458. * Gets the current render width
  27459. * @param useScreen defines if screen size must be used (or the current render target if any)
  27460. * @returns a number defining the current render width
  27461. */
  27462. getRenderWidth(useScreen?: boolean): number;
  27463. /**
  27464. * Gets the current render height
  27465. * @param useScreen defines if screen size must be used (or the current render target if any)
  27466. * @returns a number defining the current render height
  27467. */
  27468. getRenderHeight(useScreen?: boolean): number;
  27469. /**
  27470. * Gets the HTML canvas attached with the current webGL context
  27471. * @returns a HTML canvas
  27472. */
  27473. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27474. /**
  27475. * Gets the client rect of the HTML canvas attached with the current webGL context
  27476. * @returns a client rectanglee
  27477. */
  27478. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27479. /**
  27480. * Defines the hardware scaling level.
  27481. * By default the hardware scaling level is computed from the window device ratio.
  27482. * 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.
  27483. * @param level defines the level to use
  27484. */
  27485. setHardwareScalingLevel(level: number): void;
  27486. /**
  27487. * Gets the current hardware scaling level.
  27488. * By default the hardware scaling level is computed from the window device ratio.
  27489. * 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.
  27490. * @returns a number indicating the current hardware scaling level
  27491. */
  27492. getHardwareScalingLevel(): number;
  27493. /**
  27494. * Gets the list of loaded textures
  27495. * @returns an array containing all loaded textures
  27496. */
  27497. getLoadedTexturesCache(): InternalTexture[];
  27498. /**
  27499. * Gets the object containing all engine capabilities
  27500. * @returns the EngineCapabilities object
  27501. */
  27502. getCaps(): EngineCapabilities;
  27503. /**
  27504. * Gets the current depth function
  27505. * @returns a number defining the depth function
  27506. */
  27507. getDepthFunction(): Nullable<number>;
  27508. /**
  27509. * Sets the current depth function
  27510. * @param depthFunc defines the function to use
  27511. */
  27512. setDepthFunction(depthFunc: number): void;
  27513. /**
  27514. * Sets the current depth function to GREATER
  27515. */
  27516. setDepthFunctionToGreater(): void;
  27517. /**
  27518. * Sets the current depth function to GEQUAL
  27519. */
  27520. setDepthFunctionToGreaterOrEqual(): void;
  27521. /**
  27522. * Sets the current depth function to LESS
  27523. */
  27524. setDepthFunctionToLess(): void;
  27525. /**
  27526. * Sets the current depth function to LEQUAL
  27527. */
  27528. setDepthFunctionToLessOrEqual(): void;
  27529. /**
  27530. * Gets a boolean indicating if stencil buffer is enabled
  27531. * @returns the current stencil buffer state
  27532. */
  27533. getStencilBuffer(): boolean;
  27534. /**
  27535. * Enable or disable the stencil buffer
  27536. * @param enable defines if the stencil buffer must be enabled or disabled
  27537. */
  27538. setStencilBuffer(enable: boolean): void;
  27539. /**
  27540. * Gets the current stencil mask
  27541. * @returns a number defining the new stencil mask to use
  27542. */
  27543. getStencilMask(): number;
  27544. /**
  27545. * Sets the current stencil mask
  27546. * @param mask defines the new stencil mask to use
  27547. */
  27548. setStencilMask(mask: number): void;
  27549. /**
  27550. * Gets the current stencil function
  27551. * @returns a number defining the stencil function to use
  27552. */
  27553. getStencilFunction(): number;
  27554. /**
  27555. * Gets the current stencil reference value
  27556. * @returns a number defining the stencil reference value to use
  27557. */
  27558. getStencilFunctionReference(): number;
  27559. /**
  27560. * Gets the current stencil mask
  27561. * @returns a number defining the stencil mask to use
  27562. */
  27563. getStencilFunctionMask(): number;
  27564. /**
  27565. * Sets the current stencil function
  27566. * @param stencilFunc defines the new stencil function to use
  27567. */
  27568. setStencilFunction(stencilFunc: number): void;
  27569. /**
  27570. * Sets the current stencil reference
  27571. * @param reference defines the new stencil reference to use
  27572. */
  27573. setStencilFunctionReference(reference: number): void;
  27574. /**
  27575. * Sets the current stencil mask
  27576. * @param mask defines the new stencil mask to use
  27577. */
  27578. setStencilFunctionMask(mask: number): void;
  27579. /**
  27580. * Gets the current stencil operation when stencil fails
  27581. * @returns a number defining stencil operation to use when stencil fails
  27582. */
  27583. getStencilOperationFail(): number;
  27584. /**
  27585. * Gets the current stencil operation when depth fails
  27586. * @returns a number defining stencil operation to use when depth fails
  27587. */
  27588. getStencilOperationDepthFail(): number;
  27589. /**
  27590. * Gets the current stencil operation when stencil passes
  27591. * @returns a number defining stencil operation to use when stencil passes
  27592. */
  27593. getStencilOperationPass(): number;
  27594. /**
  27595. * Sets the stencil operation to use when stencil fails
  27596. * @param operation defines the stencil operation to use when stencil fails
  27597. */
  27598. setStencilOperationFail(operation: number): void;
  27599. /**
  27600. * Sets the stencil operation to use when depth fails
  27601. * @param operation defines the stencil operation to use when depth fails
  27602. */
  27603. setStencilOperationDepthFail(operation: number): void;
  27604. /**
  27605. * Sets the stencil operation to use when stencil passes
  27606. * @param operation defines the stencil operation to use when stencil passes
  27607. */
  27608. setStencilOperationPass(operation: number): void;
  27609. /**
  27610. * Sets a boolean indicating if the dithering state is enabled or disabled
  27611. * @param value defines the dithering state
  27612. */
  27613. setDitheringState(value: boolean): void;
  27614. /**
  27615. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27616. * @param value defines the rasterizer state
  27617. */
  27618. setRasterizerState(value: boolean): void;
  27619. /**
  27620. * stop executing a render loop function and remove it from the execution array
  27621. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27622. */
  27623. stopRenderLoop(renderFunction?: () => void): void;
  27624. /** @hidden */
  27625. _renderLoop(): void;
  27626. /**
  27627. * Register and execute a render loop. The engine can have more than one render function
  27628. * @param renderFunction defines the function to continuously execute
  27629. */
  27630. runRenderLoop(renderFunction: () => void): void;
  27631. /**
  27632. * Toggle full screen mode
  27633. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27634. */
  27635. switchFullscreen(requestPointerLock: boolean): void;
  27636. /**
  27637. * Enters full screen mode
  27638. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27639. */
  27640. enterFullscreen(requestPointerLock: boolean): void;
  27641. /**
  27642. * Exits full screen mode
  27643. */
  27644. exitFullscreen(): void;
  27645. /**
  27646. * Clear the current render buffer or the current render target (if any is set up)
  27647. * @param color defines the color to use
  27648. * @param backBuffer defines if the back buffer must be cleared
  27649. * @param depth defines if the depth buffer must be cleared
  27650. * @param stencil defines if the stencil buffer must be cleared
  27651. */
  27652. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27653. /**
  27654. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27655. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27656. * @param y defines the y-coordinate of the corner of the clear rectangle
  27657. * @param width defines the width of the clear rectangle
  27658. * @param height defines the height of the clear rectangle
  27659. * @param clearColor defines the clear color
  27660. */
  27661. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27662. /**
  27663. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27664. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27665. * @param y defines the y-coordinate of the corner of the clear rectangle
  27666. * @param width defines the width of the clear rectangle
  27667. * @param height defines the height of the clear rectangle
  27668. */
  27669. enableScissor(x: number, y: number, width: number, height: number): void;
  27670. /**
  27671. * Disable previously set scissor test rectangle
  27672. */
  27673. disableScissor(): void;
  27674. private _viewportCached;
  27675. /** @hidden */
  27676. _viewport(x: number, y: number, width: number, height: number): void;
  27677. /**
  27678. * Set the WebGL's viewport
  27679. * @param viewport defines the viewport element to be used
  27680. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27681. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27682. */
  27683. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27684. /**
  27685. * Directly set the WebGL Viewport
  27686. * @param x defines the x coordinate of the viewport (in screen space)
  27687. * @param y defines the y coordinate of the viewport (in screen space)
  27688. * @param width defines the width of the viewport (in screen space)
  27689. * @param height defines the height of the viewport (in screen space)
  27690. * @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
  27691. */
  27692. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27693. /**
  27694. * Begin a new frame
  27695. */
  27696. beginFrame(): void;
  27697. /**
  27698. * Enf the current frame
  27699. */
  27700. endFrame(): void;
  27701. /**
  27702. * Resize the view according to the canvas' size
  27703. */
  27704. resize(): void;
  27705. /**
  27706. * Force a specific size of the canvas
  27707. * @param width defines the new canvas' width
  27708. * @param height defines the new canvas' height
  27709. */
  27710. setSize(width: number, height: number): void;
  27711. /**
  27712. * Gets a boolean indicating if a webVR device was detected
  27713. * @returns true if a webVR device was detected
  27714. */
  27715. isVRDevicePresent(): boolean;
  27716. /**
  27717. * Gets the current webVR device
  27718. * @returns the current webVR device (or null)
  27719. */
  27720. getVRDevice(): any;
  27721. /**
  27722. * Initializes a webVR display and starts listening to display change events
  27723. * The onVRDisplayChangedObservable will be notified upon these changes
  27724. * @returns The onVRDisplayChangedObservable
  27725. */
  27726. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27727. /**
  27728. * Initializes a webVR display and starts listening to display change events
  27729. * The onVRDisplayChangedObservable will be notified upon these changes
  27730. * @returns A promise containing a VRDisplay and if vr is supported
  27731. */
  27732. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27733. /**
  27734. * Call this function to switch to webVR mode
  27735. * Will do nothing if webVR is not supported or if there is no webVR device
  27736. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27737. */
  27738. enableVR(): void;
  27739. /**
  27740. * Call this function to leave webVR mode
  27741. * Will do nothing if webVR is not supported or if there is no webVR device
  27742. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27743. */
  27744. disableVR(): void;
  27745. private _onVRFullScreenTriggered;
  27746. private _getVRDisplaysAsync;
  27747. /**
  27748. * Binds the frame buffer to the specified texture.
  27749. * @param texture The texture to render to or null for the default canvas
  27750. * @param faceIndex The face of the texture to render to in case of cube texture
  27751. * @param requiredWidth The width of the target to render to
  27752. * @param requiredHeight The height of the target to render to
  27753. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27754. * @param depthStencilTexture The depth stencil texture to use to render
  27755. * @param lodLevel defines le lod level to bind to the frame buffer
  27756. */
  27757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27758. private bindUnboundFramebuffer;
  27759. /**
  27760. * Unbind the current render target texture from the webGL context
  27761. * @param texture defines the render target texture to unbind
  27762. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27763. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27764. */
  27765. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27766. /**
  27767. * Unbind a list of render target textures from the webGL context
  27768. * This is used only when drawBuffer extension or webGL2 are active
  27769. * @param textures defines the render target textures to unbind
  27770. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27771. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27772. */
  27773. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27774. /**
  27775. * Force the mipmap generation for the given render target texture
  27776. * @param texture defines the render target texture to use
  27777. */
  27778. generateMipMapsForCubemap(texture: InternalTexture): void;
  27779. /**
  27780. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27781. */
  27782. flushFramebuffer(): void;
  27783. /**
  27784. * Unbind the current render target and bind the default framebuffer
  27785. */
  27786. restoreDefaultFramebuffer(): void;
  27787. /**
  27788. * Create an uniform buffer
  27789. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27790. * @param elements defines the content of the uniform buffer
  27791. * @returns the webGL uniform buffer
  27792. */
  27793. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27794. /**
  27795. * Create a dynamic uniform buffer
  27796. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27797. * @param elements defines the content of the uniform buffer
  27798. * @returns the webGL uniform buffer
  27799. */
  27800. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27801. /**
  27802. * Update an existing uniform buffer
  27803. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27804. * @param uniformBuffer defines the target uniform buffer
  27805. * @param elements defines the content to update
  27806. * @param offset defines the offset in the uniform buffer where update should start
  27807. * @param count defines the size of the data to update
  27808. */
  27809. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27810. private _resetVertexBufferBinding;
  27811. /**
  27812. * Creates a vertex buffer
  27813. * @param data the data for the vertex buffer
  27814. * @returns the new WebGL static buffer
  27815. */
  27816. createVertexBuffer(data: DataArray): WebGLBuffer;
  27817. /**
  27818. * Creates a dynamic vertex buffer
  27819. * @param data the data for the dynamic vertex buffer
  27820. * @returns the new WebGL dynamic buffer
  27821. */
  27822. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27823. /**
  27824. * Update a dynamic index buffer
  27825. * @param indexBuffer defines the target index buffer
  27826. * @param indices defines the data to update
  27827. * @param offset defines the offset in the target index buffer where update should start
  27828. */
  27829. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27830. /**
  27831. * Updates a dynamic vertex buffer.
  27832. * @param vertexBuffer the vertex buffer to update
  27833. * @param data the data used to update the vertex buffer
  27834. * @param byteOffset the byte offset of the data
  27835. * @param byteLength the byte length of the data
  27836. */
  27837. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27838. private _resetIndexBufferBinding;
  27839. /**
  27840. * Creates a new index buffer
  27841. * @param indices defines the content of the index buffer
  27842. * @param updatable defines if the index buffer must be updatable
  27843. * @returns a new webGL buffer
  27844. */
  27845. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27846. /**
  27847. * Bind a webGL buffer to the webGL context
  27848. * @param buffer defines the buffer to bind
  27849. */
  27850. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27851. /**
  27852. * Bind an uniform buffer to the current webGL context
  27853. * @param buffer defines the buffer to bind
  27854. */
  27855. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27856. /**
  27857. * Bind a buffer to the current webGL context at a given location
  27858. * @param buffer defines the buffer to bind
  27859. * @param location defines the index where to bind the buffer
  27860. */
  27861. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27862. /**
  27863. * Bind a specific block at a given index in a specific shader program
  27864. * @param shaderProgram defines the shader program
  27865. * @param blockName defines the block name
  27866. * @param index defines the index where to bind the block
  27867. */
  27868. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27869. private bindIndexBuffer;
  27870. private bindBuffer;
  27871. /**
  27872. * update the bound buffer with the given data
  27873. * @param data defines the data to update
  27874. */
  27875. updateArrayBuffer(data: Float32Array): void;
  27876. private _vertexAttribPointer;
  27877. private _bindIndexBufferWithCache;
  27878. private _bindVertexBuffersAttributes;
  27879. /**
  27880. * Records a vertex array object
  27881. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27882. * @param vertexBuffers defines the list of vertex buffers to store
  27883. * @param indexBuffer defines the index buffer to store
  27884. * @param effect defines the effect to store
  27885. * @returns the new vertex array object
  27886. */
  27887. recordVertexArrayObject(vertexBuffers: {
  27888. [key: string]: VertexBuffer;
  27889. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27890. /**
  27891. * Bind a specific vertex array object
  27892. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27893. * @param vertexArrayObject defines the vertex array object to bind
  27894. * @param indexBuffer defines the index buffer to bind
  27895. */
  27896. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27897. /**
  27898. * Bind webGl buffers directly to the webGL context
  27899. * @param vertexBuffer defines the vertex buffer to bind
  27900. * @param indexBuffer defines the index buffer to bind
  27901. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27902. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27903. * @param effect defines the effect associated with the vertex buffer
  27904. */
  27905. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27906. private _unbindVertexArrayObject;
  27907. /**
  27908. * Bind a list of vertex buffers to the webGL context
  27909. * @param vertexBuffers defines the list of vertex buffers to bind
  27910. * @param indexBuffer defines the index buffer to bind
  27911. * @param effect defines the effect associated with the vertex buffers
  27912. */
  27913. bindBuffers(vertexBuffers: {
  27914. [key: string]: Nullable<VertexBuffer>;
  27915. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27916. /**
  27917. * Unbind all instance attributes
  27918. */
  27919. unbindInstanceAttributes(): void;
  27920. /**
  27921. * Release and free the memory of a vertex array object
  27922. * @param vao defines the vertex array object to delete
  27923. */
  27924. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27925. /** @hidden */
  27926. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27927. /**
  27928. * Creates a webGL buffer to use with instanciation
  27929. * @param capacity defines the size of the buffer
  27930. * @returns the webGL buffer
  27931. */
  27932. createInstancesBuffer(capacity: number): WebGLBuffer;
  27933. /**
  27934. * Delete a webGL buffer used with instanciation
  27935. * @param buffer defines the webGL buffer to delete
  27936. */
  27937. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27938. /**
  27939. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27940. * @param instancesBuffer defines the webGL buffer to update and bind
  27941. * @param data defines the data to store in the buffer
  27942. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27943. */
  27944. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27945. /**
  27946. * Apply all cached states (depth, culling, stencil and alpha)
  27947. */
  27948. applyStates(): void;
  27949. /**
  27950. * Send a draw order
  27951. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27952. * @param indexStart defines the starting index
  27953. * @param indexCount defines the number of index to draw
  27954. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27955. */
  27956. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27957. /**
  27958. * Draw a list of points
  27959. * @param verticesStart defines the index of first vertex to draw
  27960. * @param verticesCount defines the count of vertices to draw
  27961. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27962. */
  27963. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27964. /**
  27965. * Draw a list of unindexed primitives
  27966. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27967. * @param verticesStart defines the index of first vertex to draw
  27968. * @param verticesCount defines the count of vertices to draw
  27969. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27970. */
  27971. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27972. /**
  27973. * Draw a list of indexed primitives
  27974. * @param fillMode defines the primitive to use
  27975. * @param indexStart defines the starting index
  27976. * @param indexCount defines the number of index to draw
  27977. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27978. */
  27979. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27980. /**
  27981. * Draw a list of unindexed primitives
  27982. * @param fillMode defines the primitive to use
  27983. * @param verticesStart defines the index of first vertex to draw
  27984. * @param verticesCount defines the count of vertices to draw
  27985. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27986. */
  27987. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27988. private _drawMode;
  27989. /** @hidden */
  27990. _releaseEffect(effect: Effect): void;
  27991. /** @hidden */
  27992. _deleteProgram(program: WebGLProgram): void;
  27993. /**
  27994. * Create a new effect (used to store vertex/fragment shaders)
  27995. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27996. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27997. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27998. * @param samplers defines an array of string used to represent textures
  27999. * @param defines defines the string containing the defines to use to compile the shaders
  28000. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28001. * @param onCompiled defines a function to call when the effect creation is successful
  28002. * @param onError defines a function to call when the effect creation has failed
  28003. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28004. * @returns the new Effect
  28005. */
  28006. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28007. private _compileShader;
  28008. private _compileRawShader;
  28009. /**
  28010. * Directly creates a webGL program
  28011. * @param vertexCode defines the vertex shader code to use
  28012. * @param fragmentCode defines the fragment shader code to use
  28013. * @param context defines the webGL context to use (if not set, the current one will be used)
  28014. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28015. * @returns the new webGL program
  28016. */
  28017. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28018. /**
  28019. * Creates a webGL program
  28020. * @param vertexCode defines the vertex shader code to use
  28021. * @param fragmentCode defines the fragment shader code to use
  28022. * @param defines defines the string containing the defines to use to compile the shaders
  28023. * @param context defines the webGL context to use (if not set, the current one will be used)
  28024. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28025. * @returns the new webGL program
  28026. */
  28027. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28028. private _createShaderProgram;
  28029. private _finalizeProgram;
  28030. /** @hidden */
  28031. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28032. /** @hidden */
  28033. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28034. /**
  28035. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28036. * @param shaderProgram defines the webGL program to use
  28037. * @param uniformsNames defines the list of uniform names
  28038. * @returns an array of webGL uniform locations
  28039. */
  28040. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28041. /**
  28042. * Gets the lsit of active attributes for a given webGL program
  28043. * @param shaderProgram defines the webGL program to use
  28044. * @param attributesNames defines the list of attribute names to get
  28045. * @returns an array of indices indicating the offset of each attribute
  28046. */
  28047. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28048. /**
  28049. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28050. * @param effect defines the effect to activate
  28051. */
  28052. enableEffect(effect: Nullable<Effect>): void;
  28053. /**
  28054. * Set the value of an uniform to an array of int32
  28055. * @param uniform defines the webGL uniform location where to store the value
  28056. * @param array defines the array of int32 to store
  28057. */
  28058. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28059. /**
  28060. * Set the value of an uniform to an array of int32 (stored as vec2)
  28061. * @param uniform defines the webGL uniform location where to store the value
  28062. * @param array defines the array of int32 to store
  28063. */
  28064. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28065. /**
  28066. * Set the value of an uniform to an array of int32 (stored as vec3)
  28067. * @param uniform defines the webGL uniform location where to store the value
  28068. * @param array defines the array of int32 to store
  28069. */
  28070. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28071. /**
  28072. * Set the value of an uniform to an array of int32 (stored as vec4)
  28073. * @param uniform defines the webGL uniform location where to store the value
  28074. * @param array defines the array of int32 to store
  28075. */
  28076. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28077. /**
  28078. * Set the value of an uniform to an array of float32
  28079. * @param uniform defines the webGL uniform location where to store the value
  28080. * @param array defines the array of float32 to store
  28081. */
  28082. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28083. /**
  28084. * Set the value of an uniform to an array of float32 (stored as vec2)
  28085. * @param uniform defines the webGL uniform location where to store the value
  28086. * @param array defines the array of float32 to store
  28087. */
  28088. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28089. /**
  28090. * Set the value of an uniform to an array of float32 (stored as vec3)
  28091. * @param uniform defines the webGL uniform location where to store the value
  28092. * @param array defines the array of float32 to store
  28093. */
  28094. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28095. /**
  28096. * Set the value of an uniform to an array of float32 (stored as vec4)
  28097. * @param uniform defines the webGL uniform location where to store the value
  28098. * @param array defines the array of float32 to store
  28099. */
  28100. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28101. /**
  28102. * Set the value of an uniform to an array of number
  28103. * @param uniform defines the webGL uniform location where to store the value
  28104. * @param array defines the array of number to store
  28105. */
  28106. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28107. /**
  28108. * Set the value of an uniform to an array of number (stored as vec2)
  28109. * @param uniform defines the webGL uniform location where to store the value
  28110. * @param array defines the array of number to store
  28111. */
  28112. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28113. /**
  28114. * Set the value of an uniform to an array of number (stored as vec3)
  28115. * @param uniform defines the webGL uniform location where to store the value
  28116. * @param array defines the array of number to store
  28117. */
  28118. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28119. /**
  28120. * Set the value of an uniform to an array of number (stored as vec4)
  28121. * @param uniform defines the webGL uniform location where to store the value
  28122. * @param array defines the array of number to store
  28123. */
  28124. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28125. /**
  28126. * Set the value of an uniform to an array of float32 (stored as matrices)
  28127. * @param uniform defines the webGL uniform location where to store the value
  28128. * @param matrices defines the array of float32 to store
  28129. */
  28130. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28131. /**
  28132. * Set the value of an uniform to a matrix
  28133. * @param uniform defines the webGL uniform location where to store the value
  28134. * @param matrix defines the matrix to store
  28135. */
  28136. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28137. /**
  28138. * Set the value of an uniform to a matrix (3x3)
  28139. * @param uniform defines the webGL uniform location where to store the value
  28140. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28141. */
  28142. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28143. /**
  28144. * Set the value of an uniform to a matrix (2x2)
  28145. * @param uniform defines the webGL uniform location where to store the value
  28146. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28147. */
  28148. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28149. /**
  28150. * Set the value of an uniform to a number (int)
  28151. * @param uniform defines the webGL uniform location where to store the value
  28152. * @param value defines the int number to store
  28153. */
  28154. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28155. /**
  28156. * Set the value of an uniform to a number (float)
  28157. * @param uniform defines the webGL uniform location where to store the value
  28158. * @param value defines the float number to store
  28159. */
  28160. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28161. /**
  28162. * Set the value of an uniform to a vec2
  28163. * @param uniform defines the webGL uniform location where to store the value
  28164. * @param x defines the 1st component of the value
  28165. * @param y defines the 2nd component of the value
  28166. */
  28167. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28168. /**
  28169. * Set the value of an uniform to a vec3
  28170. * @param uniform defines the webGL uniform location where to store the value
  28171. * @param x defines the 1st component of the value
  28172. * @param y defines the 2nd component of the value
  28173. * @param z defines the 3rd component of the value
  28174. */
  28175. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28176. /**
  28177. * Set the value of an uniform to a boolean
  28178. * @param uniform defines the webGL uniform location where to store the value
  28179. * @param bool defines the boolean to store
  28180. */
  28181. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28182. /**
  28183. * Set the value of an uniform to a vec4
  28184. * @param uniform defines the webGL uniform location where to store the value
  28185. * @param x defines the 1st component of the value
  28186. * @param y defines the 2nd component of the value
  28187. * @param z defines the 3rd component of the value
  28188. * @param w defines the 4th component of the value
  28189. */
  28190. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28191. /**
  28192. * Set the value of an uniform to a Color3
  28193. * @param uniform defines the webGL uniform location where to store the value
  28194. * @param color3 defines the color to store
  28195. */
  28196. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28197. /**
  28198. * Set the value of an uniform to a Color3 and an alpha value
  28199. * @param uniform defines the webGL uniform location where to store the value
  28200. * @param color3 defines the color to store
  28201. * @param alpha defines the alpha component to store
  28202. */
  28203. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28204. /**
  28205. * Sets a Color4 on a uniform variable
  28206. * @param uniform defines the uniform location
  28207. * @param color4 defines the value to be set
  28208. */
  28209. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28210. /**
  28211. * Set various states to the webGL context
  28212. * @param culling defines backface culling state
  28213. * @param zOffset defines the value to apply to zOffset (0 by default)
  28214. * @param force defines if states must be applied even if cache is up to date
  28215. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28216. */
  28217. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28218. /**
  28219. * Set the z offset to apply to current rendering
  28220. * @param value defines the offset to apply
  28221. */
  28222. setZOffset(value: number): void;
  28223. /**
  28224. * Gets the current value of the zOffset
  28225. * @returns the current zOffset state
  28226. */
  28227. getZOffset(): number;
  28228. /**
  28229. * Enable or disable depth buffering
  28230. * @param enable defines the state to set
  28231. */
  28232. setDepthBuffer(enable: boolean): void;
  28233. /**
  28234. * Gets a boolean indicating if depth writing is enabled
  28235. * @returns the current depth writing state
  28236. */
  28237. getDepthWrite(): boolean;
  28238. /**
  28239. * Enable or disable depth writing
  28240. * @param enable defines the state to set
  28241. */
  28242. setDepthWrite(enable: boolean): void;
  28243. /**
  28244. * Enable or disable color writing
  28245. * @param enable defines the state to set
  28246. */
  28247. setColorWrite(enable: boolean): void;
  28248. /**
  28249. * Gets a boolean indicating if color writing is enabled
  28250. * @returns the current color writing state
  28251. */
  28252. getColorWrite(): boolean;
  28253. /**
  28254. * Sets alpha constants used by some alpha blending modes
  28255. * @param r defines the red component
  28256. * @param g defines the green component
  28257. * @param b defines the blue component
  28258. * @param a defines the alpha component
  28259. */
  28260. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28261. /**
  28262. * Sets the current alpha mode
  28263. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28264. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28265. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28266. */
  28267. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28268. /**
  28269. * Gets the current alpha mode
  28270. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28271. * @returns the current alpha mode
  28272. */
  28273. getAlphaMode(): number;
  28274. /**
  28275. * Clears the list of texture accessible through engine.
  28276. * This can help preventing texture load conflict due to name collision.
  28277. */
  28278. clearInternalTexturesCache(): void;
  28279. /**
  28280. * Force the entire cache to be cleared
  28281. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28282. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28283. */
  28284. wipeCaches(bruteForce?: boolean): void;
  28285. /**
  28286. * Set the compressed texture format to use, based on the formats you have, and the formats
  28287. * supported by the hardware / browser.
  28288. *
  28289. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28290. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28291. * to API arguments needed to compressed textures. This puts the burden on the container
  28292. * generator to house the arcane code for determining these for current & future formats.
  28293. *
  28294. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28295. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28296. *
  28297. * Note: The result of this call is not taken into account when a texture is base64.
  28298. *
  28299. * @param formatsAvailable defines the list of those format families you have created
  28300. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28301. *
  28302. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28303. * @returns The extension selected.
  28304. */
  28305. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28306. private _getSamplingParameters;
  28307. private _partialLoadImg;
  28308. private _cascadeLoadImgs;
  28309. /** @hidden */
  28310. _createTexture(): WebGLTexture;
  28311. /**
  28312. * Usually called from Texture.ts.
  28313. * Passed information to create a WebGLTexture
  28314. * @param urlArg defines a value which contains one of the following:
  28315. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28316. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28317. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28318. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28319. * @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)
  28320. * @param scene needed for loading to the correct scene
  28321. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28322. * @param onLoad optional callback to be called upon successful completion
  28323. * @param onError optional callback to be called upon failure
  28324. * @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
  28325. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28326. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28327. * @param forcedExtension defines the extension to use to pick the right loader
  28328. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28329. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28330. */
  28331. 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;
  28332. private _rescaleTexture;
  28333. /**
  28334. * Update a raw texture
  28335. * @param texture defines the texture to update
  28336. * @param data defines the data to store in the texture
  28337. * @param format defines the format of the data
  28338. * @param invertY defines if data must be stored with Y axis inverted
  28339. * @param compression defines the compression used (null by default)
  28340. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28341. */
  28342. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28343. /**
  28344. * Creates a raw texture
  28345. * @param data defines the data to store in the texture
  28346. * @param width defines the width of the texture
  28347. * @param height defines the height of the texture
  28348. * @param format defines the format of the data
  28349. * @param generateMipMaps defines if the engine should generate the mip levels
  28350. * @param invertY defines if data must be stored with Y axis inverted
  28351. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28352. * @param compression defines the compression used (null by default)
  28353. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28354. * @returns the raw texture inside an InternalTexture
  28355. */
  28356. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28357. private _unpackFlipYCached;
  28358. /**
  28359. * In case you are sharing the context with other applications, it might
  28360. * be interested to not cache the unpack flip y state to ensure a consistent
  28361. * value would be set.
  28362. */
  28363. enableUnpackFlipYCached: boolean;
  28364. /** @hidden */
  28365. _unpackFlipY(value: boolean): void;
  28366. /** @hidden */
  28367. _getUnpackAlignement(): number;
  28368. /**
  28369. * Creates a dynamic texture
  28370. * @param width defines the width of the texture
  28371. * @param height defines the height of the texture
  28372. * @param generateMipMaps defines if the engine should generate the mip levels
  28373. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28374. * @returns the dynamic texture inside an InternalTexture
  28375. */
  28376. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28377. /**
  28378. * Update the sampling mode of a given texture
  28379. * @param samplingMode defines the required sampling mode
  28380. * @param texture defines the texture to update
  28381. */
  28382. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28383. /**
  28384. * Update the content of a dynamic texture
  28385. * @param texture defines the texture to update
  28386. * @param canvas defines the canvas containing the source
  28387. * @param invertY defines if data must be stored with Y axis inverted
  28388. * @param premulAlpha defines if alpha is stored as premultiplied
  28389. * @param format defines the format of the data
  28390. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28391. */
  28392. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28393. /**
  28394. * Update a video texture
  28395. * @param texture defines the texture to update
  28396. * @param video defines the video element to use
  28397. * @param invertY defines if data must be stored with Y axis inverted
  28398. */
  28399. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28400. /**
  28401. * Updates a depth texture Comparison Mode and Function.
  28402. * If the comparison Function is equal to 0, the mode will be set to none.
  28403. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28404. * @param texture The texture to set the comparison function for
  28405. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28406. */
  28407. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28408. private _setupDepthStencilTexture;
  28409. /**
  28410. * Creates a depth stencil texture.
  28411. * This is only available in WebGL 2 or with the depth texture extension available.
  28412. * @param size The size of face edge in the texture.
  28413. * @param options The options defining the texture.
  28414. * @returns The texture
  28415. */
  28416. createDepthStencilTexture(size: number | {
  28417. width: number;
  28418. height: number;
  28419. }, options: DepthTextureCreationOptions): InternalTexture;
  28420. /**
  28421. * Creates a depth stencil texture.
  28422. * This is only available in WebGL 2 or with the depth texture extension available.
  28423. * @param size The size of face edge in the texture.
  28424. * @param options The options defining the texture.
  28425. * @returns The texture
  28426. */
  28427. private _createDepthStencilTexture;
  28428. /**
  28429. * Creates a depth stencil cube texture.
  28430. * This is only available in WebGL 2.
  28431. * @param size The size of face edge in the cube texture.
  28432. * @param options The options defining the cube texture.
  28433. * @returns The cube texture
  28434. */
  28435. private _createDepthStencilCubeTexture;
  28436. /**
  28437. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28438. * @param renderTarget The render target to set the frame buffer for
  28439. */
  28440. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28441. /**
  28442. * Creates a new render target texture
  28443. * @param size defines the size of the texture
  28444. * @param options defines the options used to create the texture
  28445. * @returns a new render target texture stored in an InternalTexture
  28446. */
  28447. createRenderTargetTexture(size: number | {
  28448. width: number;
  28449. height: number;
  28450. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28451. /**
  28452. * Create a multi render target texture
  28453. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28454. * @param size defines the size of the texture
  28455. * @param options defines the creation options
  28456. * @returns the cube texture as an InternalTexture
  28457. */
  28458. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28459. private _setupFramebufferDepthAttachments;
  28460. /**
  28461. * Updates the sample count of a render target texture
  28462. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28463. * @param texture defines the texture to update
  28464. * @param samples defines the sample count to set
  28465. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28466. */
  28467. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28468. /**
  28469. * Update the sample count for a given multiple render target texture
  28470. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28471. * @param textures defines the textures to update
  28472. * @param samples defines the sample count to set
  28473. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28474. */
  28475. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28476. /** @hidden */
  28477. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28478. /** @hidden */
  28479. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28480. /** @hidden */
  28481. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28482. /** @hidden */
  28483. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28484. /**
  28485. * Creates a new render target cube texture
  28486. * @param size defines the size of the texture
  28487. * @param options defines the options used to create the texture
  28488. * @returns a new render target cube texture stored in an InternalTexture
  28489. */
  28490. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28491. /**
  28492. * Creates a cube texture
  28493. * @param rootUrl defines the url where the files to load is located
  28494. * @param scene defines the current scene
  28495. * @param files defines the list of files to load (1 per face)
  28496. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28497. * @param onLoad defines an optional callback raised when the texture is loaded
  28498. * @param onError defines an optional callback raised if there is an issue to load the texture
  28499. * @param format defines the format of the data
  28500. * @param forcedExtension defines the extension to use to pick the right loader
  28501. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28502. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28503. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28504. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28505. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28506. * @returns the cube texture as an InternalTexture
  28507. */
  28508. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28509. /**
  28510. * @hidden
  28511. */
  28512. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28513. /**
  28514. * Update a raw cube texture
  28515. * @param texture defines the texture to udpdate
  28516. * @param data defines the data to store
  28517. * @param format defines the data format
  28518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28519. * @param invertY defines if data must be stored with Y axis inverted
  28520. * @param compression defines the compression used (null by default)
  28521. * @param level defines which level of the texture to update
  28522. */
  28523. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28524. /**
  28525. * Creates a new raw cube texture
  28526. * @param data defines the array of data to use to create each face
  28527. * @param size defines the size of the textures
  28528. * @param format defines the format of the data
  28529. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28530. * @param generateMipMaps defines if the engine should generate the mip levels
  28531. * @param invertY defines if data must be stored with Y axis inverted
  28532. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28533. * @param compression defines the compression used (null by default)
  28534. * @returns the cube texture as an InternalTexture
  28535. */
  28536. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28537. /**
  28538. * Creates a new raw cube texture from a specified url
  28539. * @param url defines the url where the data is located
  28540. * @param scene defines the current scene
  28541. * @param size defines the size of the textures
  28542. * @param format defines the format of the data
  28543. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28544. * @param noMipmap defines if the engine should avoid generating the mip levels
  28545. * @param callback defines a callback used to extract texture data from loaded data
  28546. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28547. * @param onLoad defines a callback called when texture is loaded
  28548. * @param onError defines a callback called if there is an error
  28549. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28550. * @param invertY defines if data must be stored with Y axis inverted
  28551. * @returns the cube texture as an InternalTexture
  28552. */
  28553. 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;
  28554. /**
  28555. * Update a raw 3D texture
  28556. * @param texture defines the texture to update
  28557. * @param data defines the data to store
  28558. * @param format defines the data format
  28559. * @param invertY defines if data must be stored with Y axis inverted
  28560. * @param compression defines the used compression (can be null)
  28561. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28562. */
  28563. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28564. /**
  28565. * Creates a new raw 3D texture
  28566. * @param data defines the data used to create the texture
  28567. * @param width defines the width of the texture
  28568. * @param height defines the height of the texture
  28569. * @param depth defines the depth of the texture
  28570. * @param format defines the format of the texture
  28571. * @param generateMipMaps defines if the engine must generate mip levels
  28572. * @param invertY defines if data must be stored with Y axis inverted
  28573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28574. * @param compression defines the compressed used (can be null)
  28575. * @param textureType defines the compressed used (can be null)
  28576. * @returns a new raw 3D texture (stored in an InternalTexture)
  28577. */
  28578. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28579. private _prepareWebGLTextureContinuation;
  28580. private _prepareWebGLTexture;
  28581. private _convertRGBtoRGBATextureData;
  28582. /** @hidden */
  28583. _releaseFramebufferObjects(texture: InternalTexture): void;
  28584. /** @hidden */
  28585. _releaseTexture(texture: InternalTexture): void;
  28586. private setProgram;
  28587. private _boundUniforms;
  28588. /**
  28589. * Binds an effect to the webGL context
  28590. * @param effect defines the effect to bind
  28591. */
  28592. bindSamplers(effect: Effect): void;
  28593. private _moveBoundTextureOnTop;
  28594. private _getCorrectTextureChannel;
  28595. private _linkTrackers;
  28596. private _removeDesignatedSlot;
  28597. private _activateCurrentTexture;
  28598. /** @hidden */
  28599. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28600. /** @hidden */
  28601. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28602. /**
  28603. * Sets a texture to the webGL context from a postprocess
  28604. * @param channel defines the channel to use
  28605. * @param postProcess defines the source postprocess
  28606. */
  28607. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28608. /**
  28609. * Binds the output of the passed in post process to the texture channel specified
  28610. * @param channel The channel the texture should be bound to
  28611. * @param postProcess The post process which's output should be bound
  28612. */
  28613. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28614. /**
  28615. * Unbind all textures from the webGL context
  28616. */
  28617. unbindAllTextures(): void;
  28618. /**
  28619. * Sets a texture to the according uniform.
  28620. * @param channel The texture channel
  28621. * @param uniform The uniform to set
  28622. * @param texture The texture to apply
  28623. */
  28624. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28625. /**
  28626. * Sets a depth stencil texture from a render target to the according uniform.
  28627. * @param channel The texture channel
  28628. * @param uniform The uniform to set
  28629. * @param texture The render target texture containing the depth stencil texture to apply
  28630. */
  28631. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28632. private _bindSamplerUniformToChannel;
  28633. private _getTextureWrapMode;
  28634. private _setTexture;
  28635. /**
  28636. * Sets an array of texture to the webGL context
  28637. * @param channel defines the channel where the texture array must be set
  28638. * @param uniform defines the associated uniform location
  28639. * @param textures defines the array of textures to bind
  28640. */
  28641. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28642. /** @hidden */
  28643. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28644. private _setTextureParameterFloat;
  28645. private _setTextureParameterInteger;
  28646. /**
  28647. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28648. * @param x defines the x coordinate of the rectangle where pixels must be read
  28649. * @param y defines the y coordinate of the rectangle where pixels must be read
  28650. * @param width defines the width of the rectangle where pixels must be read
  28651. * @param height defines the height of the rectangle where pixels must be read
  28652. * @returns a Uint8Array containing RGBA colors
  28653. */
  28654. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28655. /**
  28656. * Add an externaly attached data from its key.
  28657. * This method call will fail and return false, if such key already exists.
  28658. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28659. * @param key the unique key that identifies the data
  28660. * @param data the data object to associate to the key for this Engine instance
  28661. * @return true if no such key were already present and the data was added successfully, false otherwise
  28662. */
  28663. addExternalData<T>(key: string, data: T): boolean;
  28664. /**
  28665. * Get an externaly attached data from its key
  28666. * @param key the unique key that identifies the data
  28667. * @return the associated data, if present (can be null), or undefined if not present
  28668. */
  28669. getExternalData<T>(key: string): T;
  28670. /**
  28671. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28672. * @param key the unique key that identifies the data
  28673. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28674. * @return the associated data, can be null if the factory returned null.
  28675. */
  28676. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28677. /**
  28678. * Remove an externaly attached data from the Engine instance
  28679. * @param key the unique key that identifies the data
  28680. * @return true if the data was successfully removed, false if it doesn't exist
  28681. */
  28682. removeExternalData(key: string): boolean;
  28683. /**
  28684. * Unbind all vertex attributes from the webGL context
  28685. */
  28686. unbindAllAttributes(): void;
  28687. /**
  28688. * 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
  28689. */
  28690. releaseEffects(): void;
  28691. /**
  28692. * Dispose and release all associated resources
  28693. */
  28694. dispose(): void;
  28695. /**
  28696. * Display the loading screen
  28697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28698. */
  28699. displayLoadingUI(): void;
  28700. /**
  28701. * Hide the loading screen
  28702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28703. */
  28704. hideLoadingUI(): void;
  28705. /**
  28706. * Gets the current loading screen object
  28707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28708. */
  28709. /**
  28710. * Sets the current loading screen object
  28711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28712. */
  28713. loadingScreen: ILoadingScreen;
  28714. /**
  28715. * Sets the current loading screen text
  28716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28717. */
  28718. loadingUIText: string;
  28719. /**
  28720. * Sets the current loading screen background color
  28721. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28722. */
  28723. loadingUIBackgroundColor: string;
  28724. /**
  28725. * Attach a new callback raised when context lost event is fired
  28726. * @param callback defines the callback to call
  28727. */
  28728. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28729. /**
  28730. * Attach a new callback raised when context restored event is fired
  28731. * @param callback defines the callback to call
  28732. */
  28733. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28734. /**
  28735. * Gets the source code of the vertex shader associated with a specific webGL program
  28736. * @param program defines the program to use
  28737. * @returns a string containing the source code of the vertex shader associated with the program
  28738. */
  28739. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28740. /**
  28741. * Gets the source code of the fragment shader associated with a specific webGL program
  28742. * @param program defines the program to use
  28743. * @returns a string containing the source code of the fragment shader associated with the program
  28744. */
  28745. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28746. /**
  28747. * Get the current error code of the webGL context
  28748. * @returns the error code
  28749. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28750. */
  28751. getError(): number;
  28752. /**
  28753. * Gets the current framerate
  28754. * @returns a number representing the framerate
  28755. */
  28756. getFps(): number;
  28757. /**
  28758. * Gets the time spent between current and previous frame
  28759. * @returns a number representing the delta time in ms
  28760. */
  28761. getDeltaTime(): number;
  28762. private _measureFps;
  28763. /** @hidden */
  28764. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28765. private _canRenderToFloatFramebuffer;
  28766. private _canRenderToHalfFloatFramebuffer;
  28767. private _canRenderToFramebuffer;
  28768. /** @hidden */
  28769. _getWebGLTextureType(type: number): number;
  28770. private _getInternalFormat;
  28771. /** @hidden */
  28772. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28773. /** @hidden */
  28774. _getRGBAMultiSampleBufferFormat(type: number): number;
  28775. /** @hidden */
  28776. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28777. /** @hidden */
  28778. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28779. private _partialLoadFile;
  28780. private _cascadeLoadFiles;
  28781. /**
  28782. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28783. * @returns true if the engine can be created
  28784. * @ignorenaming
  28785. */
  28786. static isSupported(): boolean;
  28787. }
  28788. }
  28789. declare module "babylonjs/Materials/effect" {
  28790. import { Observable } from "babylonjs/Misc/observable";
  28791. import { Nullable } from "babylonjs/types";
  28792. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28793. import { Engine } from "babylonjs/Engines/engine";
  28794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28799. /**
  28800. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28801. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28802. */
  28803. export class EffectFallbacks {
  28804. private _defines;
  28805. private _currentRank;
  28806. private _maxRank;
  28807. private _mesh;
  28808. /**
  28809. * Removes the fallback from the bound mesh.
  28810. */
  28811. unBindMesh(): void;
  28812. /**
  28813. * Adds a fallback on the specified property.
  28814. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28815. * @param define The name of the define in the shader
  28816. */
  28817. addFallback(rank: number, define: string): void;
  28818. /**
  28819. * Sets the mesh to use CPU skinning when needing to fallback.
  28820. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28821. * @param mesh The mesh to use the fallbacks.
  28822. */
  28823. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28824. /**
  28825. * Checks to see if more fallbacks are still availible.
  28826. */
  28827. readonly isMoreFallbacks: boolean;
  28828. /**
  28829. * Removes the defines that shoould be removed when falling back.
  28830. * @param currentDefines defines the current define statements for the shader.
  28831. * @param effect defines the current effect we try to compile
  28832. * @returns The resulting defines with defines of the current rank removed.
  28833. */
  28834. reduce(currentDefines: string, effect: Effect): string;
  28835. }
  28836. /**
  28837. * Options to be used when creating an effect.
  28838. */
  28839. export class EffectCreationOptions {
  28840. /**
  28841. * Atrributes that will be used in the shader.
  28842. */
  28843. attributes: string[];
  28844. /**
  28845. * Uniform varible names that will be set in the shader.
  28846. */
  28847. uniformsNames: string[];
  28848. /**
  28849. * Uniform buffer varible names that will be set in the shader.
  28850. */
  28851. uniformBuffersNames: string[];
  28852. /**
  28853. * Sampler texture variable names that will be set in the shader.
  28854. */
  28855. samplers: string[];
  28856. /**
  28857. * Define statements that will be set in the shader.
  28858. */
  28859. defines: any;
  28860. /**
  28861. * Possible fallbacks for this effect to improve performance when needed.
  28862. */
  28863. fallbacks: Nullable<EffectFallbacks>;
  28864. /**
  28865. * Callback that will be called when the shader is compiled.
  28866. */
  28867. onCompiled: Nullable<(effect: Effect) => void>;
  28868. /**
  28869. * Callback that will be called if an error occurs during shader compilation.
  28870. */
  28871. onError: Nullable<(effect: Effect, errors: string) => void>;
  28872. /**
  28873. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28874. */
  28875. indexParameters: any;
  28876. /**
  28877. * Max number of lights that can be used in the shader.
  28878. */
  28879. maxSimultaneousLights: number;
  28880. /**
  28881. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28882. */
  28883. transformFeedbackVaryings: Nullable<string[]>;
  28884. }
  28885. /**
  28886. * Effect containing vertex and fragment shader that can be executed on an object.
  28887. */
  28888. export class Effect {
  28889. /**
  28890. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28891. */
  28892. static ShadersRepository: string;
  28893. /**
  28894. * Name of the effect.
  28895. */
  28896. name: any;
  28897. /**
  28898. * String container all the define statements that should be set on the shader.
  28899. */
  28900. defines: string;
  28901. /**
  28902. * Callback that will be called when the shader is compiled.
  28903. */
  28904. onCompiled: Nullable<(effect: Effect) => void>;
  28905. /**
  28906. * Callback that will be called if an error occurs during shader compilation.
  28907. */
  28908. onError: Nullable<(effect: Effect, errors: string) => void>;
  28909. /**
  28910. * Callback that will be called when effect is bound.
  28911. */
  28912. onBind: Nullable<(effect: Effect) => void>;
  28913. /**
  28914. * Unique ID of the effect.
  28915. */
  28916. uniqueId: number;
  28917. /**
  28918. * Observable that will be called when the shader is compiled.
  28919. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28920. */
  28921. onCompileObservable: Observable<Effect>;
  28922. /**
  28923. * Observable that will be called if an error occurs during shader compilation.
  28924. */
  28925. onErrorObservable: Observable<Effect>;
  28926. /** @hidden */
  28927. _onBindObservable: Nullable<Observable<Effect>>;
  28928. /**
  28929. * Observable that will be called when effect is bound.
  28930. */
  28931. readonly onBindObservable: Observable<Effect>;
  28932. /** @hidden */
  28933. _bonesComputationForcedToCPU: boolean;
  28934. private static _uniqueIdSeed;
  28935. private _engine;
  28936. private _uniformBuffersNames;
  28937. private _uniformsNames;
  28938. private _samplers;
  28939. private _isReady;
  28940. private _compilationError;
  28941. private _attributesNames;
  28942. private _attributes;
  28943. private _uniforms;
  28944. /**
  28945. * Key for the effect.
  28946. * @hidden
  28947. */
  28948. _key: string;
  28949. private _indexParameters;
  28950. private _fallbacks;
  28951. private _vertexSourceCode;
  28952. private _fragmentSourceCode;
  28953. private _vertexSourceCodeOverride;
  28954. private _fragmentSourceCodeOverride;
  28955. private _transformFeedbackVaryings;
  28956. /**
  28957. * Compiled shader to webGL program.
  28958. * @hidden
  28959. */
  28960. _program: WebGLProgram;
  28961. private _valueCache;
  28962. private static _baseCache;
  28963. /**
  28964. * Instantiates an effect.
  28965. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28966. * @param baseName Name of the effect.
  28967. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28968. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28969. * @param samplers List of sampler variables that will be passed to the shader.
  28970. * @param engine Engine to be used to render the effect
  28971. * @param defines Define statements to be added to the shader.
  28972. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28973. * @param onCompiled Callback that will be called when the shader is compiled.
  28974. * @param onError Callback that will be called if an error occurs during shader compilation.
  28975. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28976. */
  28977. 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);
  28978. /**
  28979. * Unique key for this effect
  28980. */
  28981. readonly key: string;
  28982. /**
  28983. * If the effect has been compiled and prepared.
  28984. * @returns if the effect is compiled and prepared.
  28985. */
  28986. isReady(): boolean;
  28987. /**
  28988. * The engine the effect was initialized with.
  28989. * @returns the engine.
  28990. */
  28991. getEngine(): Engine;
  28992. /**
  28993. * The compiled webGL program for the effect
  28994. * @returns the webGL program.
  28995. */
  28996. getProgram(): WebGLProgram;
  28997. /**
  28998. * The set of names of attribute variables for the shader.
  28999. * @returns An array of attribute names.
  29000. */
  29001. getAttributesNames(): string[];
  29002. /**
  29003. * Returns the attribute at the given index.
  29004. * @param index The index of the attribute.
  29005. * @returns The location of the attribute.
  29006. */
  29007. getAttributeLocation(index: number): number;
  29008. /**
  29009. * Returns the attribute based on the name of the variable.
  29010. * @param name of the attribute to look up.
  29011. * @returns the attribute location.
  29012. */
  29013. getAttributeLocationByName(name: string): number;
  29014. /**
  29015. * The number of attributes.
  29016. * @returns the numnber of attributes.
  29017. */
  29018. getAttributesCount(): number;
  29019. /**
  29020. * Gets the index of a uniform variable.
  29021. * @param uniformName of the uniform to look up.
  29022. * @returns the index.
  29023. */
  29024. getUniformIndex(uniformName: string): number;
  29025. /**
  29026. * Returns the attribute based on the name of the variable.
  29027. * @param uniformName of the uniform to look up.
  29028. * @returns the location of the uniform.
  29029. */
  29030. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29031. /**
  29032. * Returns an array of sampler variable names
  29033. * @returns The array of sampler variable neames.
  29034. */
  29035. getSamplers(): string[];
  29036. /**
  29037. * The error from the last compilation.
  29038. * @returns the error string.
  29039. */
  29040. getCompilationError(): string;
  29041. /**
  29042. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29043. * @param func The callback to be used.
  29044. */
  29045. executeWhenCompiled(func: (effect: Effect) => void): void;
  29046. private _checkIsReady;
  29047. /** @hidden */
  29048. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29049. /** @hidden */
  29050. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29051. /** @hidden */
  29052. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29053. private _processShaderConversion;
  29054. private _processIncludes;
  29055. private _processPrecision;
  29056. /**
  29057. * Recompiles the webGL program
  29058. * @param vertexSourceCode The source code for the vertex shader.
  29059. * @param fragmentSourceCode The source code for the fragment shader.
  29060. * @param onCompiled Callback called when completed.
  29061. * @param onError Callback called on error.
  29062. * @hidden
  29063. */
  29064. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29065. /**
  29066. * Gets the uniform locations of the the specified variable names
  29067. * @param names THe names of the variables to lookup.
  29068. * @returns Array of locations in the same order as variable names.
  29069. */
  29070. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29071. /**
  29072. * Prepares the effect
  29073. * @hidden
  29074. */
  29075. _prepareEffect(): void;
  29076. /**
  29077. * Checks if the effect is supported. (Must be called after compilation)
  29078. */
  29079. readonly isSupported: boolean;
  29080. /**
  29081. * Binds a texture to the engine to be used as output of the shader.
  29082. * @param channel Name of the output variable.
  29083. * @param texture Texture to bind.
  29084. * @hidden
  29085. */
  29086. _bindTexture(channel: string, texture: InternalTexture): void;
  29087. /**
  29088. * Sets a texture on the engine to be used in the shader.
  29089. * @param channel Name of the sampler variable.
  29090. * @param texture Texture to set.
  29091. */
  29092. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29093. /**
  29094. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29095. * @param channel Name of the sampler variable.
  29096. * @param texture Texture to set.
  29097. */
  29098. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29099. /**
  29100. * Sets an array of textures on the engine to be used in the shader.
  29101. * @param channel Name of the variable.
  29102. * @param textures Textures to set.
  29103. */
  29104. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29105. /**
  29106. * 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)
  29107. * @param channel Name of the sampler variable.
  29108. * @param postProcess Post process to get the input texture from.
  29109. */
  29110. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29111. /**
  29112. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29113. * 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)
  29114. * @param channel Name of the sampler variable.
  29115. * @param postProcess Post process to get the output texture from.
  29116. */
  29117. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29118. /** @hidden */
  29119. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29120. /** @hidden */
  29121. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29122. /** @hidden */
  29123. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29124. /** @hidden */
  29125. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29126. /**
  29127. * Binds a buffer to a uniform.
  29128. * @param buffer Buffer to bind.
  29129. * @param name Name of the uniform variable to bind to.
  29130. */
  29131. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29132. /**
  29133. * Binds block to a uniform.
  29134. * @param blockName Name of the block to bind.
  29135. * @param index Index to bind.
  29136. */
  29137. bindUniformBlock(blockName: string, index: number): void;
  29138. /**
  29139. * Sets an interger value on a uniform variable.
  29140. * @param uniformName Name of the variable.
  29141. * @param value Value to be set.
  29142. * @returns this effect.
  29143. */
  29144. setInt(uniformName: string, value: number): Effect;
  29145. /**
  29146. * Sets an int array on a uniform variable.
  29147. * @param uniformName Name of the variable.
  29148. * @param array array to be set.
  29149. * @returns this effect.
  29150. */
  29151. setIntArray(uniformName: string, array: Int32Array): Effect;
  29152. /**
  29153. * 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)
  29154. * @param uniformName Name of the variable.
  29155. * @param array array to be set.
  29156. * @returns this effect.
  29157. */
  29158. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29159. /**
  29160. * 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)
  29161. * @param uniformName Name of the variable.
  29162. * @param array array to be set.
  29163. * @returns this effect.
  29164. */
  29165. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29166. /**
  29167. * 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)
  29168. * @param uniformName Name of the variable.
  29169. * @param array array to be set.
  29170. * @returns this effect.
  29171. */
  29172. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29173. /**
  29174. * Sets an float array on a uniform variable.
  29175. * @param uniformName Name of the variable.
  29176. * @param array array to be set.
  29177. * @returns this effect.
  29178. */
  29179. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29180. /**
  29181. * 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)
  29182. * @param uniformName Name of the variable.
  29183. * @param array array to be set.
  29184. * @returns this effect.
  29185. */
  29186. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29187. /**
  29188. * 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)
  29189. * @param uniformName Name of the variable.
  29190. * @param array array to be set.
  29191. * @returns this effect.
  29192. */
  29193. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29194. /**
  29195. * 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)
  29196. * @param uniformName Name of the variable.
  29197. * @param array array to be set.
  29198. * @returns this effect.
  29199. */
  29200. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29201. /**
  29202. * Sets an array on a uniform variable.
  29203. * @param uniformName Name of the variable.
  29204. * @param array array to be set.
  29205. * @returns this effect.
  29206. */
  29207. setArray(uniformName: string, array: number[]): Effect;
  29208. /**
  29209. * 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)
  29210. * @param uniformName Name of the variable.
  29211. * @param array array to be set.
  29212. * @returns this effect.
  29213. */
  29214. setArray2(uniformName: string, array: number[]): Effect;
  29215. /**
  29216. * 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)
  29217. * @param uniformName Name of the variable.
  29218. * @param array array to be set.
  29219. * @returns this effect.
  29220. */
  29221. setArray3(uniformName: string, array: number[]): Effect;
  29222. /**
  29223. * 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)
  29224. * @param uniformName Name of the variable.
  29225. * @param array array to be set.
  29226. * @returns this effect.
  29227. */
  29228. setArray4(uniformName: string, array: number[]): Effect;
  29229. /**
  29230. * Sets matrices on a uniform variable.
  29231. * @param uniformName Name of the variable.
  29232. * @param matrices matrices to be set.
  29233. * @returns this effect.
  29234. */
  29235. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29236. /**
  29237. * Sets matrix on a uniform variable.
  29238. * @param uniformName Name of the variable.
  29239. * @param matrix matrix to be set.
  29240. * @returns this effect.
  29241. */
  29242. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29243. /**
  29244. * 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)
  29245. * @param uniformName Name of the variable.
  29246. * @param matrix matrix to be set.
  29247. * @returns this effect.
  29248. */
  29249. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29250. /**
  29251. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29252. * @param uniformName Name of the variable.
  29253. * @param matrix matrix to be set.
  29254. * @returns this effect.
  29255. */
  29256. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29257. /**
  29258. * Sets a float on a uniform variable.
  29259. * @param uniformName Name of the variable.
  29260. * @param value value to be set.
  29261. * @returns this effect.
  29262. */
  29263. setFloat(uniformName: string, value: number): Effect;
  29264. /**
  29265. * Sets a boolean on a uniform variable.
  29266. * @param uniformName Name of the variable.
  29267. * @param bool value to be set.
  29268. * @returns this effect.
  29269. */
  29270. setBool(uniformName: string, bool: boolean): Effect;
  29271. /**
  29272. * Sets a Vector2 on a uniform variable.
  29273. * @param uniformName Name of the variable.
  29274. * @param vector2 vector2 to be set.
  29275. * @returns this effect.
  29276. */
  29277. setVector2(uniformName: string, vector2: Vector2): Effect;
  29278. /**
  29279. * Sets a float2 on a uniform variable.
  29280. * @param uniformName Name of the variable.
  29281. * @param x First float in float2.
  29282. * @param y Second float in float2.
  29283. * @returns this effect.
  29284. */
  29285. setFloat2(uniformName: string, x: number, y: number): Effect;
  29286. /**
  29287. * Sets a Vector3 on a uniform variable.
  29288. * @param uniformName Name of the variable.
  29289. * @param vector3 Value to be set.
  29290. * @returns this effect.
  29291. */
  29292. setVector3(uniformName: string, vector3: Vector3): Effect;
  29293. /**
  29294. * Sets a float3 on a uniform variable.
  29295. * @param uniformName Name of the variable.
  29296. * @param x First float in float3.
  29297. * @param y Second float in float3.
  29298. * @param z Third float in float3.
  29299. * @returns this effect.
  29300. */
  29301. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29302. /**
  29303. * Sets a Vector4 on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param vector4 Value to be set.
  29306. * @returns this effect.
  29307. */
  29308. setVector4(uniformName: string, vector4: Vector4): Effect;
  29309. /**
  29310. * Sets a float4 on a uniform variable.
  29311. * @param uniformName Name of the variable.
  29312. * @param x First float in float4.
  29313. * @param y Second float in float4.
  29314. * @param z Third float in float4.
  29315. * @param w Fourth float in float4.
  29316. * @returns this effect.
  29317. */
  29318. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29319. /**
  29320. * Sets a Color3 on a uniform variable.
  29321. * @param uniformName Name of the variable.
  29322. * @param color3 Value to be set.
  29323. * @returns this effect.
  29324. */
  29325. setColor3(uniformName: string, color3: Color3): Effect;
  29326. /**
  29327. * Sets a Color4 on a uniform variable.
  29328. * @param uniformName Name of the variable.
  29329. * @param color3 Value to be set.
  29330. * @param alpha Alpha value to be set.
  29331. * @returns this effect.
  29332. */
  29333. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29334. /**
  29335. * Sets a Color4 on a uniform variable
  29336. * @param uniformName defines the name of the variable
  29337. * @param color4 defines the value to be set
  29338. * @returns this effect.
  29339. */
  29340. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29341. /**
  29342. * This function will add a new shader to the shader store
  29343. * @param name the name of the shader
  29344. * @param pixelShader optional pixel shader content
  29345. * @param vertexShader optional vertex shader content
  29346. */
  29347. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29348. /**
  29349. * Store of each shader (The can be looked up using effect.key)
  29350. */
  29351. static ShadersStore: {
  29352. [key: string]: string;
  29353. };
  29354. /**
  29355. * Store of each included file for a shader (The can be looked up using effect.key)
  29356. */
  29357. static IncludesShadersStore: {
  29358. [key: string]: string;
  29359. };
  29360. /**
  29361. * Resets the cache of effects.
  29362. */
  29363. static ResetCache(): void;
  29364. }
  29365. }
  29366. declare module "babylonjs/Materials/colorCurves" {
  29367. import { Effect } from "babylonjs/Materials/effect";
  29368. /**
  29369. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29370. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29371. * 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;
  29372. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29373. */
  29374. export class ColorCurves {
  29375. private _dirty;
  29376. private _tempColor;
  29377. private _globalCurve;
  29378. private _highlightsCurve;
  29379. private _midtonesCurve;
  29380. private _shadowsCurve;
  29381. private _positiveCurve;
  29382. private _negativeCurve;
  29383. private _globalHue;
  29384. private _globalDensity;
  29385. private _globalSaturation;
  29386. private _globalExposure;
  29387. /**
  29388. * Gets the global Hue value.
  29389. * 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).
  29390. */
  29391. /**
  29392. * Sets the global Hue value.
  29393. * 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).
  29394. */
  29395. globalHue: number;
  29396. /**
  29397. * Gets the global Density value.
  29398. * 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.
  29399. * Values less than zero provide a filter of opposite hue.
  29400. */
  29401. /**
  29402. * Sets the global Density value.
  29403. * 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.
  29404. * Values less than zero provide a filter of opposite hue.
  29405. */
  29406. globalDensity: number;
  29407. /**
  29408. * Gets the global Saturation value.
  29409. * 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.
  29410. */
  29411. /**
  29412. * Sets the global Saturation value.
  29413. * 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.
  29414. */
  29415. globalSaturation: number;
  29416. /**
  29417. * Gets the global Exposure value.
  29418. * 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.
  29419. */
  29420. /**
  29421. * Sets the global Exposure value.
  29422. * 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.
  29423. */
  29424. globalExposure: number;
  29425. private _highlightsHue;
  29426. private _highlightsDensity;
  29427. private _highlightsSaturation;
  29428. private _highlightsExposure;
  29429. /**
  29430. * Gets the highlights Hue value.
  29431. * 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).
  29432. */
  29433. /**
  29434. * Sets the highlights Hue value.
  29435. * 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).
  29436. */
  29437. highlightsHue: number;
  29438. /**
  29439. * Gets the highlights Density value.
  29440. * 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.
  29441. * Values less than zero provide a filter of opposite hue.
  29442. */
  29443. /**
  29444. * Sets the highlights Density value.
  29445. * 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.
  29446. * Values less than zero provide a filter of opposite hue.
  29447. */
  29448. highlightsDensity: number;
  29449. /**
  29450. * Gets the highlights Saturation value.
  29451. * 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.
  29452. */
  29453. /**
  29454. * Sets the highlights Saturation value.
  29455. * 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.
  29456. */
  29457. highlightsSaturation: number;
  29458. /**
  29459. * Gets the highlights Exposure value.
  29460. * 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.
  29461. */
  29462. /**
  29463. * Sets the highlights Exposure value.
  29464. * 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.
  29465. */
  29466. highlightsExposure: number;
  29467. private _midtonesHue;
  29468. private _midtonesDensity;
  29469. private _midtonesSaturation;
  29470. private _midtonesExposure;
  29471. /**
  29472. * Gets the midtones Hue value.
  29473. * 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).
  29474. */
  29475. /**
  29476. * Sets the midtones Hue value.
  29477. * 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).
  29478. */
  29479. midtonesHue: number;
  29480. /**
  29481. * Gets the midtones Density value.
  29482. * 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.
  29483. * Values less than zero provide a filter of opposite hue.
  29484. */
  29485. /**
  29486. * Sets the midtones Density value.
  29487. * 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.
  29488. * Values less than zero provide a filter of opposite hue.
  29489. */
  29490. midtonesDensity: number;
  29491. /**
  29492. * Gets the midtones Saturation value.
  29493. * 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.
  29494. */
  29495. /**
  29496. * Sets the midtones Saturation value.
  29497. * 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.
  29498. */
  29499. midtonesSaturation: number;
  29500. /**
  29501. * Gets the midtones Exposure value.
  29502. * 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.
  29503. */
  29504. /**
  29505. * Sets the midtones Exposure value.
  29506. * 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.
  29507. */
  29508. midtonesExposure: number;
  29509. private _shadowsHue;
  29510. private _shadowsDensity;
  29511. private _shadowsSaturation;
  29512. private _shadowsExposure;
  29513. /**
  29514. * Gets the shadows Hue value.
  29515. * 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).
  29516. */
  29517. /**
  29518. * Sets the shadows Hue value.
  29519. * 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).
  29520. */
  29521. shadowsHue: number;
  29522. /**
  29523. * Gets the shadows Density value.
  29524. * 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.
  29525. * Values less than zero provide a filter of opposite hue.
  29526. */
  29527. /**
  29528. * Sets the shadows Density value.
  29529. * 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.
  29530. * Values less than zero provide a filter of opposite hue.
  29531. */
  29532. shadowsDensity: number;
  29533. /**
  29534. * Gets the shadows Saturation value.
  29535. * 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.
  29536. */
  29537. /**
  29538. * Sets the shadows Saturation value.
  29539. * 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.
  29540. */
  29541. shadowsSaturation: number;
  29542. /**
  29543. * Gets the shadows Exposure value.
  29544. * 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.
  29545. */
  29546. /**
  29547. * Sets the shadows Exposure value.
  29548. * 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.
  29549. */
  29550. shadowsExposure: number;
  29551. /**
  29552. * Returns the class name
  29553. * @returns The class name
  29554. */
  29555. getClassName(): string;
  29556. /**
  29557. * Binds the color curves to the shader.
  29558. * @param colorCurves The color curve to bind
  29559. * @param effect The effect to bind to
  29560. * @param positiveUniform The positive uniform shader parameter
  29561. * @param neutralUniform The neutral uniform shader parameter
  29562. * @param negativeUniform The negative uniform shader parameter
  29563. */
  29564. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29565. /**
  29566. * Prepare the list of uniforms associated with the ColorCurves effects.
  29567. * @param uniformsList The list of uniforms used in the effect
  29568. */
  29569. static PrepareUniforms(uniformsList: string[]): void;
  29570. /**
  29571. * Returns color grading data based on a hue, density, saturation and exposure value.
  29572. * @param filterHue The hue of the color filter.
  29573. * @param filterDensity The density of the color filter.
  29574. * @param saturation The saturation.
  29575. * @param exposure The exposure.
  29576. * @param result The result data container.
  29577. */
  29578. private getColorGradingDataToRef;
  29579. /**
  29580. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29581. * @param value The input slider value in range [-100,100].
  29582. * @returns Adjusted value.
  29583. */
  29584. private static applyColorGradingSliderNonlinear;
  29585. /**
  29586. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29587. * @param hue The hue (H) input.
  29588. * @param saturation The saturation (S) input.
  29589. * @param brightness The brightness (B) input.
  29590. * @result An RGBA color represented as Vector4.
  29591. */
  29592. private static fromHSBToRef;
  29593. /**
  29594. * Returns a value clamped between min and max
  29595. * @param value The value to clamp
  29596. * @param min The minimum of value
  29597. * @param max The maximum of value
  29598. * @returns The clamped value.
  29599. */
  29600. private static clamp;
  29601. /**
  29602. * Clones the current color curve instance.
  29603. * @return The cloned curves
  29604. */
  29605. clone(): ColorCurves;
  29606. /**
  29607. * Serializes the current color curve instance to a json representation.
  29608. * @return a JSON representation
  29609. */
  29610. serialize(): any;
  29611. /**
  29612. * Parses the color curve from a json representation.
  29613. * @param source the JSON source to parse
  29614. * @return The parsed curves
  29615. */
  29616. static Parse(source: any): ColorCurves;
  29617. }
  29618. }
  29619. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29620. import { Observable } from "babylonjs/Misc/observable";
  29621. import { Nullable } from "babylonjs/types";
  29622. import { Color4 } from "babylonjs/Maths/math";
  29623. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29624. import { Effect } from "babylonjs/Materials/effect";
  29625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29626. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29627. /**
  29628. * Interface to follow in your material defines to integrate easily the
  29629. * Image proccessing functions.
  29630. * @hidden
  29631. */
  29632. export interface IImageProcessingConfigurationDefines {
  29633. IMAGEPROCESSING: boolean;
  29634. VIGNETTE: boolean;
  29635. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29636. VIGNETTEBLENDMODEOPAQUE: boolean;
  29637. TONEMAPPING: boolean;
  29638. TONEMAPPING_ACES: boolean;
  29639. CONTRAST: boolean;
  29640. EXPOSURE: boolean;
  29641. COLORCURVES: boolean;
  29642. COLORGRADING: boolean;
  29643. COLORGRADING3D: boolean;
  29644. SAMPLER3DGREENDEPTH: boolean;
  29645. SAMPLER3DBGRMAP: boolean;
  29646. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29647. }
  29648. /**
  29649. * @hidden
  29650. */
  29651. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29652. IMAGEPROCESSING: boolean;
  29653. VIGNETTE: boolean;
  29654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29655. VIGNETTEBLENDMODEOPAQUE: boolean;
  29656. TONEMAPPING: boolean;
  29657. TONEMAPPING_ACES: boolean;
  29658. CONTRAST: boolean;
  29659. COLORCURVES: boolean;
  29660. COLORGRADING: boolean;
  29661. COLORGRADING3D: boolean;
  29662. SAMPLER3DGREENDEPTH: boolean;
  29663. SAMPLER3DBGRMAP: boolean;
  29664. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29665. EXPOSURE: boolean;
  29666. constructor();
  29667. }
  29668. /**
  29669. * This groups together the common properties used for image processing either in direct forward pass
  29670. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29671. * or not.
  29672. */
  29673. export class ImageProcessingConfiguration {
  29674. /**
  29675. * Default tone mapping applied in BabylonJS.
  29676. */
  29677. static readonly TONEMAPPING_STANDARD: number;
  29678. /**
  29679. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29680. * to other engines rendering to increase portability.
  29681. */
  29682. static readonly TONEMAPPING_ACES: number;
  29683. /**
  29684. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29685. */
  29686. colorCurves: Nullable<ColorCurves>;
  29687. private _colorCurvesEnabled;
  29688. /**
  29689. * Gets wether the color curves effect is enabled.
  29690. */
  29691. /**
  29692. * Sets wether the color curves effect is enabled.
  29693. */
  29694. colorCurvesEnabled: boolean;
  29695. private _colorGradingTexture;
  29696. /**
  29697. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29698. */
  29699. /**
  29700. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29701. */
  29702. colorGradingTexture: Nullable<BaseTexture>;
  29703. private _colorGradingEnabled;
  29704. /**
  29705. * Gets wether the color grading effect is enabled.
  29706. */
  29707. /**
  29708. * Sets wether the color grading effect is enabled.
  29709. */
  29710. colorGradingEnabled: boolean;
  29711. private _colorGradingWithGreenDepth;
  29712. /**
  29713. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29714. */
  29715. /**
  29716. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29717. */
  29718. colorGradingWithGreenDepth: boolean;
  29719. private _colorGradingBGR;
  29720. /**
  29721. * Gets wether the color grading texture contains BGR values.
  29722. */
  29723. /**
  29724. * Sets wether the color grading texture contains BGR values.
  29725. */
  29726. colorGradingBGR: boolean;
  29727. /** @hidden */
  29728. _exposure: number;
  29729. /**
  29730. * Gets the Exposure used in the effect.
  29731. */
  29732. /**
  29733. * Sets the Exposure used in the effect.
  29734. */
  29735. exposure: number;
  29736. private _toneMappingEnabled;
  29737. /**
  29738. * Gets wether the tone mapping effect is enabled.
  29739. */
  29740. /**
  29741. * Sets wether the tone mapping effect is enabled.
  29742. */
  29743. toneMappingEnabled: boolean;
  29744. private _toneMappingType;
  29745. /**
  29746. * Gets the type of tone mapping effect.
  29747. */
  29748. /**
  29749. * Sets the type of tone mapping effect used in BabylonJS.
  29750. */
  29751. toneMappingType: number;
  29752. protected _contrast: number;
  29753. /**
  29754. * Gets the contrast used in the effect.
  29755. */
  29756. /**
  29757. * Sets the contrast used in the effect.
  29758. */
  29759. contrast: number;
  29760. /**
  29761. * Vignette stretch size.
  29762. */
  29763. vignetteStretch: number;
  29764. /**
  29765. * Vignette centre X Offset.
  29766. */
  29767. vignetteCentreX: number;
  29768. /**
  29769. * Vignette centre Y Offset.
  29770. */
  29771. vignetteCentreY: number;
  29772. /**
  29773. * Vignette weight or intensity of the vignette effect.
  29774. */
  29775. vignetteWeight: number;
  29776. /**
  29777. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29778. * if vignetteEnabled is set to true.
  29779. */
  29780. vignetteColor: Color4;
  29781. /**
  29782. * Camera field of view used by the Vignette effect.
  29783. */
  29784. vignetteCameraFov: number;
  29785. private _vignetteBlendMode;
  29786. /**
  29787. * Gets the vignette blend mode allowing different kind of effect.
  29788. */
  29789. /**
  29790. * Sets the vignette blend mode allowing different kind of effect.
  29791. */
  29792. vignetteBlendMode: number;
  29793. private _vignetteEnabled;
  29794. /**
  29795. * Gets wether the vignette effect is enabled.
  29796. */
  29797. /**
  29798. * Sets wether the vignette effect is enabled.
  29799. */
  29800. vignetteEnabled: boolean;
  29801. private _applyByPostProcess;
  29802. /**
  29803. * Gets wether the image processing is applied through a post process or not.
  29804. */
  29805. /**
  29806. * Sets wether the image processing is applied through a post process or not.
  29807. */
  29808. applyByPostProcess: boolean;
  29809. private _isEnabled;
  29810. /**
  29811. * Gets wether the image processing is enabled or not.
  29812. */
  29813. /**
  29814. * Sets wether the image processing is enabled or not.
  29815. */
  29816. isEnabled: boolean;
  29817. /**
  29818. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29819. */
  29820. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29821. /**
  29822. * Method called each time the image processing information changes requires to recompile the effect.
  29823. */
  29824. protected _updateParameters(): void;
  29825. /**
  29826. * Gets the current class name.
  29827. * @return "ImageProcessingConfiguration"
  29828. */
  29829. getClassName(): string;
  29830. /**
  29831. * Prepare the list of uniforms associated with the Image Processing effects.
  29832. * @param uniforms The list of uniforms used in the effect
  29833. * @param defines the list of defines currently in use
  29834. */
  29835. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29836. /**
  29837. * Prepare the list of samplers associated with the Image Processing effects.
  29838. * @param samplersList The list of uniforms used in the effect
  29839. * @param defines the list of defines currently in use
  29840. */
  29841. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29842. /**
  29843. * Prepare the list of defines associated to the shader.
  29844. * @param defines the list of defines to complete
  29845. * @param forPostProcess Define if we are currently in post process mode or not
  29846. */
  29847. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29848. /**
  29849. * Returns true if all the image processing information are ready.
  29850. * @returns True if ready, otherwise, false
  29851. */
  29852. isReady(): boolean;
  29853. /**
  29854. * Binds the image processing to the shader.
  29855. * @param effect The effect to bind to
  29856. * @param aspectRatio Define the current aspect ratio of the effect
  29857. */
  29858. bind(effect: Effect, aspectRatio?: number): void;
  29859. /**
  29860. * Clones the current image processing instance.
  29861. * @return The cloned image processing
  29862. */
  29863. clone(): ImageProcessingConfiguration;
  29864. /**
  29865. * Serializes the current image processing instance to a json representation.
  29866. * @return a JSON representation
  29867. */
  29868. serialize(): any;
  29869. /**
  29870. * Parses the image processing from a json representation.
  29871. * @param source the JSON source to parse
  29872. * @return The parsed image processing
  29873. */
  29874. static Parse(source: any): ImageProcessingConfiguration;
  29875. private static _VIGNETTEMODE_MULTIPLY;
  29876. private static _VIGNETTEMODE_OPAQUE;
  29877. /**
  29878. * Used to apply the vignette as a mix with the pixel color.
  29879. */
  29880. static readonly VIGNETTEMODE_MULTIPLY: number;
  29881. /**
  29882. * Used to apply the vignette as a replacement of the pixel color.
  29883. */
  29884. static readonly VIGNETTEMODE_OPAQUE: number;
  29885. }
  29886. }
  29887. declare module "babylonjs/Materials/fresnelParameters" {
  29888. import { Color3 } from "babylonjs/Maths/math";
  29889. /**
  29890. * This represents all the required information to add a fresnel effect on a material:
  29891. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29892. */
  29893. export class FresnelParameters {
  29894. private _isEnabled;
  29895. /**
  29896. * Define if the fresnel effect is enable or not.
  29897. */
  29898. isEnabled: boolean;
  29899. /**
  29900. * Define the color used on edges (grazing angle)
  29901. */
  29902. leftColor: Color3;
  29903. /**
  29904. * Define the color used on center
  29905. */
  29906. rightColor: Color3;
  29907. /**
  29908. * Define bias applied to computed fresnel term
  29909. */
  29910. bias: number;
  29911. /**
  29912. * Defined the power exponent applied to fresnel term
  29913. */
  29914. power: number;
  29915. /**
  29916. * Clones the current fresnel and its valuues
  29917. * @returns a clone fresnel configuration
  29918. */
  29919. clone(): FresnelParameters;
  29920. /**
  29921. * Serializes the current fresnel parameters to a JSON representation.
  29922. * @return the JSON serialization
  29923. */
  29924. serialize(): any;
  29925. /**
  29926. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29927. * @param parsedFresnelParameters Define the JSON representation
  29928. * @returns the parsed parameters
  29929. */
  29930. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29931. }
  29932. }
  29933. declare module "babylonjs/Misc/decorators" {
  29934. import { Nullable } from "babylonjs/types";
  29935. import { Scene } from "babylonjs/scene";
  29936. import { IAnimatable } from "babylonjs/Misc/tools";
  29937. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29938. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29939. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29940. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29942. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29943. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29944. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29945. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29946. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29947. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29948. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29949. /**
  29950. * Decorator used to define property that can be serialized as reference to a camera
  29951. * @param sourceName defines the name of the property to decorate
  29952. */
  29953. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29954. /**
  29955. * Class used to help serialization objects
  29956. */
  29957. export class SerializationHelper {
  29958. /** hidden */
  29959. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29960. /** hidden */
  29961. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29962. /** hidden */
  29963. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29964. /** hidden */
  29965. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29966. /**
  29967. * Appends the serialized animations from the source animations
  29968. * @param source Source containing the animations
  29969. * @param destination Target to store the animations
  29970. */
  29971. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29972. /**
  29973. * Static function used to serialized a specific entity
  29974. * @param entity defines the entity to serialize
  29975. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29976. * @returns a JSON compatible object representing the serialization of the entity
  29977. */
  29978. static Serialize<T>(entity: T, serializationObject?: any): any;
  29979. /**
  29980. * Creates a new entity from a serialization data object
  29981. * @param creationFunction defines a function used to instanciated the new entity
  29982. * @param source defines the source serialization data
  29983. * @param scene defines the hosting scene
  29984. * @param rootUrl defines the root url for resources
  29985. * @returns a new entity
  29986. */
  29987. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29988. /**
  29989. * Clones an object
  29990. * @param creationFunction defines the function used to instanciate the new object
  29991. * @param source defines the source object
  29992. * @returns the cloned object
  29993. */
  29994. static Clone<T>(creationFunction: () => T, source: T): T;
  29995. /**
  29996. * Instanciates a new object based on a source one (some data will be shared between both object)
  29997. * @param creationFunction defines the function used to instanciate the new object
  29998. * @param source defines the source object
  29999. * @returns the new object
  30000. */
  30001. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30002. }
  30003. }
  30004. declare module "babylonjs/Cameras/camera" {
  30005. import { SmartArray } from "babylonjs/Misc/smartArray";
  30006. import { Observable } from "babylonjs/Misc/observable";
  30007. import { Nullable } from "babylonjs/types";
  30008. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30009. import { Scene } from "babylonjs/scene";
  30010. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30011. import { Node } from "babylonjs/node";
  30012. import { Mesh } from "babylonjs/Meshes/mesh";
  30013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30014. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30015. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30016. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30017. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30018. import { Ray } from "babylonjs/Culling/ray";
  30019. /**
  30020. * This is the base class of all the camera used in the application.
  30021. * @see http://doc.babylonjs.com/features/cameras
  30022. */
  30023. export class Camera extends Node {
  30024. /** @hidden */
  30025. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30026. /**
  30027. * This is the default projection mode used by the cameras.
  30028. * It helps recreating a feeling of perspective and better appreciate depth.
  30029. * This is the best way to simulate real life cameras.
  30030. */
  30031. static readonly PERSPECTIVE_CAMERA: number;
  30032. /**
  30033. * This helps creating camera with an orthographic mode.
  30034. * 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.
  30035. */
  30036. static readonly ORTHOGRAPHIC_CAMERA: number;
  30037. /**
  30038. * This is the default FOV mode for perspective cameras.
  30039. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30040. */
  30041. static readonly FOVMODE_VERTICAL_FIXED: number;
  30042. /**
  30043. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30044. */
  30045. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30046. /**
  30047. * This specifies ther is no need for a camera rig.
  30048. * Basically only one eye is rendered corresponding to the camera.
  30049. */
  30050. static readonly RIG_MODE_NONE: number;
  30051. /**
  30052. * Simulates a camera Rig with one blue eye and one red eye.
  30053. * This can be use with 3d blue and red glasses.
  30054. */
  30055. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30056. /**
  30057. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30058. */
  30059. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30060. /**
  30061. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30062. */
  30063. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30064. /**
  30065. * Defines that both eyes of the camera will be rendered over under each other.
  30066. */
  30067. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30068. /**
  30069. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30070. */
  30071. static readonly RIG_MODE_VR: number;
  30072. /**
  30073. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30074. */
  30075. static readonly RIG_MODE_WEBVR: number;
  30076. /**
  30077. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30078. */
  30079. static readonly RIG_MODE_CUSTOM: number;
  30080. /**
  30081. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30082. */
  30083. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30084. /**
  30085. * @hidden
  30086. * Might be removed once multiview will be a thing
  30087. */
  30088. static UseAlternateWebVRRendering: boolean;
  30089. /**
  30090. * Define the input manager associated with the camera.
  30091. */
  30092. inputs: CameraInputsManager<Camera>;
  30093. /**
  30094. * Define the current local position of the camera in the scene
  30095. */
  30096. position: Vector3;
  30097. /**
  30098. * The vector the camera should consider as up.
  30099. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30100. */
  30101. upVector: Vector3;
  30102. /**
  30103. * Define the current limit on the left side for an orthographic camera
  30104. * In scene unit
  30105. */
  30106. orthoLeft: Nullable<number>;
  30107. /**
  30108. * Define the current limit on the right side for an orthographic camera
  30109. * In scene unit
  30110. */
  30111. orthoRight: Nullable<number>;
  30112. /**
  30113. * Define the current limit on the bottom side for an orthographic camera
  30114. * In scene unit
  30115. */
  30116. orthoBottom: Nullable<number>;
  30117. /**
  30118. * Define the current limit on the top side for an orthographic camera
  30119. * In scene unit
  30120. */
  30121. orthoTop: Nullable<number>;
  30122. /**
  30123. * Field Of View is set in Radians. (default is 0.8)
  30124. */
  30125. fov: number;
  30126. /**
  30127. * Define the minimum distance the camera can see from.
  30128. * This is important to note that the depth buffer are not infinite and the closer it starts
  30129. * the more your scene might encounter depth fighting issue.
  30130. */
  30131. minZ: number;
  30132. /**
  30133. * Define the maximum distance the camera can see to.
  30134. * This is important to note that the depth buffer are not infinite and the further it end
  30135. * the more your scene might encounter depth fighting issue.
  30136. */
  30137. maxZ: number;
  30138. /**
  30139. * Define the default inertia of the camera.
  30140. * This helps giving a smooth feeling to the camera movement.
  30141. */
  30142. inertia: number;
  30143. /**
  30144. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30145. */
  30146. mode: number;
  30147. /**
  30148. * Define wether the camera is intermediate.
  30149. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30150. */
  30151. isIntermediate: boolean;
  30152. /**
  30153. * Define the viewport of the camera.
  30154. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30155. */
  30156. viewport: Viewport;
  30157. /**
  30158. * Restricts the camera to viewing objects with the same layerMask.
  30159. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30160. */
  30161. layerMask: number;
  30162. /**
  30163. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30164. */
  30165. fovMode: number;
  30166. /**
  30167. * Rig mode of the camera.
  30168. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30169. * This is normally controlled byt the camera themselves as internal use.
  30170. */
  30171. cameraRigMode: number;
  30172. /**
  30173. * Defines the distance between both "eyes" in case of a RIG
  30174. */
  30175. interaxialDistance: number;
  30176. /**
  30177. * Defines if stereoscopic rendering is done side by side or over under.
  30178. */
  30179. isStereoscopicSideBySide: boolean;
  30180. /**
  30181. * 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
  30182. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30183. * else in the scene.
  30184. */
  30185. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30186. /**
  30187. * When set, the camera will render to this render target instead of the default canvas
  30188. */
  30189. outputRenderTarget: Nullable<RenderTargetTexture>;
  30190. /**
  30191. * Observable triggered when the camera view matrix has changed.
  30192. */
  30193. onViewMatrixChangedObservable: Observable<Camera>;
  30194. /**
  30195. * Observable triggered when the camera Projection matrix has changed.
  30196. */
  30197. onProjectionMatrixChangedObservable: Observable<Camera>;
  30198. /**
  30199. * Observable triggered when the inputs have been processed.
  30200. */
  30201. onAfterCheckInputsObservable: Observable<Camera>;
  30202. /**
  30203. * Observable triggered when reset has been called and applied to the camera.
  30204. */
  30205. onRestoreStateObservable: Observable<Camera>;
  30206. /** @hidden */
  30207. _cameraRigParams: any;
  30208. /** @hidden */
  30209. _rigCameras: Camera[];
  30210. /** @hidden */
  30211. _rigPostProcess: Nullable<PostProcess>;
  30212. protected _webvrViewMatrix: Matrix;
  30213. /** @hidden */
  30214. _skipRendering: boolean;
  30215. /** @hidden */
  30216. _alternateCamera: Camera;
  30217. /** @hidden */
  30218. _projectionMatrix: Matrix;
  30219. /** @hidden */
  30220. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30221. /** @hidden */
  30222. _activeMeshes: SmartArray<AbstractMesh>;
  30223. protected _globalPosition: Vector3;
  30224. /** hidden */
  30225. _computedViewMatrix: Matrix;
  30226. private _doNotComputeProjectionMatrix;
  30227. private _transformMatrix;
  30228. private _frustumPlanes;
  30229. private _refreshFrustumPlanes;
  30230. private _storedFov;
  30231. private _stateStored;
  30232. /**
  30233. * Instantiates a new camera object.
  30234. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30235. * @see http://doc.babylonjs.com/features/cameras
  30236. * @param name Defines the name of the camera in the scene
  30237. * @param position Defines the position of the camera
  30238. * @param scene Defines the scene the camera belongs too
  30239. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30240. */
  30241. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30242. /**
  30243. * Store current camera state (fov, position, etc..)
  30244. * @returns the camera
  30245. */
  30246. storeState(): Camera;
  30247. /**
  30248. * Restores the camera state values if it has been stored. You must call storeState() first
  30249. */
  30250. protected _restoreStateValues(): boolean;
  30251. /**
  30252. * Restored camera state. You must call storeState() first.
  30253. * @returns true if restored and false otherwise
  30254. */
  30255. restoreState(): boolean;
  30256. /**
  30257. * Gets the class name of the camera.
  30258. * @returns the class name
  30259. */
  30260. getClassName(): string;
  30261. /** @hidden */
  30262. readonly _isCamera: boolean;
  30263. /**
  30264. * Gets a string representation of the camera useful for debug purpose.
  30265. * @param fullDetails Defines that a more verboe level of logging is required
  30266. * @returns the string representation
  30267. */
  30268. toString(fullDetails?: boolean): string;
  30269. /**
  30270. * Gets the current world space position of the camera.
  30271. */
  30272. readonly globalPosition: Vector3;
  30273. /**
  30274. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30275. * @returns the active meshe list
  30276. */
  30277. getActiveMeshes(): SmartArray<AbstractMesh>;
  30278. /**
  30279. * Check wether a mesh is part of the current active mesh list of the camera
  30280. * @param mesh Defines the mesh to check
  30281. * @returns true if active, false otherwise
  30282. */
  30283. isActiveMesh(mesh: Mesh): boolean;
  30284. /**
  30285. * Is this camera ready to be used/rendered
  30286. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30287. * @return true if the camera is ready
  30288. */
  30289. isReady(completeCheck?: boolean): boolean;
  30290. /** @hidden */
  30291. _initCache(): void;
  30292. /** @hidden */
  30293. _updateCache(ignoreParentClass?: boolean): void;
  30294. /** @hidden */
  30295. _isSynchronized(): boolean;
  30296. /** @hidden */
  30297. _isSynchronizedViewMatrix(): boolean;
  30298. /** @hidden */
  30299. _isSynchronizedProjectionMatrix(): boolean;
  30300. /**
  30301. * Attach the input controls to a specific dom element to get the input from.
  30302. * @param element Defines the element the controls should be listened from
  30303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30304. */
  30305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30306. /**
  30307. * Detach the current controls from the specified dom element.
  30308. * @param element Defines the element to stop listening the inputs from
  30309. */
  30310. detachControl(element: HTMLElement): void;
  30311. /**
  30312. * Update the camera state according to the different inputs gathered during the frame.
  30313. */
  30314. update(): void;
  30315. /** @hidden */
  30316. _checkInputs(): void;
  30317. /** @hidden */
  30318. readonly rigCameras: Camera[];
  30319. /**
  30320. * Gets the post process used by the rig cameras
  30321. */
  30322. readonly rigPostProcess: Nullable<PostProcess>;
  30323. /**
  30324. * Internal, gets the first post proces.
  30325. * @returns the first post process to be run on this camera.
  30326. */
  30327. _getFirstPostProcess(): Nullable<PostProcess>;
  30328. private _cascadePostProcessesToRigCams;
  30329. /**
  30330. * Attach a post process to the camera.
  30331. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30332. * @param postProcess The post process to attach to the camera
  30333. * @param insertAt The position of the post process in case several of them are in use in the scene
  30334. * @returns the position the post process has been inserted at
  30335. */
  30336. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30337. /**
  30338. * Detach a post process to the camera.
  30339. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30340. * @param postProcess The post process to detach from the camera
  30341. */
  30342. detachPostProcess(postProcess: PostProcess): void;
  30343. /**
  30344. * Gets the current world matrix of the camera
  30345. */
  30346. getWorldMatrix(): Matrix;
  30347. /** @hidden */
  30348. _getViewMatrix(): Matrix;
  30349. /**
  30350. * Gets the current view matrix of the camera.
  30351. * @param force forces the camera to recompute the matrix without looking at the cached state
  30352. * @returns the view matrix
  30353. */
  30354. getViewMatrix(force?: boolean): Matrix;
  30355. /**
  30356. * Freeze the projection matrix.
  30357. * It will prevent the cache check of the camera projection compute and can speed up perf
  30358. * if no parameter of the camera are meant to change
  30359. * @param projection Defines manually a projection if necessary
  30360. */
  30361. freezeProjectionMatrix(projection?: Matrix): void;
  30362. /**
  30363. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30364. */
  30365. unfreezeProjectionMatrix(): void;
  30366. /**
  30367. * Gets the current projection matrix of the camera.
  30368. * @param force forces the camera to recompute the matrix without looking at the cached state
  30369. * @returns the projection matrix
  30370. */
  30371. getProjectionMatrix(force?: boolean): Matrix;
  30372. /**
  30373. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30374. * @returns a Matrix
  30375. */
  30376. getTransformationMatrix(): Matrix;
  30377. private _updateFrustumPlanes;
  30378. /**
  30379. * Checks if a cullable object (mesh...) is in the camera frustum
  30380. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30381. * @param target The object to check
  30382. * @returns true if the object is in frustum otherwise false
  30383. */
  30384. isInFrustum(target: ICullable): boolean;
  30385. /**
  30386. * Checks if a cullable object (mesh...) is in the camera frustum
  30387. * Unlike isInFrustum this cheks the full bounding box
  30388. * @param target The object to check
  30389. * @returns true if the object is in frustum otherwise false
  30390. */
  30391. isCompletelyInFrustum(target: ICullable): boolean;
  30392. /**
  30393. * Gets a ray in the forward direction from the camera.
  30394. * @param length Defines the length of the ray to create
  30395. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30396. * @param origin Defines the start point of the ray which defaults to the camera position
  30397. * @returns the forward ray
  30398. */
  30399. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30400. /**
  30401. * Releases resources associated with this node.
  30402. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30403. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30404. */
  30405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30406. /**
  30407. * Gets the left camera of a rig setup in case of Rigged Camera
  30408. */
  30409. readonly leftCamera: Nullable<FreeCamera>;
  30410. /**
  30411. * Gets the right camera of a rig setup in case of Rigged Camera
  30412. */
  30413. readonly rightCamera: Nullable<FreeCamera>;
  30414. /**
  30415. * Gets the left camera target of a rig setup in case of Rigged Camera
  30416. * @returns the target position
  30417. */
  30418. getLeftTarget(): Nullable<Vector3>;
  30419. /**
  30420. * Gets the right camera target of a rig setup in case of Rigged Camera
  30421. * @returns the target position
  30422. */
  30423. getRightTarget(): Nullable<Vector3>;
  30424. /**
  30425. * @hidden
  30426. */
  30427. setCameraRigMode(mode: number, rigParams: any): void;
  30428. /** @hidden */
  30429. static _setStereoscopicRigMode(camera: Camera): void;
  30430. /** @hidden */
  30431. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30432. /** @hidden */
  30433. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30434. /** @hidden */
  30435. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30436. /** @hidden */
  30437. _getVRProjectionMatrix(): Matrix;
  30438. protected _updateCameraRotationMatrix(): void;
  30439. protected _updateWebVRCameraRotationMatrix(): void;
  30440. /**
  30441. * This function MUST be overwritten by the different WebVR cameras available.
  30442. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30443. * @hidden
  30444. */
  30445. _getWebVRProjectionMatrix(): Matrix;
  30446. /**
  30447. * This function MUST be overwritten by the different WebVR cameras available.
  30448. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30449. * @hidden
  30450. */
  30451. _getWebVRViewMatrix(): Matrix;
  30452. /** @hidden */
  30453. setCameraRigParameter(name: string, value: any): void;
  30454. /**
  30455. * needs to be overridden by children so sub has required properties to be copied
  30456. * @hidden
  30457. */
  30458. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30459. /**
  30460. * May need to be overridden by children
  30461. * @hidden
  30462. */
  30463. _updateRigCameras(): void;
  30464. /** @hidden */
  30465. _setupInputs(): void;
  30466. /**
  30467. * Serialiaze the camera setup to a json represention
  30468. * @returns the JSON representation
  30469. */
  30470. serialize(): any;
  30471. /**
  30472. * Clones the current camera.
  30473. * @param name The cloned camera name
  30474. * @returns the cloned camera
  30475. */
  30476. clone(name: string): Camera;
  30477. /**
  30478. * Gets the direction of the camera relative to a given local axis.
  30479. * @param localAxis Defines the reference axis to provide a relative direction.
  30480. * @return the direction
  30481. */
  30482. getDirection(localAxis: Vector3): Vector3;
  30483. /**
  30484. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30485. * @param localAxis Defines the reference axis to provide a relative direction.
  30486. * @param result Defines the vector to store the result in
  30487. */
  30488. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30489. /**
  30490. * Gets a camera constructor for a given camera type
  30491. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30492. * @param name The name of the camera the result will be able to instantiate
  30493. * @param scene The scene the result will construct the camera in
  30494. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30495. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30496. * @returns a factory method to construc the camera
  30497. */
  30498. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30499. /**
  30500. * Compute the world matrix of the camera.
  30501. * @returns the camera workd matrix
  30502. */
  30503. computeWorldMatrix(): Matrix;
  30504. /**
  30505. * Parse a JSON and creates the camera from the parsed information
  30506. * @param parsedCamera The JSON to parse
  30507. * @param scene The scene to instantiate the camera in
  30508. * @returns the newly constructed camera
  30509. */
  30510. static Parse(parsedCamera: any, scene: Scene): Camera;
  30511. }
  30512. }
  30513. declare module "babylonjs/Misc/tools" {
  30514. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30515. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30516. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30517. import { Observable } from "babylonjs/Misc/observable";
  30518. import { DomManagement } from "babylonjs/Misc/domManagement";
  30519. import { Camera } from "babylonjs/Cameras/camera";
  30520. import { Engine } from "babylonjs/Engines/engine";
  30521. import { Animation } from "babylonjs/Animations/animation";
  30522. /**
  30523. * Interface for any object that can request an animation frame
  30524. */
  30525. export interface ICustomAnimationFrameRequester {
  30526. /**
  30527. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30528. */
  30529. renderFunction?: Function;
  30530. /**
  30531. * Called to request the next frame to render to
  30532. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30533. */
  30534. requestAnimationFrame: Function;
  30535. /**
  30536. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30537. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30538. */
  30539. requestID?: number;
  30540. }
  30541. /**
  30542. * Interface containing an array of animations
  30543. */
  30544. export interface IAnimatable {
  30545. /**
  30546. * Array of animations
  30547. */
  30548. animations: Array<Animation>;
  30549. }
  30550. /** Interface used by value gradients (color, factor, ...) */
  30551. export interface IValueGradient {
  30552. /**
  30553. * Gets or sets the gradient value (between 0 and 1)
  30554. */
  30555. gradient: number;
  30556. }
  30557. /** Class used to store color4 gradient */
  30558. export class ColorGradient implements IValueGradient {
  30559. /**
  30560. * Gets or sets the gradient value (between 0 and 1)
  30561. */
  30562. gradient: number;
  30563. /**
  30564. * Gets or sets first associated color
  30565. */
  30566. color1: Color4;
  30567. /**
  30568. * Gets or sets second associated color
  30569. */
  30570. color2?: Color4;
  30571. /**
  30572. * Will get a color picked randomly between color1 and color2.
  30573. * If color2 is undefined then color1 will be used
  30574. * @param result defines the target Color4 to store the result in
  30575. */
  30576. getColorToRef(result: Color4): void;
  30577. }
  30578. /** Class used to store color 3 gradient */
  30579. export class Color3Gradient implements IValueGradient {
  30580. /**
  30581. * Gets or sets the gradient value (between 0 and 1)
  30582. */
  30583. gradient: number;
  30584. /**
  30585. * Gets or sets the associated color
  30586. */
  30587. color: Color3;
  30588. }
  30589. /** Class used to store factor gradient */
  30590. export class FactorGradient implements IValueGradient {
  30591. /**
  30592. * Gets or sets the gradient value (between 0 and 1)
  30593. */
  30594. gradient: number;
  30595. /**
  30596. * Gets or sets first associated factor
  30597. */
  30598. factor1: number;
  30599. /**
  30600. * Gets or sets second associated factor
  30601. */
  30602. factor2?: number;
  30603. /**
  30604. * Will get a number picked randomly between factor1 and factor2.
  30605. * If factor2 is undefined then factor1 will be used
  30606. * @returns the picked number
  30607. */
  30608. getFactor(): number;
  30609. }
  30610. /**
  30611. * @ignore
  30612. * Application error to support additional information when loading a file
  30613. */
  30614. export class LoadFileError extends Error {
  30615. /** defines the optional XHR request */
  30616. request?: XMLHttpRequest | undefined;
  30617. private static _setPrototypeOf;
  30618. /**
  30619. * Creates a new LoadFileError
  30620. * @param message defines the message of the error
  30621. * @param request defines the optional XHR request
  30622. */
  30623. constructor(message: string,
  30624. /** defines the optional XHR request */
  30625. request?: XMLHttpRequest | undefined);
  30626. }
  30627. /**
  30628. * Class used to define a retry strategy when error happens while loading assets
  30629. */
  30630. export class RetryStrategy {
  30631. /**
  30632. * Function used to defines an exponential back off strategy
  30633. * @param maxRetries defines the maximum number of retries (3 by default)
  30634. * @param baseInterval defines the interval between retries
  30635. * @returns the strategy function to use
  30636. */
  30637. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30638. }
  30639. /**
  30640. * File request interface
  30641. */
  30642. export interface IFileRequest {
  30643. /**
  30644. * Raised when the request is complete (success or error).
  30645. */
  30646. onCompleteObservable: Observable<IFileRequest>;
  30647. /**
  30648. * Aborts the request for a file.
  30649. */
  30650. abort: () => void;
  30651. }
  30652. /**
  30653. * Class containing a set of static utilities functions
  30654. */
  30655. export class Tools {
  30656. /**
  30657. * Gets or sets the base URL to use to load assets
  30658. */
  30659. static BaseUrl: string;
  30660. /**
  30661. * Enable/Disable Custom HTTP Request Headers globally.
  30662. * default = false
  30663. * @see CustomRequestHeaders
  30664. */
  30665. static UseCustomRequestHeaders: boolean;
  30666. /**
  30667. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30668. * i.e. when loading files, where the server/service expects an Authorization header.
  30669. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30670. */
  30671. static CustomRequestHeaders: {
  30672. [key: string]: string;
  30673. };
  30674. /**
  30675. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30676. */
  30677. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30678. /**
  30679. * Default behaviour for cors in the application.
  30680. * It can be a string if the expected behavior is identical in the entire app.
  30681. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30682. */
  30683. static CorsBehavior: string | ((url: string | string[]) => string);
  30684. /**
  30685. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30686. * @ignorenaming
  30687. */
  30688. static UseFallbackTexture: boolean;
  30689. /**
  30690. * Use this object to register external classes like custom textures or material
  30691. * to allow the laoders to instantiate them
  30692. */
  30693. static RegisteredExternalClasses: {
  30694. [key: string]: Object;
  30695. };
  30696. /**
  30697. * Texture content used if a texture cannot loaded
  30698. * @ignorenaming
  30699. */
  30700. static fallbackTexture: string;
  30701. /**
  30702. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30703. * @param u defines the coordinate on X axis
  30704. * @param v defines the coordinate on Y axis
  30705. * @param width defines the width of the source data
  30706. * @param height defines the height of the source data
  30707. * @param pixels defines the source byte array
  30708. * @param color defines the output color
  30709. */
  30710. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30711. /**
  30712. * Interpolates between a and b via alpha
  30713. * @param a The lower value (returned when alpha = 0)
  30714. * @param b The upper value (returned when alpha = 1)
  30715. * @param alpha The interpolation-factor
  30716. * @return The mixed value
  30717. */
  30718. static Mix(a: number, b: number, alpha: number): number;
  30719. /**
  30720. * Tries to instantiate a new object from a given class name
  30721. * @param className defines the class name to instantiate
  30722. * @returns the new object or null if the system was not able to do the instantiation
  30723. */
  30724. static Instantiate(className: string): any;
  30725. /**
  30726. * Provides a slice function that will work even on IE
  30727. * @param data defines the array to slice
  30728. * @param start defines the start of the data (optional)
  30729. * @param end defines the end of the data (optional)
  30730. * @returns the new sliced array
  30731. */
  30732. static Slice<T>(data: T, start?: number, end?: number): T;
  30733. /**
  30734. * Polyfill for setImmediate
  30735. * @param action defines the action to execute after the current execution block
  30736. */
  30737. static SetImmediate(action: () => void): void;
  30738. /**
  30739. * Function indicating if a number is an exponent of 2
  30740. * @param value defines the value to test
  30741. * @returns true if the value is an exponent of 2
  30742. */
  30743. static IsExponentOfTwo(value: number): boolean;
  30744. private static _tmpFloatArray;
  30745. /**
  30746. * Returns the nearest 32-bit single precision float representation of a Number
  30747. * @param value A Number. If the parameter is of a different type, it will get converted
  30748. * to a number or to NaN if it cannot be converted
  30749. * @returns number
  30750. */
  30751. static FloatRound(value: number): number;
  30752. /**
  30753. * Find the next highest power of two.
  30754. * @param x Number to start search from.
  30755. * @return Next highest power of two.
  30756. */
  30757. static CeilingPOT(x: number): number;
  30758. /**
  30759. * Find the next lowest power of two.
  30760. * @param x Number to start search from.
  30761. * @return Next lowest power of two.
  30762. */
  30763. static FloorPOT(x: number): number;
  30764. /**
  30765. * Find the nearest power of two.
  30766. * @param x Number to start search from.
  30767. * @return Next nearest power of two.
  30768. */
  30769. static NearestPOT(x: number): number;
  30770. /**
  30771. * Get the closest exponent of two
  30772. * @param value defines the value to approximate
  30773. * @param max defines the maximum value to return
  30774. * @param mode defines how to define the closest value
  30775. * @returns closest exponent of two of the given value
  30776. */
  30777. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30778. /**
  30779. * Extracts the filename from a path
  30780. * @param path defines the path to use
  30781. * @returns the filename
  30782. */
  30783. static GetFilename(path: string): string;
  30784. /**
  30785. * Extracts the "folder" part of a path (everything before the filename).
  30786. * @param uri The URI to extract the info from
  30787. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30788. * @returns The "folder" part of the path
  30789. */
  30790. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30791. /**
  30792. * Extracts text content from a DOM element hierarchy
  30793. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30794. */
  30795. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30796. /**
  30797. * Convert an angle in radians to degrees
  30798. * @param angle defines the angle to convert
  30799. * @returns the angle in degrees
  30800. */
  30801. static ToDegrees(angle: number): number;
  30802. /**
  30803. * Convert an angle in degrees to radians
  30804. * @param angle defines the angle to convert
  30805. * @returns the angle in radians
  30806. */
  30807. static ToRadians(angle: number): number;
  30808. /**
  30809. * Encode a buffer to a base64 string
  30810. * @param buffer defines the buffer to encode
  30811. * @returns the encoded string
  30812. */
  30813. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30814. /**
  30815. * Extracts minimum and maximum values from a list of indexed positions
  30816. * @param positions defines the positions to use
  30817. * @param indices defines the indices to the positions
  30818. * @param indexStart defines the start index
  30819. * @param indexCount defines the end index
  30820. * @param bias defines bias value to add to the result
  30821. * @return minimum and maximum values
  30822. */
  30823. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30824. minimum: Vector3;
  30825. maximum: Vector3;
  30826. };
  30827. /**
  30828. * Extracts minimum and maximum values from a list of positions
  30829. * @param positions defines the positions to use
  30830. * @param start defines the start index in the positions array
  30831. * @param count defines the number of positions to handle
  30832. * @param bias defines bias value to add to the result
  30833. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30834. * @return minimum and maximum values
  30835. */
  30836. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30837. minimum: Vector3;
  30838. maximum: Vector3;
  30839. };
  30840. /**
  30841. * Returns an array if obj is not an array
  30842. * @param obj defines the object to evaluate as an array
  30843. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30844. * @returns either obj directly if obj is an array or a new array containing obj
  30845. */
  30846. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30847. /**
  30848. * Gets the pointer prefix to use
  30849. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30850. */
  30851. static GetPointerPrefix(): string;
  30852. /**
  30853. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30854. * @param func - the function to be called
  30855. * @param requester - the object that will request the next frame. Falls back to window.
  30856. * @returns frame number
  30857. */
  30858. static QueueNewFrame(func: () => void, requester?: any): number;
  30859. /**
  30860. * Ask the browser to promote the current element to fullscreen rendering mode
  30861. * @param element defines the DOM element to promote
  30862. */
  30863. static RequestFullscreen(element: HTMLElement): void;
  30864. /**
  30865. * Asks the browser to exit fullscreen mode
  30866. */
  30867. static ExitFullscreen(): void;
  30868. /**
  30869. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30870. * @param url define the url we are trying
  30871. * @param element define the dom element where to configure the cors policy
  30872. */
  30873. static SetCorsBehavior(url: string | string[], element: {
  30874. crossOrigin: string | null;
  30875. }): void;
  30876. /**
  30877. * Removes unwanted characters from an url
  30878. * @param url defines the url to clean
  30879. * @returns the cleaned url
  30880. */
  30881. static CleanUrl(url: string): string;
  30882. /**
  30883. * Gets or sets a function used to pre-process url before using them to load assets
  30884. */
  30885. static PreprocessUrl: (url: string) => string;
  30886. /**
  30887. * Loads an image as an HTMLImageElement.
  30888. * @param input url string, ArrayBuffer, or Blob to load
  30889. * @param onLoad callback called when the image successfully loads
  30890. * @param onError callback called when the image fails to load
  30891. * @param offlineProvider offline provider for caching
  30892. * @returns the HTMLImageElement of the loaded image
  30893. */
  30894. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30895. /**
  30896. * Loads a file
  30897. * @param url url string, ArrayBuffer, or Blob to load
  30898. * @param onSuccess callback called when the file successfully loads
  30899. * @param onProgress callback called while file is loading (if the server supports this mode)
  30900. * @param offlineProvider defines the offline provider for caching
  30901. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30902. * @param onError callback called when the file fails to load
  30903. * @returns a file request object
  30904. */
  30905. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30906. /**
  30907. * Load a script (identified by an url). When the url returns, the
  30908. * content of this file is added into a new script element, attached to the DOM (body element)
  30909. * @param scriptUrl defines the url of the script to laod
  30910. * @param onSuccess defines the callback called when the script is loaded
  30911. * @param onError defines the callback to call if an error occurs
  30912. */
  30913. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30914. /**
  30915. * Loads a file from a blob
  30916. * @param fileToLoad defines the blob to use
  30917. * @param callback defines the callback to call when data is loaded
  30918. * @param progressCallback defines the callback to call during loading process
  30919. * @returns a file request object
  30920. */
  30921. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30922. /**
  30923. * Loads a file
  30924. * @param fileToLoad defines the file to load
  30925. * @param callback defines the callback to call when data is loaded
  30926. * @param progressCallBack defines the callback to call during loading process
  30927. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30928. * @returns a file request object
  30929. */
  30930. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30931. /**
  30932. * Creates a data url from a given string content
  30933. * @param content defines the content to convert
  30934. * @returns the new data url link
  30935. */
  30936. static FileAsURL(content: string): string;
  30937. /**
  30938. * Format the given number to a specific decimal format
  30939. * @param value defines the number to format
  30940. * @param decimals defines the number of decimals to use
  30941. * @returns the formatted string
  30942. */
  30943. static Format(value: number, decimals?: number): string;
  30944. /**
  30945. * Checks if a given vector is inside a specific range
  30946. * @param v defines the vector to test
  30947. * @param min defines the minimum range
  30948. * @param max defines the maximum range
  30949. */
  30950. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30951. /**
  30952. * Tries to copy an object by duplicating every property
  30953. * @param source defines the source object
  30954. * @param destination defines the target object
  30955. * @param doNotCopyList defines a list of properties to avoid
  30956. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30957. */
  30958. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30959. /**
  30960. * Gets a boolean indicating if the given object has no own property
  30961. * @param obj defines the object to test
  30962. * @returns true if object has no own property
  30963. */
  30964. static IsEmpty(obj: any): boolean;
  30965. /**
  30966. * Function used to register events at window level
  30967. * @param events defines the events to register
  30968. */
  30969. static RegisterTopRootEvents(events: {
  30970. name: string;
  30971. handler: Nullable<(e: FocusEvent) => any>;
  30972. }[]): void;
  30973. /**
  30974. * Function used to unregister events from window level
  30975. * @param events defines the events to unregister
  30976. */
  30977. static UnregisterTopRootEvents(events: {
  30978. name: string;
  30979. handler: Nullable<(e: FocusEvent) => any>;
  30980. }[]): void;
  30981. /**
  30982. * Dumps the current bound framebuffer
  30983. * @param width defines the rendering width
  30984. * @param height defines the rendering height
  30985. * @param engine defines the hosting engine
  30986. * @param successCallback defines the callback triggered once the data are available
  30987. * @param mimeType defines the mime type of the result
  30988. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30989. */
  30990. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30991. /**
  30992. * Converts the canvas data to blob.
  30993. * This acts as a polyfill for browsers not supporting the to blob function.
  30994. * @param canvas Defines the canvas to extract the data from
  30995. * @param successCallback Defines the callback triggered once the data are available
  30996. * @param mimeType Defines the mime type of the result
  30997. */
  30998. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30999. /**
  31000. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31001. * @param successCallback defines the callback triggered once the data are available
  31002. * @param mimeType defines the mime type of the result
  31003. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31004. */
  31005. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31006. /**
  31007. * Downloads a blob in the browser
  31008. * @param blob defines the blob to download
  31009. * @param fileName defines the name of the downloaded file
  31010. */
  31011. static Download(blob: Blob, fileName: string): void;
  31012. /**
  31013. * Captures a screenshot of the current rendering
  31014. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31015. * @param engine defines the rendering engine
  31016. * @param camera defines the source camera
  31017. * @param size This parameter can be set to a single number or to an object with the
  31018. * following (optional) properties: precision, width, height. If a single number is passed,
  31019. * it will be used for both width and height. If an object is passed, the screenshot size
  31020. * will be derived from the parameters. The precision property is a multiplier allowing
  31021. * rendering at a higher or lower resolution
  31022. * @param successCallback defines the callback receives a single parameter which contains the
  31023. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31024. * src parameter of an <img> to display it
  31025. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31026. * Check your browser for supported MIME types
  31027. */
  31028. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31029. /**
  31030. * Generates an image screenshot from the specified camera.
  31031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31032. * @param engine The engine to use for rendering
  31033. * @param camera The camera to use for rendering
  31034. * @param size This parameter can be set to a single number or to an object with the
  31035. * following (optional) properties: precision, width, height. If a single number is passed,
  31036. * it will be used for both width and height. If an object is passed, the screenshot size
  31037. * will be derived from the parameters. The precision property is a multiplier allowing
  31038. * rendering at a higher or lower resolution
  31039. * @param successCallback The callback receives a single parameter which contains the
  31040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31041. * src parameter of an <img> to display it
  31042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31043. * Check your browser for supported MIME types
  31044. * @param samples Texture samples (default: 1)
  31045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31046. * @param fileName A name for for the downloaded file.
  31047. */
  31048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31049. /**
  31050. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31051. * Be aware Math.random() could cause collisions, but:
  31052. * "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"
  31053. * @returns a pseudo random id
  31054. */
  31055. static RandomId(): string;
  31056. /**
  31057. * Test if the given uri is a base64 string
  31058. * @param uri The uri to test
  31059. * @return True if the uri is a base64 string or false otherwise
  31060. */
  31061. static IsBase64(uri: string): boolean;
  31062. /**
  31063. * Decode the given base64 uri.
  31064. * @param uri The uri to decode
  31065. * @return The decoded base64 data.
  31066. */
  31067. static DecodeBase64(uri: string): ArrayBuffer;
  31068. /**
  31069. * No log
  31070. */
  31071. static readonly NoneLogLevel: number;
  31072. /**
  31073. * Only message logs
  31074. */
  31075. static readonly MessageLogLevel: number;
  31076. /**
  31077. * Only warning logs
  31078. */
  31079. static readonly WarningLogLevel: number;
  31080. /**
  31081. * Only error logs
  31082. */
  31083. static readonly ErrorLogLevel: number;
  31084. /**
  31085. * All logs
  31086. */
  31087. static readonly AllLogLevel: number;
  31088. /**
  31089. * Gets a value indicating the number of loading errors
  31090. * @ignorenaming
  31091. */
  31092. static readonly errorsCount: number;
  31093. /**
  31094. * Callback called when a new log is added
  31095. */
  31096. static OnNewCacheEntry: (entry: string) => void;
  31097. /**
  31098. * Log a message to the console
  31099. * @param message defines the message to log
  31100. */
  31101. static Log(message: string): void;
  31102. /**
  31103. * Write a warning message to the console
  31104. * @param message defines the message to log
  31105. */
  31106. static Warn(message: string): void;
  31107. /**
  31108. * Write an error message to the console
  31109. * @param message defines the message to log
  31110. */
  31111. static Error(message: string): void;
  31112. /**
  31113. * Gets current log cache (list of logs)
  31114. */
  31115. static readonly LogCache: string;
  31116. /**
  31117. * Clears the log cache
  31118. */
  31119. static ClearLogCache(): void;
  31120. /**
  31121. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31122. */
  31123. static LogLevels: number;
  31124. /**
  31125. * Checks if the loaded document was accessed via `file:`-Protocol.
  31126. * @returns boolean
  31127. */
  31128. static IsFileURL(): boolean;
  31129. /**
  31130. * Checks if the window object exists
  31131. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31132. */
  31133. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31134. /**
  31135. * No performance log
  31136. */
  31137. static readonly PerformanceNoneLogLevel: number;
  31138. /**
  31139. * Use user marks to log performance
  31140. */
  31141. static readonly PerformanceUserMarkLogLevel: number;
  31142. /**
  31143. * Log performance to the console
  31144. */
  31145. static readonly PerformanceConsoleLogLevel: number;
  31146. private static _performance;
  31147. /**
  31148. * Sets the current performance log level
  31149. */
  31150. static PerformanceLogLevel: number;
  31151. private static _StartPerformanceCounterDisabled;
  31152. private static _EndPerformanceCounterDisabled;
  31153. private static _StartUserMark;
  31154. private static _EndUserMark;
  31155. private static _StartPerformanceConsole;
  31156. private static _EndPerformanceConsole;
  31157. /**
  31158. * Injects the @see CustomRequestHeaders into the given request
  31159. * @param request the request that should be used for injection
  31160. */
  31161. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31162. /**
  31163. * Starts a performance counter
  31164. */
  31165. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31166. /**
  31167. * Ends a specific performance coutner
  31168. */
  31169. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31170. /**
  31171. * Gets either window.performance.now() if supported or Date.now() else
  31172. */
  31173. static readonly Now: number;
  31174. /**
  31175. * This method will return the name of the class used to create the instance of the given object.
  31176. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31177. * @param object the object to get the class name from
  31178. * @param isType defines if the object is actually a type
  31179. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31180. */
  31181. static GetClassName(object: any, isType?: boolean): string;
  31182. /**
  31183. * Gets the first element of an array satisfying a given predicate
  31184. * @param array defines the array to browse
  31185. * @param predicate defines the predicate to use
  31186. * @returns null if not found or the element
  31187. */
  31188. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31189. /**
  31190. * This method will return the name of the full name of the class, including its owning module (if any).
  31191. * 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).
  31192. * @param object the object to get the class name from
  31193. * @param isType defines if the object is actually a type
  31194. * @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.
  31195. * @ignorenaming
  31196. */
  31197. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31198. /**
  31199. * Returns a promise that resolves after the given amount of time.
  31200. * @param delay Number of milliseconds to delay
  31201. * @returns Promise that resolves after the given amount of time
  31202. */
  31203. static DelayAsync(delay: number): Promise<void>;
  31204. /**
  31205. * Gets the current gradient from an array of IValueGradient
  31206. * @param ratio defines the current ratio to get
  31207. * @param gradients defines the array of IValueGradient
  31208. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31209. */
  31210. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31211. }
  31212. /**
  31213. * This class is used to track a performance counter which is number based.
  31214. * The user has access to many properties which give statistics of different nature.
  31215. *
  31216. * The implementer can track two kinds of Performance Counter: time and count.
  31217. * 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.
  31218. * 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.
  31219. */
  31220. export class PerfCounter {
  31221. /**
  31222. * Gets or sets a global boolean to turn on and off all the counters
  31223. */
  31224. static Enabled: boolean;
  31225. /**
  31226. * Returns the smallest value ever
  31227. */
  31228. readonly min: number;
  31229. /**
  31230. * Returns the biggest value ever
  31231. */
  31232. readonly max: number;
  31233. /**
  31234. * Returns the average value since the performance counter is running
  31235. */
  31236. readonly average: number;
  31237. /**
  31238. * Returns the average value of the last second the counter was monitored
  31239. */
  31240. readonly lastSecAverage: number;
  31241. /**
  31242. * Returns the current value
  31243. */
  31244. readonly current: number;
  31245. /**
  31246. * Gets the accumulated total
  31247. */
  31248. readonly total: number;
  31249. /**
  31250. * Gets the total value count
  31251. */
  31252. readonly count: number;
  31253. /**
  31254. * Creates a new counter
  31255. */
  31256. constructor();
  31257. /**
  31258. * Call this method to start monitoring a new frame.
  31259. * 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.
  31260. */
  31261. fetchNewFrame(): void;
  31262. /**
  31263. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31264. * @param newCount the count value to add to the monitored count
  31265. * @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.
  31266. */
  31267. addCount(newCount: number, fetchResult: boolean): void;
  31268. /**
  31269. * Start monitoring this performance counter
  31270. */
  31271. beginMonitoring(): void;
  31272. /**
  31273. * Compute the time lapsed since the previous beginMonitoring() call.
  31274. * @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
  31275. */
  31276. endMonitoring(newFrame?: boolean): void;
  31277. private _fetchResult;
  31278. private _startMonitoringTime;
  31279. private _min;
  31280. private _max;
  31281. private _average;
  31282. private _current;
  31283. private _totalValueCount;
  31284. private _totalAccumulated;
  31285. private _lastSecAverage;
  31286. private _lastSecAccumulated;
  31287. private _lastSecTime;
  31288. private _lastSecValueCount;
  31289. }
  31290. /**
  31291. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31292. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31293. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31294. * @param name The name of the class, case should be preserved
  31295. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31296. */
  31297. export function className(name: string, module?: string): (target: Object) => void;
  31298. /**
  31299. * An implementation of a loop for asynchronous functions.
  31300. */
  31301. export class AsyncLoop {
  31302. /**
  31303. * Defines the number of iterations for the loop
  31304. */
  31305. iterations: number;
  31306. /**
  31307. * Defines the current index of the loop.
  31308. */
  31309. index: number;
  31310. private _done;
  31311. private _fn;
  31312. private _successCallback;
  31313. /**
  31314. * Constructor.
  31315. * @param iterations the number of iterations.
  31316. * @param func the function to run each iteration
  31317. * @param successCallback the callback that will be called upon succesful execution
  31318. * @param offset starting offset.
  31319. */
  31320. constructor(
  31321. /**
  31322. * Defines the number of iterations for the loop
  31323. */
  31324. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31325. /**
  31326. * Execute the next iteration. Must be called after the last iteration was finished.
  31327. */
  31328. executeNext(): void;
  31329. /**
  31330. * Break the loop and run the success callback.
  31331. */
  31332. breakLoop(): void;
  31333. /**
  31334. * Create and run an async loop.
  31335. * @param iterations the number of iterations.
  31336. * @param fn the function to run each iteration
  31337. * @param successCallback the callback that will be called upon succesful execution
  31338. * @param offset starting offset.
  31339. * @returns the created async loop object
  31340. */
  31341. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31342. /**
  31343. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31344. * @param iterations total number of iterations
  31345. * @param syncedIterations number of synchronous iterations in each async iteration.
  31346. * @param fn the function to call each iteration.
  31347. * @param callback a success call back that will be called when iterating stops.
  31348. * @param breakFunction a break condition (optional)
  31349. * @param timeout timeout settings for the setTimeout function. default - 0.
  31350. * @returns the created async loop object
  31351. */
  31352. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31353. }
  31354. }
  31355. declare module "babylonjs/Collisions/collisionCoordinator" {
  31356. import { Nullable } from "babylonjs/types";
  31357. import { Scene } from "babylonjs/scene";
  31358. import { Vector3 } from "babylonjs/Maths/math";
  31359. import { Collider } from "babylonjs/Collisions/collider";
  31360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31361. /** @hidden */
  31362. export interface ICollisionCoordinator {
  31363. createCollider(): Collider;
  31364. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31365. init(scene: Scene): void;
  31366. }
  31367. /** @hidden */
  31368. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31369. private _scene;
  31370. private _scaledPosition;
  31371. private _scaledVelocity;
  31372. private _finalPosition;
  31373. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31374. createCollider(): Collider;
  31375. init(scene: Scene): void;
  31376. private _collideWithWorld;
  31377. }
  31378. }
  31379. declare module "babylonjs/Animations/animationGroup" {
  31380. import { Animatable } from "babylonjs/Animations/animatable";
  31381. import { Animation } from "babylonjs/Animations/animation";
  31382. import { Scene, IDisposable } from "babylonjs/scene";
  31383. import { Observable } from "babylonjs/Misc/observable";
  31384. import { Nullable } from "babylonjs/types";
  31385. /**
  31386. * This class defines the direct association between an animation and a target
  31387. */
  31388. export class TargetedAnimation {
  31389. /**
  31390. * Animation to perform
  31391. */
  31392. animation: Animation;
  31393. /**
  31394. * Target to animate
  31395. */
  31396. target: any;
  31397. }
  31398. /**
  31399. * Use this class to create coordinated animations on multiple targets
  31400. */
  31401. export class AnimationGroup implements IDisposable {
  31402. /** The name of the animation group */
  31403. name: string;
  31404. private _scene;
  31405. private _targetedAnimations;
  31406. private _animatables;
  31407. private _from;
  31408. private _to;
  31409. private _isStarted;
  31410. private _isPaused;
  31411. private _speedRatio;
  31412. /**
  31413. * Gets or sets the unique id of the node
  31414. */
  31415. uniqueId: number;
  31416. /**
  31417. * This observable will notify when one animation have ended
  31418. */
  31419. onAnimationEndObservable: Observable<TargetedAnimation>;
  31420. /**
  31421. * Observer raised when one animation loops
  31422. */
  31423. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31424. /**
  31425. * This observable will notify when all animations have ended.
  31426. */
  31427. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31428. /**
  31429. * This observable will notify when all animations have paused.
  31430. */
  31431. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31432. /**
  31433. * This observable will notify when all animations are playing.
  31434. */
  31435. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31436. /**
  31437. * Gets the first frame
  31438. */
  31439. readonly from: number;
  31440. /**
  31441. * Gets the last frame
  31442. */
  31443. readonly to: number;
  31444. /**
  31445. * Define if the animations are started
  31446. */
  31447. readonly isStarted: boolean;
  31448. /**
  31449. * Gets a value indicating that the current group is playing
  31450. */
  31451. readonly isPlaying: boolean;
  31452. /**
  31453. * Gets or sets the speed ratio to use for all animations
  31454. */
  31455. /**
  31456. * Gets or sets the speed ratio to use for all animations
  31457. */
  31458. speedRatio: number;
  31459. /**
  31460. * Gets the targeted animations for this animation group
  31461. */
  31462. readonly targetedAnimations: Array<TargetedAnimation>;
  31463. /**
  31464. * returning the list of animatables controlled by this animation group.
  31465. */
  31466. readonly animatables: Array<Animatable>;
  31467. /**
  31468. * Instantiates a new Animation Group.
  31469. * This helps managing several animations at once.
  31470. * @see http://doc.babylonjs.com/how_to/group
  31471. * @param name Defines the name of the group
  31472. * @param scene Defines the scene the group belongs to
  31473. */
  31474. constructor(
  31475. /** The name of the animation group */
  31476. name: string, scene?: Nullable<Scene>);
  31477. /**
  31478. * Add an animation (with its target) in the group
  31479. * @param animation defines the animation we want to add
  31480. * @param target defines the target of the animation
  31481. * @returns the TargetedAnimation object
  31482. */
  31483. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31484. /**
  31485. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31486. * It can add constant keys at begin or end
  31487. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31488. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31489. * @returns the animation group
  31490. */
  31491. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31492. /**
  31493. * Start all animations on given targets
  31494. * @param loop defines if animations must loop
  31495. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31496. * @param from defines the from key (optional)
  31497. * @param to defines the to key (optional)
  31498. * @returns the current animation group
  31499. */
  31500. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31501. /**
  31502. * Pause all animations
  31503. * @returns the animation group
  31504. */
  31505. pause(): AnimationGroup;
  31506. /**
  31507. * Play all animations to initial state
  31508. * This function will start() the animations if they were not started or will restart() them if they were paused
  31509. * @param loop defines if animations must loop
  31510. * @returns the animation group
  31511. */
  31512. play(loop?: boolean): AnimationGroup;
  31513. /**
  31514. * Reset all animations to initial state
  31515. * @returns the animation group
  31516. */
  31517. reset(): AnimationGroup;
  31518. /**
  31519. * Restart animations from key 0
  31520. * @returns the animation group
  31521. */
  31522. restart(): AnimationGroup;
  31523. /**
  31524. * Stop all animations
  31525. * @returns the animation group
  31526. */
  31527. stop(): AnimationGroup;
  31528. /**
  31529. * Set animation weight for all animatables
  31530. * @param weight defines the weight to use
  31531. * @return the animationGroup
  31532. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31533. */
  31534. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31535. /**
  31536. * Synchronize and normalize all animatables with a source animatable
  31537. * @param root defines the root animatable to synchronize with
  31538. * @return the animationGroup
  31539. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31540. */
  31541. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31542. /**
  31543. * Goes to a specific frame in this animation group
  31544. * @param frame the frame number to go to
  31545. * @return the animationGroup
  31546. */
  31547. goToFrame(frame: number): AnimationGroup;
  31548. /**
  31549. * Dispose all associated resources
  31550. */
  31551. dispose(): void;
  31552. private _checkAnimationGroupEnded;
  31553. /**
  31554. * Clone the current animation group and returns a copy
  31555. * @param newName defines the name of the new group
  31556. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31557. * @returns the new aniamtion group
  31558. */
  31559. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31560. /**
  31561. * Returns a new AnimationGroup object parsed from the source provided.
  31562. * @param parsedAnimationGroup defines the source
  31563. * @param scene defines the scene that will receive the animationGroup
  31564. * @returns a new AnimationGroup
  31565. */
  31566. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31567. /**
  31568. * Returns the string "AnimationGroup"
  31569. * @returns "AnimationGroup"
  31570. */
  31571. getClassName(): string;
  31572. /**
  31573. * Creates a detailled string about the object
  31574. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31575. * @returns a string representing the object
  31576. */
  31577. toString(fullDetails?: boolean): string;
  31578. }
  31579. }
  31580. declare module "babylonjs/scene" {
  31581. import { Nullable } from "babylonjs/types";
  31582. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31583. import { Observable } from "babylonjs/Misc/observable";
  31584. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31585. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31586. import { Geometry } from "babylonjs/Meshes/geometry";
  31587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31588. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31590. import { Mesh } from "babylonjs/Meshes/mesh";
  31591. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31592. import { Bone } from "babylonjs/Bones/bone";
  31593. import { Skeleton } from "babylonjs/Bones/skeleton";
  31594. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31595. import { Camera } from "babylonjs/Cameras/camera";
  31596. import { AbstractScene } from "babylonjs/abstractScene";
  31597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31598. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31599. import { Material } from "babylonjs/Materials/material";
  31600. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31601. import { Effect } from "babylonjs/Materials/effect";
  31602. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31603. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31604. import { Light } from "babylonjs/Lights/light";
  31605. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31606. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31607. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31608. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31609. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31610. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31611. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31612. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31613. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31614. import { Engine } from "babylonjs/Engines/engine";
  31615. import { Node } from "babylonjs/node";
  31616. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31617. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31618. import { Ray } from "babylonjs/Culling/ray";
  31619. import { Animation } from "babylonjs/Animations/animation";
  31620. import { Animatable } from "babylonjs/Animations/animatable";
  31621. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31623. import { Collider } from "babylonjs/Collisions/collider";
  31624. /**
  31625. * Define an interface for all classes that will hold resources
  31626. */
  31627. export interface IDisposable {
  31628. /**
  31629. * Releases all held resources
  31630. */
  31631. dispose(): void;
  31632. }
  31633. /** Interface defining initialization parameters for Scene class */
  31634. export interface SceneOptions {
  31635. /**
  31636. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31637. * It will improve performance when the number of geometries becomes important.
  31638. */
  31639. useGeometryUniqueIdsMap?: boolean;
  31640. /**
  31641. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31642. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31643. */
  31644. useMaterialMeshMap?: boolean;
  31645. /**
  31646. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31647. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31648. */
  31649. useClonedMeshhMap?: boolean;
  31650. }
  31651. /**
  31652. * Represents a scene to be rendered by the engine.
  31653. * @see http://doc.babylonjs.com/features/scene
  31654. */
  31655. export class Scene extends AbstractScene implements IAnimatable {
  31656. private static _uniqueIdCounter;
  31657. /** The fog is deactivated */
  31658. static readonly FOGMODE_NONE: number;
  31659. /** The fog density is following an exponential function */
  31660. static readonly FOGMODE_EXP: number;
  31661. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31662. static readonly FOGMODE_EXP2: number;
  31663. /** The fog density is following a linear function. */
  31664. static readonly FOGMODE_LINEAR: number;
  31665. /**
  31666. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31667. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31668. */
  31669. static MinDeltaTime: number;
  31670. /**
  31671. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31672. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31673. */
  31674. static MaxDeltaTime: number;
  31675. /**
  31676. * Factory used to create the default material.
  31677. * @param name The name of the material to create
  31678. * @param scene The scene to create the material for
  31679. * @returns The default material
  31680. */
  31681. static DefaultMaterialFactory(scene: Scene): Material;
  31682. /**
  31683. * Factory used to create the a collision coordinator.
  31684. * @returns The collision coordinator
  31685. */
  31686. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31687. /** @hidden */
  31688. readonly _isScene: boolean;
  31689. /**
  31690. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31691. */
  31692. autoClear: boolean;
  31693. /**
  31694. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31695. */
  31696. autoClearDepthAndStencil: boolean;
  31697. /**
  31698. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31699. */
  31700. clearColor: Color4;
  31701. /**
  31702. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31703. */
  31704. ambientColor: Color3;
  31705. /** @hidden */
  31706. _environmentBRDFTexture: BaseTexture;
  31707. /** @hidden */
  31708. protected _environmentTexture: Nullable<BaseTexture>;
  31709. /**
  31710. * Texture used in all pbr material as the reflection texture.
  31711. * As in the majority of the scene they are the same (exception for multi room and so on),
  31712. * this is easier to reference from here than from all the materials.
  31713. */
  31714. /**
  31715. * Texture used in all pbr material as the reflection texture.
  31716. * As in the majority of the scene they are the same (exception for multi room and so on),
  31717. * this is easier to set here than in all the materials.
  31718. */
  31719. environmentTexture: Nullable<BaseTexture>;
  31720. /** @hidden */
  31721. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31722. /**
  31723. * Default image processing configuration used either in the rendering
  31724. * Forward main pass or through the imageProcessingPostProcess if present.
  31725. * As in the majority of the scene they are the same (exception for multi camera),
  31726. * this is easier to reference from here than from all the materials and post process.
  31727. *
  31728. * No setter as we it is a shared configuration, you can set the values instead.
  31729. */
  31730. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31731. private _forceWireframe;
  31732. /**
  31733. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31734. */
  31735. forceWireframe: boolean;
  31736. private _forcePointsCloud;
  31737. /**
  31738. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31739. */
  31740. forcePointsCloud: boolean;
  31741. /**
  31742. * Gets or sets the active clipplane 1
  31743. */
  31744. clipPlane: Nullable<Plane>;
  31745. /**
  31746. * Gets or sets the active clipplane 2
  31747. */
  31748. clipPlane2: Nullable<Plane>;
  31749. /**
  31750. * Gets or sets the active clipplane 3
  31751. */
  31752. clipPlane3: Nullable<Plane>;
  31753. /**
  31754. * Gets or sets the active clipplane 4
  31755. */
  31756. clipPlane4: Nullable<Plane>;
  31757. /**
  31758. * Gets or sets a boolean indicating if animations are enabled
  31759. */
  31760. animationsEnabled: boolean;
  31761. private _animationPropertiesOverride;
  31762. /**
  31763. * Gets or sets the animation properties override
  31764. */
  31765. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31766. /**
  31767. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31768. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31769. */
  31770. useConstantAnimationDeltaTime: boolean;
  31771. /**
  31772. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31773. * Please note that it requires to run a ray cast through the scene on every frame
  31774. */
  31775. constantlyUpdateMeshUnderPointer: boolean;
  31776. /**
  31777. * Defines the HTML cursor to use when hovering over interactive elements
  31778. */
  31779. hoverCursor: string;
  31780. /**
  31781. * Defines the HTML default cursor to use (empty by default)
  31782. */
  31783. defaultCursor: string;
  31784. /**
  31785. * This is used to call preventDefault() on pointer down
  31786. * in order to block unwanted artifacts like system double clicks
  31787. */
  31788. preventDefaultOnPointerDown: boolean;
  31789. /**
  31790. * This is used to call preventDefault() on pointer up
  31791. * in order to block unwanted artifacts like system double clicks
  31792. */
  31793. preventDefaultOnPointerUp: boolean;
  31794. /**
  31795. * Gets or sets user defined metadata
  31796. */
  31797. metadata: any;
  31798. /**
  31799. * For internal use only. Please do not use.
  31800. */
  31801. reservedDataStore: any;
  31802. /**
  31803. * Gets the name of the plugin used to load this scene (null by default)
  31804. */
  31805. loadingPluginName: string;
  31806. /**
  31807. * Use this array to add regular expressions used to disable offline support for specific urls
  31808. */
  31809. disableOfflineSupportExceptionRules: RegExp[];
  31810. /**
  31811. * An event triggered when the scene is disposed.
  31812. */
  31813. onDisposeObservable: Observable<Scene>;
  31814. private _onDisposeObserver;
  31815. /** Sets a function to be executed when this scene is disposed. */
  31816. onDispose: () => void;
  31817. /**
  31818. * An event triggered before rendering the scene (right after animations and physics)
  31819. */
  31820. onBeforeRenderObservable: Observable<Scene>;
  31821. private _onBeforeRenderObserver;
  31822. /** Sets a function to be executed before rendering this scene */
  31823. beforeRender: Nullable<() => void>;
  31824. /**
  31825. * An event triggered after rendering the scene
  31826. */
  31827. onAfterRenderObservable: Observable<Scene>;
  31828. private _onAfterRenderObserver;
  31829. /** Sets a function to be executed after rendering this scene */
  31830. afterRender: Nullable<() => void>;
  31831. /**
  31832. * An event triggered before animating the scene
  31833. */
  31834. onBeforeAnimationsObservable: Observable<Scene>;
  31835. /**
  31836. * An event triggered after animations processing
  31837. */
  31838. onAfterAnimationsObservable: Observable<Scene>;
  31839. /**
  31840. * An event triggered before draw calls are ready to be sent
  31841. */
  31842. onBeforeDrawPhaseObservable: Observable<Scene>;
  31843. /**
  31844. * An event triggered after draw calls have been sent
  31845. */
  31846. onAfterDrawPhaseObservable: Observable<Scene>;
  31847. /**
  31848. * An event triggered when the scene is ready
  31849. */
  31850. onReadyObservable: Observable<Scene>;
  31851. /**
  31852. * An event triggered before rendering a camera
  31853. */
  31854. onBeforeCameraRenderObservable: Observable<Camera>;
  31855. private _onBeforeCameraRenderObserver;
  31856. /** Sets a function to be executed before rendering a camera*/
  31857. beforeCameraRender: () => void;
  31858. /**
  31859. * An event triggered after rendering a camera
  31860. */
  31861. onAfterCameraRenderObservable: Observable<Camera>;
  31862. private _onAfterCameraRenderObserver;
  31863. /** Sets a function to be executed after rendering a camera*/
  31864. afterCameraRender: () => void;
  31865. /**
  31866. * An event triggered when active meshes evaluation is about to start
  31867. */
  31868. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31869. /**
  31870. * An event triggered when active meshes evaluation is done
  31871. */
  31872. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31873. /**
  31874. * An event triggered when particles rendering is about to start
  31875. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31876. */
  31877. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31878. /**
  31879. * An event triggered when particles rendering is done
  31880. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31881. */
  31882. onAfterParticlesRenderingObservable: Observable<Scene>;
  31883. /**
  31884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31885. */
  31886. onDataLoadedObservable: Observable<Scene>;
  31887. /**
  31888. * An event triggered when a camera is created
  31889. */
  31890. onNewCameraAddedObservable: Observable<Camera>;
  31891. /**
  31892. * An event triggered when a camera is removed
  31893. */
  31894. onCameraRemovedObservable: Observable<Camera>;
  31895. /**
  31896. * An event triggered when a light is created
  31897. */
  31898. onNewLightAddedObservable: Observable<Light>;
  31899. /**
  31900. * An event triggered when a light is removed
  31901. */
  31902. onLightRemovedObservable: Observable<Light>;
  31903. /**
  31904. * An event triggered when a geometry is created
  31905. */
  31906. onNewGeometryAddedObservable: Observable<Geometry>;
  31907. /**
  31908. * An event triggered when a geometry is removed
  31909. */
  31910. onGeometryRemovedObservable: Observable<Geometry>;
  31911. /**
  31912. * An event triggered when a transform node is created
  31913. */
  31914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31915. /**
  31916. * An event triggered when a transform node is removed
  31917. */
  31918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31919. /**
  31920. * An event triggered when a mesh is created
  31921. */
  31922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31923. /**
  31924. * An event triggered when a mesh is removed
  31925. */
  31926. onMeshRemovedObservable: Observable<AbstractMesh>;
  31927. /**
  31928. * An event triggered when a material is created
  31929. */
  31930. onNewMaterialAddedObservable: Observable<Material>;
  31931. /**
  31932. * An event triggered when a material is removed
  31933. */
  31934. onMaterialRemovedObservable: Observable<Material>;
  31935. /**
  31936. * An event triggered when a texture is created
  31937. */
  31938. onNewTextureAddedObservable: Observable<BaseTexture>;
  31939. /**
  31940. * An event triggered when a texture is removed
  31941. */
  31942. onTextureRemovedObservable: Observable<BaseTexture>;
  31943. /**
  31944. * An event triggered when render targets are about to be rendered
  31945. * Can happen multiple times per frame.
  31946. */
  31947. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31948. /**
  31949. * An event triggered when render targets were rendered.
  31950. * Can happen multiple times per frame.
  31951. */
  31952. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31953. /**
  31954. * An event triggered before calculating deterministic simulation step
  31955. */
  31956. onBeforeStepObservable: Observable<Scene>;
  31957. /**
  31958. * An event triggered after calculating deterministic simulation step
  31959. */
  31960. onAfterStepObservable: Observable<Scene>;
  31961. /**
  31962. * An event triggered when the activeCamera property is updated
  31963. */
  31964. onActiveCameraChanged: Observable<Scene>;
  31965. /**
  31966. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31967. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31968. * 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)
  31969. */
  31970. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31971. /**
  31972. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31973. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31974. * 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)
  31975. */
  31976. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31977. /**
  31978. * This Observable will when a mesh has been imported into the scene.
  31979. */
  31980. onMeshImportedObservable: Observable<AbstractMesh>;
  31981. /** @hidden */
  31982. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31983. /**
  31984. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31985. */
  31986. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31987. /**
  31988. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31989. */
  31990. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31991. /**
  31992. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31993. */
  31994. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31995. private _onPointerMove;
  31996. private _onPointerDown;
  31997. private _onPointerUp;
  31998. /** Callback called when a pointer move is detected */
  31999. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32000. /** Callback called when a pointer down is detected */
  32001. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32002. /** Callback called when a pointer up is detected */
  32003. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32004. /** Callback called when a pointer pick is detected */
  32005. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32006. /**
  32007. * 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).
  32008. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32009. */
  32010. onPrePointerObservable: Observable<PointerInfoPre>;
  32011. /**
  32012. * Observable event triggered each time an input event is received from the rendering canvas
  32013. */
  32014. onPointerObservable: Observable<PointerInfo>;
  32015. /**
  32016. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32017. */
  32018. readonly unTranslatedPointer: Vector2;
  32019. /** The distance in pixel that you have to move to prevent some events */
  32020. static DragMovementThreshold: number;
  32021. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32022. static LongPressDelay: number;
  32023. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32024. static DoubleClickDelay: number;
  32025. /** If you need to check double click without raising a single click at first click, enable this flag */
  32026. static ExclusiveDoubleClickMode: boolean;
  32027. private _initClickEvent;
  32028. private _initActionManager;
  32029. private _delayedSimpleClick;
  32030. private _delayedSimpleClickTimeout;
  32031. private _previousDelayedSimpleClickTimeout;
  32032. private _meshPickProceed;
  32033. private _previousButtonPressed;
  32034. private _currentPickResult;
  32035. private _previousPickResult;
  32036. private _totalPointersPressed;
  32037. private _doubleClickOccured;
  32038. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32039. cameraToUseForPointers: Nullable<Camera>;
  32040. private _pointerX;
  32041. private _pointerY;
  32042. private _unTranslatedPointerX;
  32043. private _unTranslatedPointerY;
  32044. private _startingPointerPosition;
  32045. private _previousStartingPointerPosition;
  32046. private _startingPointerTime;
  32047. private _previousStartingPointerTime;
  32048. private _pointerCaptures;
  32049. private _timeAccumulator;
  32050. private _currentStepId;
  32051. private _currentInternalStep;
  32052. /** @hidden */
  32053. _mirroredCameraPosition: Nullable<Vector3>;
  32054. /**
  32055. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32056. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32057. */
  32058. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32059. /**
  32060. * Observable event triggered each time an keyboard event is received from the hosting window
  32061. */
  32062. onKeyboardObservable: Observable<KeyboardInfo>;
  32063. private _onKeyDown;
  32064. private _onKeyUp;
  32065. private _onCanvasFocusObserver;
  32066. private _onCanvasBlurObserver;
  32067. private _useRightHandedSystem;
  32068. /**
  32069. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32070. */
  32071. useRightHandedSystem: boolean;
  32072. /**
  32073. * Sets the step Id used by deterministic lock step
  32074. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32075. * @param newStepId defines the step Id
  32076. */
  32077. setStepId(newStepId: number): void;
  32078. /**
  32079. * Gets the step Id used by deterministic lock step
  32080. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32081. * @returns the step Id
  32082. */
  32083. getStepId(): number;
  32084. /**
  32085. * Gets the internal step used by deterministic lock step
  32086. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32087. * @returns the internal step
  32088. */
  32089. getInternalStep(): number;
  32090. private _fogEnabled;
  32091. /**
  32092. * Gets or sets a boolean indicating if fog is enabled on this scene
  32093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32094. * (Default is true)
  32095. */
  32096. fogEnabled: boolean;
  32097. private _fogMode;
  32098. /**
  32099. * Gets or sets the fog mode to use
  32100. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32101. * | mode | value |
  32102. * | --- | --- |
  32103. * | FOGMODE_NONE | 0 |
  32104. * | FOGMODE_EXP | 1 |
  32105. * | FOGMODE_EXP2 | 2 |
  32106. * | FOGMODE_LINEAR | 3 |
  32107. */
  32108. fogMode: number;
  32109. /**
  32110. * Gets or sets the fog color to use
  32111. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32112. * (Default is Color3(0.2, 0.2, 0.3))
  32113. */
  32114. fogColor: Color3;
  32115. /**
  32116. * Gets or sets the fog density to use
  32117. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32118. * (Default is 0.1)
  32119. */
  32120. fogDensity: number;
  32121. /**
  32122. * Gets or sets the fog start distance to use
  32123. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32124. * (Default is 0)
  32125. */
  32126. fogStart: number;
  32127. /**
  32128. * Gets or sets the fog end distance to use
  32129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32130. * (Default is 1000)
  32131. */
  32132. fogEnd: number;
  32133. private _shadowsEnabled;
  32134. /**
  32135. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32136. */
  32137. shadowsEnabled: boolean;
  32138. private _lightsEnabled;
  32139. /**
  32140. * Gets or sets a boolean indicating if lights are enabled on this scene
  32141. */
  32142. lightsEnabled: boolean;
  32143. /** All of the active cameras added to this scene. */
  32144. activeCameras: Camera[];
  32145. private _activeCamera;
  32146. /** Gets or sets the current active camera */
  32147. activeCamera: Nullable<Camera>;
  32148. private _defaultMaterial;
  32149. /** The default material used on meshes when no material is affected */
  32150. /** The default material used on meshes when no material is affected */
  32151. defaultMaterial: Material;
  32152. private _texturesEnabled;
  32153. /**
  32154. * Gets or sets a boolean indicating if textures are enabled on this scene
  32155. */
  32156. texturesEnabled: boolean;
  32157. /**
  32158. * Gets or sets a boolean indicating if particles are enabled on this scene
  32159. */
  32160. particlesEnabled: boolean;
  32161. /**
  32162. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32163. */
  32164. spritesEnabled: boolean;
  32165. private _skeletonsEnabled;
  32166. /**
  32167. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32168. */
  32169. skeletonsEnabled: boolean;
  32170. /**
  32171. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32172. */
  32173. lensFlaresEnabled: boolean;
  32174. /**
  32175. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32176. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32177. */
  32178. collisionsEnabled: boolean;
  32179. private _collisionCoordinator;
  32180. /** @hidden */
  32181. readonly collisionCoordinator: ICollisionCoordinator;
  32182. /**
  32183. * Defines the gravity applied to this scene (used only for collisions)
  32184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32185. */
  32186. gravity: Vector3;
  32187. /**
  32188. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32189. */
  32190. postProcessesEnabled: boolean;
  32191. /**
  32192. * The list of postprocesses added to the scene
  32193. */
  32194. postProcesses: PostProcess[];
  32195. /**
  32196. * Gets the current postprocess manager
  32197. */
  32198. postProcessManager: PostProcessManager;
  32199. /**
  32200. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32201. */
  32202. renderTargetsEnabled: boolean;
  32203. /**
  32204. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32205. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32206. */
  32207. dumpNextRenderTargets: boolean;
  32208. /**
  32209. * The list of user defined render targets added to the scene
  32210. */
  32211. customRenderTargets: RenderTargetTexture[];
  32212. /**
  32213. * Defines if texture loading must be delayed
  32214. * If true, textures will only be loaded when they need to be rendered
  32215. */
  32216. useDelayedTextureLoading: boolean;
  32217. /**
  32218. * Gets the list of meshes imported to the scene through SceneLoader
  32219. */
  32220. importedMeshesFiles: String[];
  32221. /**
  32222. * Gets or sets a boolean indicating if probes are enabled on this scene
  32223. */
  32224. probesEnabled: boolean;
  32225. /**
  32226. * Gets or sets the current offline provider to use to store scene data
  32227. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32228. */
  32229. offlineProvider: IOfflineProvider;
  32230. /**
  32231. * Gets or sets the action manager associated with the scene
  32232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32233. */
  32234. actionManager: AbstractActionManager;
  32235. private _meshesForIntersections;
  32236. /**
  32237. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32238. */
  32239. proceduralTexturesEnabled: boolean;
  32240. private _engine;
  32241. private _totalVertices;
  32242. /** @hidden */
  32243. _activeIndices: PerfCounter;
  32244. /** @hidden */
  32245. _activeParticles: PerfCounter;
  32246. /** @hidden */
  32247. _activeBones: PerfCounter;
  32248. private _animationRatio;
  32249. /** @hidden */
  32250. _animationTimeLast: number;
  32251. /** @hidden */
  32252. _animationTime: number;
  32253. /**
  32254. * Gets or sets a general scale for animation speed
  32255. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32256. */
  32257. animationTimeScale: number;
  32258. /** @hidden */
  32259. _cachedMaterial: Nullable<Material>;
  32260. /** @hidden */
  32261. _cachedEffect: Nullable<Effect>;
  32262. /** @hidden */
  32263. _cachedVisibility: Nullable<number>;
  32264. private _renderId;
  32265. private _frameId;
  32266. private _executeWhenReadyTimeoutId;
  32267. private _intermediateRendering;
  32268. private _viewUpdateFlag;
  32269. private _projectionUpdateFlag;
  32270. private _alternateViewUpdateFlag;
  32271. private _alternateProjectionUpdateFlag;
  32272. /** @hidden */
  32273. _toBeDisposed: Nullable<IDisposable>[];
  32274. private _activeRequests;
  32275. /** @hidden */
  32276. _pendingData: any[];
  32277. private _isDisposed;
  32278. /**
  32279. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32280. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32281. */
  32282. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32283. private _activeMeshes;
  32284. private _processedMaterials;
  32285. private _renderTargets;
  32286. /** @hidden */
  32287. _activeParticleSystems: SmartArray<IParticleSystem>;
  32288. private _activeSkeletons;
  32289. private _softwareSkinnedMeshes;
  32290. private _renderingManager;
  32291. /** @hidden */
  32292. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32293. private _transformMatrix;
  32294. private _sceneUbo;
  32295. private _alternateSceneUbo;
  32296. private _viewMatrix;
  32297. private _projectionMatrix;
  32298. private _alternateViewMatrix;
  32299. private _alternateProjectionMatrix;
  32300. private _alternateTransformMatrix;
  32301. private _useAlternateCameraConfiguration;
  32302. private _alternateRendering;
  32303. private _wheelEventName;
  32304. /** @hidden */
  32305. _forcedViewPosition: Nullable<Vector3>;
  32306. /** @hidden */
  32307. readonly _isAlternateRenderingEnabled: boolean;
  32308. private _frustumPlanes;
  32309. /**
  32310. * Gets the list of frustum planes (built from the active camera)
  32311. */
  32312. readonly frustumPlanes: Plane[];
  32313. /**
  32314. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32315. * This is useful if there are more lights that the maximum simulteanous authorized
  32316. */
  32317. requireLightSorting: boolean;
  32318. /** @hidden */
  32319. readonly useMaterialMeshMap: boolean;
  32320. /** @hidden */
  32321. readonly useClonedMeshhMap: boolean;
  32322. private _pointerOverMesh;
  32323. private _pickedDownMesh;
  32324. private _pickedUpMesh;
  32325. private _externalData;
  32326. private _uid;
  32327. /**
  32328. * @hidden
  32329. * Backing store of defined scene components.
  32330. */
  32331. _components: ISceneComponent[];
  32332. /**
  32333. * @hidden
  32334. * Backing store of defined scene components.
  32335. */
  32336. _serializableComponents: ISceneSerializableComponent[];
  32337. /**
  32338. * List of components to register on the next registration step.
  32339. */
  32340. private _transientComponents;
  32341. /**
  32342. * Registers the transient components if needed.
  32343. */
  32344. private _registerTransientComponents;
  32345. /**
  32346. * @hidden
  32347. * Add a component to the scene.
  32348. * Note that the ccomponent could be registered on th next frame if this is called after
  32349. * the register component stage.
  32350. * @param component Defines the component to add to the scene
  32351. */
  32352. _addComponent(component: ISceneComponent): void;
  32353. /**
  32354. * @hidden
  32355. * Gets a component from the scene.
  32356. * @param name defines the name of the component to retrieve
  32357. * @returns the component or null if not present
  32358. */
  32359. _getComponent(name: string): Nullable<ISceneComponent>;
  32360. /**
  32361. * @hidden
  32362. * Defines the actions happening before camera updates.
  32363. */
  32364. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32365. /**
  32366. * @hidden
  32367. * Defines the actions happening before clear the canvas.
  32368. */
  32369. _beforeClearStage: Stage<SimpleStageAction>;
  32370. /**
  32371. * @hidden
  32372. * Defines the actions when collecting render targets for the frame.
  32373. */
  32374. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32375. /**
  32376. * @hidden
  32377. * Defines the actions happening for one camera in the frame.
  32378. */
  32379. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32380. /**
  32381. * @hidden
  32382. * Defines the actions happening during the per mesh ready checks.
  32383. */
  32384. _isReadyForMeshStage: Stage<MeshStageAction>;
  32385. /**
  32386. * @hidden
  32387. * Defines the actions happening before evaluate active mesh checks.
  32388. */
  32389. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32390. /**
  32391. * @hidden
  32392. * Defines the actions happening during the evaluate sub mesh checks.
  32393. */
  32394. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32395. /**
  32396. * @hidden
  32397. * Defines the actions happening during the active mesh stage.
  32398. */
  32399. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32400. /**
  32401. * @hidden
  32402. * Defines the actions happening during the per camera render target step.
  32403. */
  32404. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32405. /**
  32406. * @hidden
  32407. * Defines the actions happening just before the active camera is drawing.
  32408. */
  32409. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32410. /**
  32411. * @hidden
  32412. * Defines the actions happening just before a render target is drawing.
  32413. */
  32414. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32415. /**
  32416. * @hidden
  32417. * Defines the actions happening just before a rendering group is drawing.
  32418. */
  32419. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32420. /**
  32421. * @hidden
  32422. * Defines the actions happening just before a mesh is drawing.
  32423. */
  32424. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32425. /**
  32426. * @hidden
  32427. * Defines the actions happening just after a mesh has been drawn.
  32428. */
  32429. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32430. /**
  32431. * @hidden
  32432. * Defines the actions happening just after a rendering group has been drawn.
  32433. */
  32434. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32435. /**
  32436. * @hidden
  32437. * Defines the actions happening just after the active camera has been drawn.
  32438. */
  32439. _afterCameraDrawStage: Stage<CameraStageAction>;
  32440. /**
  32441. * @hidden
  32442. * Defines the actions happening just after a render target has been drawn.
  32443. */
  32444. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32445. /**
  32446. * @hidden
  32447. * Defines the actions happening just after rendering all cameras and computing intersections.
  32448. */
  32449. _afterRenderStage: Stage<SimpleStageAction>;
  32450. /**
  32451. * @hidden
  32452. * Defines the actions happening when a pointer move event happens.
  32453. */
  32454. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32455. /**
  32456. * @hidden
  32457. * Defines the actions happening when a pointer down event happens.
  32458. */
  32459. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32460. /**
  32461. * @hidden
  32462. * Defines the actions happening when a pointer up event happens.
  32463. */
  32464. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32465. /**
  32466. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32467. */
  32468. private geometriesByUniqueId;
  32469. /**
  32470. * Creates a new Scene
  32471. * @param engine defines the engine to use to render this scene
  32472. * @param options defines the scene options
  32473. */
  32474. constructor(engine: Engine, options?: SceneOptions);
  32475. private _defaultMeshCandidates;
  32476. /**
  32477. * @hidden
  32478. */
  32479. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32480. private _defaultSubMeshCandidates;
  32481. /**
  32482. * @hidden
  32483. */
  32484. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32485. /**
  32486. * Sets the default candidate providers for the scene.
  32487. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32488. * and getCollidingSubMeshCandidates to their default function
  32489. */
  32490. setDefaultCandidateProviders(): void;
  32491. /**
  32492. * Gets the mesh that is currently under the pointer
  32493. */
  32494. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32495. /**
  32496. * Gets or sets the current on-screen X position of the pointer
  32497. */
  32498. pointerX: number;
  32499. /**
  32500. * Gets or sets the current on-screen Y position of the pointer
  32501. */
  32502. pointerY: number;
  32503. /**
  32504. * Gets the cached material (ie. the latest rendered one)
  32505. * @returns the cached material
  32506. */
  32507. getCachedMaterial(): Nullable<Material>;
  32508. /**
  32509. * Gets the cached effect (ie. the latest rendered one)
  32510. * @returns the cached effect
  32511. */
  32512. getCachedEffect(): Nullable<Effect>;
  32513. /**
  32514. * Gets the cached visibility state (ie. the latest rendered one)
  32515. * @returns the cached visibility state
  32516. */
  32517. getCachedVisibility(): Nullable<number>;
  32518. /**
  32519. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32520. * @param material defines the current material
  32521. * @param effect defines the current effect
  32522. * @param visibility defines the current visibility state
  32523. * @returns true if one parameter is not cached
  32524. */
  32525. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32526. /**
  32527. * Gets the engine associated with the scene
  32528. * @returns an Engine
  32529. */
  32530. getEngine(): Engine;
  32531. /**
  32532. * Gets the total number of vertices rendered per frame
  32533. * @returns the total number of vertices rendered per frame
  32534. */
  32535. getTotalVertices(): number;
  32536. /**
  32537. * Gets the performance counter for total vertices
  32538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32539. */
  32540. readonly totalVerticesPerfCounter: PerfCounter;
  32541. /**
  32542. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32543. * @returns the total number of active indices rendered per frame
  32544. */
  32545. getActiveIndices(): number;
  32546. /**
  32547. * Gets the performance counter for active indices
  32548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32549. */
  32550. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32551. /**
  32552. * Gets the total number of active particles rendered per frame
  32553. * @returns the total number of active particles rendered per frame
  32554. */
  32555. getActiveParticles(): number;
  32556. /**
  32557. * Gets the performance counter for active particles
  32558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32559. */
  32560. readonly activeParticlesPerfCounter: PerfCounter;
  32561. /**
  32562. * Gets the total number of active bones rendered per frame
  32563. * @returns the total number of active bones rendered per frame
  32564. */
  32565. getActiveBones(): number;
  32566. /**
  32567. * Gets the performance counter for active bones
  32568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32569. */
  32570. readonly activeBonesPerfCounter: PerfCounter;
  32571. /**
  32572. * Gets the array of active meshes
  32573. * @returns an array of AbstractMesh
  32574. */
  32575. getActiveMeshes(): SmartArray<AbstractMesh>;
  32576. /**
  32577. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32578. * @returns a number
  32579. */
  32580. getAnimationRatio(): number;
  32581. /**
  32582. * Gets an unique Id for the current render phase
  32583. * @returns a number
  32584. */
  32585. getRenderId(): number;
  32586. /**
  32587. * Gets an unique Id for the current frame
  32588. * @returns a number
  32589. */
  32590. getFrameId(): number;
  32591. /** Call this function if you want to manually increment the render Id*/
  32592. incrementRenderId(): void;
  32593. private _updatePointerPosition;
  32594. private _createUbo;
  32595. private _createAlternateUbo;
  32596. private _setRayOnPointerInfo;
  32597. /**
  32598. * Use this method to simulate a pointer move on a mesh
  32599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32602. * @returns the current scene
  32603. */
  32604. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32605. private _processPointerMove;
  32606. private _checkPrePointerObservable;
  32607. /**
  32608. * Use this method to simulate a pointer down on a mesh
  32609. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32610. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32611. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32612. * @returns the current scene
  32613. */
  32614. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32615. private _processPointerDown;
  32616. /**
  32617. * Use this method to simulate a pointer up on a mesh
  32618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32621. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32622. * @returns the current scene
  32623. */
  32624. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32625. private _processPointerUp;
  32626. /**
  32627. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32628. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32629. * @returns true if the pointer was captured
  32630. */
  32631. isPointerCaptured(pointerId?: number): boolean;
  32632. /** @hidden */
  32633. _isPointerSwiping(): boolean;
  32634. /**
  32635. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32636. * @param attachUp defines if you want to attach events to pointerup
  32637. * @param attachDown defines if you want to attach events to pointerdown
  32638. * @param attachMove defines if you want to attach events to pointermove
  32639. */
  32640. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32641. /** Detaches all event handlers*/
  32642. detachControl(): void;
  32643. /**
  32644. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32645. * Delay loaded resources are not taking in account
  32646. * @return true if all required resources are ready
  32647. */
  32648. isReady(): boolean;
  32649. /** Resets all cached information relative to material (including effect and visibility) */
  32650. resetCachedMaterial(): void;
  32651. /**
  32652. * Registers a function to be called before every frame render
  32653. * @param func defines the function to register
  32654. */
  32655. registerBeforeRender(func: () => void): void;
  32656. /**
  32657. * Unregisters a function called before every frame render
  32658. * @param func defines the function to unregister
  32659. */
  32660. unregisterBeforeRender(func: () => void): void;
  32661. /**
  32662. * Registers a function to be called after every frame render
  32663. * @param func defines the function to register
  32664. */
  32665. registerAfterRender(func: () => void): void;
  32666. /**
  32667. * Unregisters a function called after every frame render
  32668. * @param func defines the function to unregister
  32669. */
  32670. unregisterAfterRender(func: () => void): void;
  32671. private _executeOnceBeforeRender;
  32672. /**
  32673. * The provided function will run before render once and will be disposed afterwards.
  32674. * A timeout delay can be provided so that the function will be executed in N ms.
  32675. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32676. * @param func The function to be executed.
  32677. * @param timeout optional delay in ms
  32678. */
  32679. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32680. /** @hidden */
  32681. _addPendingData(data: any): void;
  32682. /** @hidden */
  32683. _removePendingData(data: any): void;
  32684. /**
  32685. * Returns the number of items waiting to be loaded
  32686. * @returns the number of items waiting to be loaded
  32687. */
  32688. getWaitingItemsCount(): number;
  32689. /**
  32690. * Returns a boolean indicating if the scene is still loading data
  32691. */
  32692. readonly isLoading: boolean;
  32693. /**
  32694. * Registers a function to be executed when the scene is ready
  32695. * @param {Function} func - the function to be executed
  32696. */
  32697. executeWhenReady(func: () => void): void;
  32698. /**
  32699. * Returns a promise that resolves when the scene is ready
  32700. * @returns A promise that resolves when the scene is ready
  32701. */
  32702. whenReadyAsync(): Promise<void>;
  32703. /** @hidden */
  32704. _checkIsReady(): void;
  32705. /**
  32706. * Gets all animatable attached to the scene
  32707. */
  32708. readonly animatables: Animatable[];
  32709. /**
  32710. * Resets the last animation time frame.
  32711. * Useful to override when animations start running when loading a scene for the first time.
  32712. */
  32713. resetLastAnimationTimeFrame(): void;
  32714. /** @hidden */
  32715. _switchToAlternateCameraConfiguration(active: boolean): void;
  32716. /**
  32717. * Gets the current view matrix
  32718. * @returns a Matrix
  32719. */
  32720. getViewMatrix(): Matrix;
  32721. /**
  32722. * Gets the current projection matrix
  32723. * @returns a Matrix
  32724. */
  32725. getProjectionMatrix(): Matrix;
  32726. /**
  32727. * Gets the current transform matrix
  32728. * @returns a Matrix made of View * Projection
  32729. */
  32730. getTransformMatrix(): Matrix;
  32731. /**
  32732. * Sets the current transform matrix
  32733. * @param view defines the View matrix to use
  32734. * @param projection defines the Projection matrix to use
  32735. */
  32736. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32737. /** @hidden */
  32738. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32739. /**
  32740. * Gets the uniform buffer used to store scene data
  32741. * @returns a UniformBuffer
  32742. */
  32743. getSceneUniformBuffer(): UniformBuffer;
  32744. /**
  32745. * Gets an unique (relatively to the current scene) Id
  32746. * @returns an unique number for the scene
  32747. */
  32748. getUniqueId(): number;
  32749. /**
  32750. * Add a mesh to the list of scene's meshes
  32751. * @param newMesh defines the mesh to add
  32752. * @param recursive if all child meshes should also be added to the scene
  32753. */
  32754. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32755. /**
  32756. * Remove a mesh for the list of scene's meshes
  32757. * @param toRemove defines the mesh to remove
  32758. * @param recursive if all child meshes should also be removed from the scene
  32759. * @returns the index where the mesh was in the mesh list
  32760. */
  32761. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32762. /**
  32763. * Add a transform node to the list of scene's transform nodes
  32764. * @param newTransformNode defines the transform node to add
  32765. */
  32766. addTransformNode(newTransformNode: TransformNode): void;
  32767. /**
  32768. * Remove a transform node for the list of scene's transform nodes
  32769. * @param toRemove defines the transform node to remove
  32770. * @returns the index where the transform node was in the transform node list
  32771. */
  32772. removeTransformNode(toRemove: TransformNode): number;
  32773. /**
  32774. * Remove a skeleton for the list of scene's skeletons
  32775. * @param toRemove defines the skeleton to remove
  32776. * @returns the index where the skeleton was in the skeleton list
  32777. */
  32778. removeSkeleton(toRemove: Skeleton): number;
  32779. /**
  32780. * Remove a morph target for the list of scene's morph targets
  32781. * @param toRemove defines the morph target to remove
  32782. * @returns the index where the morph target was in the morph target list
  32783. */
  32784. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32785. /**
  32786. * Remove a light for the list of scene's lights
  32787. * @param toRemove defines the light to remove
  32788. * @returns the index where the light was in the light list
  32789. */
  32790. removeLight(toRemove: Light): number;
  32791. /**
  32792. * Remove a camera for the list of scene's cameras
  32793. * @param toRemove defines the camera to remove
  32794. * @returns the index where the camera was in the camera list
  32795. */
  32796. removeCamera(toRemove: Camera): number;
  32797. /**
  32798. * Remove a particle system for the list of scene's particle systems
  32799. * @param toRemove defines the particle system to remove
  32800. * @returns the index where the particle system was in the particle system list
  32801. */
  32802. removeParticleSystem(toRemove: IParticleSystem): number;
  32803. /**
  32804. * Remove a animation for the list of scene's animations
  32805. * @param toRemove defines the animation to remove
  32806. * @returns the index where the animation was in the animation list
  32807. */
  32808. removeAnimation(toRemove: Animation): number;
  32809. /**
  32810. * Removes the given animation group from this scene.
  32811. * @param toRemove The animation group to remove
  32812. * @returns The index of the removed animation group
  32813. */
  32814. removeAnimationGroup(toRemove: AnimationGroup): number;
  32815. /**
  32816. * Removes the given multi-material from this scene.
  32817. * @param toRemove The multi-material to remove
  32818. * @returns The index of the removed multi-material
  32819. */
  32820. removeMultiMaterial(toRemove: MultiMaterial): number;
  32821. /**
  32822. * Removes the given material from this scene.
  32823. * @param toRemove The material to remove
  32824. * @returns The index of the removed material
  32825. */
  32826. removeMaterial(toRemove: Material): number;
  32827. /**
  32828. * Removes the given action manager from this scene.
  32829. * @param toRemove The action manager to remove
  32830. * @returns The index of the removed action manager
  32831. */
  32832. removeActionManager(toRemove: AbstractActionManager): number;
  32833. /**
  32834. * Removes the given texture from this scene.
  32835. * @param toRemove The texture to remove
  32836. * @returns The index of the removed texture
  32837. */
  32838. removeTexture(toRemove: BaseTexture): number;
  32839. /**
  32840. * Adds the given light to this scene
  32841. * @param newLight The light to add
  32842. */
  32843. addLight(newLight: Light): void;
  32844. /**
  32845. * Sorts the list list based on light priorities
  32846. */
  32847. sortLightsByPriority(): void;
  32848. /**
  32849. * Adds the given camera to this scene
  32850. * @param newCamera The camera to add
  32851. */
  32852. addCamera(newCamera: Camera): void;
  32853. /**
  32854. * Adds the given skeleton to this scene
  32855. * @param newSkeleton The skeleton to add
  32856. */
  32857. addSkeleton(newSkeleton: Skeleton): void;
  32858. /**
  32859. * Adds the given particle system to this scene
  32860. * @param newParticleSystem The particle system to add
  32861. */
  32862. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32863. /**
  32864. * Adds the given animation to this scene
  32865. * @param newAnimation The animation to add
  32866. */
  32867. addAnimation(newAnimation: Animation): void;
  32868. /**
  32869. * Adds the given animation group to this scene.
  32870. * @param newAnimationGroup The animation group to add
  32871. */
  32872. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32873. /**
  32874. * Adds the given multi-material to this scene
  32875. * @param newMultiMaterial The multi-material to add
  32876. */
  32877. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32878. /**
  32879. * Adds the given material to this scene
  32880. * @param newMaterial The material to add
  32881. */
  32882. addMaterial(newMaterial: Material): void;
  32883. /**
  32884. * Adds the given morph target to this scene
  32885. * @param newMorphTargetManager The morph target to add
  32886. */
  32887. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32888. /**
  32889. * Adds the given geometry to this scene
  32890. * @param newGeometry The geometry to add
  32891. */
  32892. addGeometry(newGeometry: Geometry): void;
  32893. /**
  32894. * Adds the given action manager to this scene
  32895. * @param newActionManager The action manager to add
  32896. */
  32897. addActionManager(newActionManager: AbstractActionManager): void;
  32898. /**
  32899. * Adds the given texture to this scene.
  32900. * @param newTexture The texture to add
  32901. */
  32902. addTexture(newTexture: BaseTexture): void;
  32903. /**
  32904. * Switch active camera
  32905. * @param newCamera defines the new active camera
  32906. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32907. */
  32908. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32909. /**
  32910. * sets the active camera of the scene using its ID
  32911. * @param id defines the camera's ID
  32912. * @return the new active camera or null if none found.
  32913. */
  32914. setActiveCameraByID(id: string): Nullable<Camera>;
  32915. /**
  32916. * sets the active camera of the scene using its name
  32917. * @param name defines the camera's name
  32918. * @returns the new active camera or null if none found.
  32919. */
  32920. setActiveCameraByName(name: string): Nullable<Camera>;
  32921. /**
  32922. * get an animation group using its name
  32923. * @param name defines the material's name
  32924. * @return the animation group or null if none found.
  32925. */
  32926. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32927. /**
  32928. * get a material using its id
  32929. * @param id defines the material's ID
  32930. * @return the material or null if none found.
  32931. */
  32932. getMaterialByID(id: string): Nullable<Material>;
  32933. /**
  32934. * Gets a material using its name
  32935. * @param name defines the material's name
  32936. * @return the material or null if none found.
  32937. */
  32938. getMaterialByName(name: string): Nullable<Material>;
  32939. /**
  32940. * Gets a camera using its id
  32941. * @param id defines the id to look for
  32942. * @returns the camera or null if not found
  32943. */
  32944. getCameraByID(id: string): Nullable<Camera>;
  32945. /**
  32946. * Gets a camera using its unique id
  32947. * @param uniqueId defines the unique id to look for
  32948. * @returns the camera or null if not found
  32949. */
  32950. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32951. /**
  32952. * Gets a camera using its name
  32953. * @param name defines the camera's name
  32954. * @return the camera or null if none found.
  32955. */
  32956. getCameraByName(name: string): Nullable<Camera>;
  32957. /**
  32958. * Gets a bone using its id
  32959. * @param id defines the bone's id
  32960. * @return the bone or null if not found
  32961. */
  32962. getBoneByID(id: string): Nullable<Bone>;
  32963. /**
  32964. * Gets a bone using its id
  32965. * @param name defines the bone's name
  32966. * @return the bone or null if not found
  32967. */
  32968. getBoneByName(name: string): Nullable<Bone>;
  32969. /**
  32970. * Gets a light node using its name
  32971. * @param name defines the the light's name
  32972. * @return the light or null if none found.
  32973. */
  32974. getLightByName(name: string): Nullable<Light>;
  32975. /**
  32976. * Gets a light node using its id
  32977. * @param id defines the light's id
  32978. * @return the light or null if none found.
  32979. */
  32980. getLightByID(id: string): Nullable<Light>;
  32981. /**
  32982. * Gets a light node using its scene-generated unique ID
  32983. * @param uniqueId defines the light's unique id
  32984. * @return the light or null if none found.
  32985. */
  32986. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32987. /**
  32988. * Gets a particle system by id
  32989. * @param id defines the particle system id
  32990. * @return the corresponding system or null if none found
  32991. */
  32992. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32993. /**
  32994. * Gets a geometry using its ID
  32995. * @param id defines the geometry's id
  32996. * @return the geometry or null if none found.
  32997. */
  32998. getGeometryByID(id: string): Nullable<Geometry>;
  32999. private _getGeometryByUniqueID;
  33000. /**
  33001. * Add a new geometry to this scene
  33002. * @param geometry defines the geometry to be added to the scene.
  33003. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33004. * @return a boolean defining if the geometry was added or not
  33005. */
  33006. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33007. /**
  33008. * Removes an existing geometry
  33009. * @param geometry defines the geometry to be removed from the scene
  33010. * @return a boolean defining if the geometry was removed or not
  33011. */
  33012. removeGeometry(geometry: Geometry): boolean;
  33013. /**
  33014. * Gets the list of geometries attached to the scene
  33015. * @returns an array of Geometry
  33016. */
  33017. getGeometries(): Geometry[];
  33018. /**
  33019. * Gets the first added mesh found of a given ID
  33020. * @param id defines the id to search for
  33021. * @return the mesh found or null if not found at all
  33022. */
  33023. getMeshByID(id: string): Nullable<AbstractMesh>;
  33024. /**
  33025. * Gets a list of meshes using their id
  33026. * @param id defines the id to search for
  33027. * @returns a list of meshes
  33028. */
  33029. getMeshesByID(id: string): Array<AbstractMesh>;
  33030. /**
  33031. * Gets the first added transform node found of a given ID
  33032. * @param id defines the id to search for
  33033. * @return the found transform node or null if not found at all.
  33034. */
  33035. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33036. /**
  33037. * Gets a list of transform nodes using their id
  33038. * @param id defines the id to search for
  33039. * @returns a list of transform nodes
  33040. */
  33041. getTransformNodesByID(id: string): Array<TransformNode>;
  33042. /**
  33043. * Gets a mesh with its auto-generated unique id
  33044. * @param uniqueId defines the unique id to search for
  33045. * @return the found mesh or null if not found at all.
  33046. */
  33047. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33048. /**
  33049. * Gets a the last added mesh using a given id
  33050. * @param id defines the id to search for
  33051. * @return the found mesh or null if not found at all.
  33052. */
  33053. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33054. /**
  33055. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33056. * @param id defines the id to search for
  33057. * @return the found node or null if not found at all
  33058. */
  33059. getLastEntryByID(id: string): Nullable<Node>;
  33060. /**
  33061. * Gets a node (Mesh, Camera, Light) using a given id
  33062. * @param id defines the id to search for
  33063. * @return the found node or null if not found at all
  33064. */
  33065. getNodeByID(id: string): Nullable<Node>;
  33066. /**
  33067. * Gets a node (Mesh, Camera, Light) using a given name
  33068. * @param name defines the name to search for
  33069. * @return the found node or null if not found at all.
  33070. */
  33071. getNodeByName(name: string): Nullable<Node>;
  33072. /**
  33073. * Gets a mesh using a given name
  33074. * @param name defines the name to search for
  33075. * @return the found mesh or null if not found at all.
  33076. */
  33077. getMeshByName(name: string): Nullable<AbstractMesh>;
  33078. /**
  33079. * Gets a transform node using a given name
  33080. * @param name defines the name to search for
  33081. * @return the found transform node or null if not found at all.
  33082. */
  33083. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33084. /**
  33085. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33086. * @param id defines the id to search for
  33087. * @return the found skeleton or null if not found at all.
  33088. */
  33089. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33090. /**
  33091. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33092. * @param id defines the id to search for
  33093. * @return the found skeleton or null if not found at all.
  33094. */
  33095. getSkeletonById(id: string): Nullable<Skeleton>;
  33096. /**
  33097. * Gets a skeleton using a given name
  33098. * @param name defines the name to search for
  33099. * @return the found skeleton or null if not found at all.
  33100. */
  33101. getSkeletonByName(name: string): Nullable<Skeleton>;
  33102. /**
  33103. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33104. * @param id defines the id to search for
  33105. * @return the found morph target manager or null if not found at all.
  33106. */
  33107. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33108. /**
  33109. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33110. * @param id defines the id to search for
  33111. * @return the found morph target or null if not found at all.
  33112. */
  33113. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33114. /**
  33115. * Gets a boolean indicating if the given mesh is active
  33116. * @param mesh defines the mesh to look for
  33117. * @returns true if the mesh is in the active list
  33118. */
  33119. isActiveMesh(mesh: AbstractMesh): boolean;
  33120. /**
  33121. * Return a unique id as a string which can serve as an identifier for the scene
  33122. */
  33123. readonly uid: string;
  33124. /**
  33125. * Add an externaly attached data from its key.
  33126. * This method call will fail and return false, if such key already exists.
  33127. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33128. * @param key the unique key that identifies the data
  33129. * @param data the data object to associate to the key for this Engine instance
  33130. * @return true if no such key were already present and the data was added successfully, false otherwise
  33131. */
  33132. addExternalData<T>(key: string, data: T): boolean;
  33133. /**
  33134. * Get an externaly attached data from its key
  33135. * @param key the unique key that identifies the data
  33136. * @return the associated data, if present (can be null), or undefined if not present
  33137. */
  33138. getExternalData<T>(key: string): Nullable<T>;
  33139. /**
  33140. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33141. * @param key the unique key that identifies the data
  33142. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33143. * @return the associated data, can be null if the factory returned null.
  33144. */
  33145. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33146. /**
  33147. * Remove an externaly attached data from the Engine instance
  33148. * @param key the unique key that identifies the data
  33149. * @return true if the data was successfully removed, false if it doesn't exist
  33150. */
  33151. removeExternalData(key: string): boolean;
  33152. private _evaluateSubMesh;
  33153. /**
  33154. * Clear the processed materials smart array preventing retention point in material dispose.
  33155. */
  33156. freeProcessedMaterials(): void;
  33157. private _preventFreeActiveMeshesAndRenderingGroups;
  33158. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33159. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33160. * when disposing several meshes in a row or a hierarchy of meshes.
  33161. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33162. */
  33163. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33164. /**
  33165. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33166. */
  33167. freeActiveMeshes(): void;
  33168. /**
  33169. * Clear the info related to rendering groups preventing retention points during dispose.
  33170. */
  33171. freeRenderingGroups(): void;
  33172. /** @hidden */
  33173. _isInIntermediateRendering(): boolean;
  33174. /**
  33175. * Lambda returning the list of potentially active meshes.
  33176. */
  33177. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33178. /**
  33179. * Lambda returning the list of potentially active sub meshes.
  33180. */
  33181. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33182. /**
  33183. * Lambda returning the list of potentially intersecting sub meshes.
  33184. */
  33185. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33186. /**
  33187. * Lambda returning the list of potentially colliding sub meshes.
  33188. */
  33189. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33190. private _activeMeshesFrozen;
  33191. /**
  33192. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33193. * @returns the current scene
  33194. */
  33195. freezeActiveMeshes(): Scene;
  33196. /**
  33197. * Use this function to restart evaluating active meshes on every frame
  33198. * @returns the current scene
  33199. */
  33200. unfreezeActiveMeshes(): Scene;
  33201. private _evaluateActiveMeshes;
  33202. private _activeMesh;
  33203. /**
  33204. * Update the transform matrix to update from the current active camera
  33205. * @param force defines a boolean used to force the update even if cache is up to date
  33206. */
  33207. updateTransformMatrix(force?: boolean): void;
  33208. /**
  33209. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33210. * @param alternateCamera defines the camera to use
  33211. */
  33212. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33213. /** @hidden */
  33214. _allowPostProcessClearColor: boolean;
  33215. private _renderForCamera;
  33216. private _processSubCameras;
  33217. private _checkIntersections;
  33218. /** @hidden */
  33219. _advancePhysicsEngineStep(step: number): void;
  33220. /**
  33221. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33222. */
  33223. getDeterministicFrameTime: () => number;
  33224. /** @hidden */
  33225. _animate(): void;
  33226. /**
  33227. * Render the scene
  33228. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33229. */
  33230. render(updateCameras?: boolean): void;
  33231. /**
  33232. * Freeze all materials
  33233. * A frozen material will not be updatable but should be faster to render
  33234. */
  33235. freezeMaterials(): void;
  33236. /**
  33237. * Unfreeze all materials
  33238. * A frozen material will not be updatable but should be faster to render
  33239. */
  33240. unfreezeMaterials(): void;
  33241. /**
  33242. * Releases all held ressources
  33243. */
  33244. dispose(): void;
  33245. /**
  33246. * Gets if the scene is already disposed
  33247. */
  33248. readonly isDisposed: boolean;
  33249. /**
  33250. * Call this function to reduce memory footprint of the scene.
  33251. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33252. */
  33253. clearCachedVertexData(): void;
  33254. /**
  33255. * This function will remove the local cached buffer data from texture.
  33256. * It will save memory but will prevent the texture from being rebuilt
  33257. */
  33258. cleanCachedTextureBuffer(): void;
  33259. /**
  33260. * Get the world extend vectors with an optional filter
  33261. *
  33262. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33263. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33264. */
  33265. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33266. min: Vector3;
  33267. max: Vector3;
  33268. };
  33269. /**
  33270. * Creates a ray that can be used to pick in the scene
  33271. * @param x defines the x coordinate of the origin (on-screen)
  33272. * @param y defines the y coordinate of the origin (on-screen)
  33273. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33274. * @param camera defines the camera to use for the picking
  33275. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33276. * @returns a Ray
  33277. */
  33278. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33279. /**
  33280. * Creates a ray that can be used to pick in the scene
  33281. * @param x defines the x coordinate of the origin (on-screen)
  33282. * @param y defines the y coordinate of the origin (on-screen)
  33283. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33284. * @param result defines the ray where to store the picking ray
  33285. * @param camera defines the camera to use for the picking
  33286. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33287. * @returns the current scene
  33288. */
  33289. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33290. /**
  33291. * Creates a ray that can be used to pick in the scene
  33292. * @param x defines the x coordinate of the origin (on-screen)
  33293. * @param y defines the y coordinate of the origin (on-screen)
  33294. * @param camera defines the camera to use for the picking
  33295. * @returns a Ray
  33296. */
  33297. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33298. /**
  33299. * Creates a ray that can be used to pick in the scene
  33300. * @param x defines the x coordinate of the origin (on-screen)
  33301. * @param y defines the y coordinate of the origin (on-screen)
  33302. * @param result defines the ray where to store the picking ray
  33303. * @param camera defines the camera to use for the picking
  33304. * @returns the current scene
  33305. */
  33306. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33307. /** Launch a ray to try to pick a mesh in the scene
  33308. * @param x position on screen
  33309. * @param y position on screen
  33310. * @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
  33311. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33312. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33313. * @returns a PickingInfo
  33314. */
  33315. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33316. /** Use the given ray to pick a mesh in the scene
  33317. * @param ray The ray to use to pick meshes
  33318. * @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
  33319. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33320. * @returns a PickingInfo
  33321. */
  33322. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33323. /**
  33324. * Launch a ray to try to pick a mesh in the scene
  33325. * @param x X position on screen
  33326. * @param y Y position on screen
  33327. * @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
  33328. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33329. * @returns an array of PickingInfo
  33330. */
  33331. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33332. /**
  33333. * Launch a ray to try to pick a mesh in the scene
  33334. * @param ray Ray to use
  33335. * @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
  33336. * @returns an array of PickingInfo
  33337. */
  33338. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33339. /**
  33340. * Force the value of meshUnderPointer
  33341. * @param mesh defines the mesh to use
  33342. */
  33343. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33344. /**
  33345. * Gets the mesh under the pointer
  33346. * @returns a Mesh or null if no mesh is under the pointer
  33347. */
  33348. getPointerOverMesh(): Nullable<AbstractMesh>;
  33349. /** @hidden */
  33350. _rebuildGeometries(): void;
  33351. /** @hidden */
  33352. _rebuildTextures(): void;
  33353. private _getByTags;
  33354. /**
  33355. * Get a list of meshes by tags
  33356. * @param tagsQuery defines the tags query to use
  33357. * @param forEach defines a predicate used to filter results
  33358. * @returns an array of Mesh
  33359. */
  33360. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33361. /**
  33362. * Get a list of cameras by tags
  33363. * @param tagsQuery defines the tags query to use
  33364. * @param forEach defines a predicate used to filter results
  33365. * @returns an array of Camera
  33366. */
  33367. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33368. /**
  33369. * Get a list of lights by tags
  33370. * @param tagsQuery defines the tags query to use
  33371. * @param forEach defines a predicate used to filter results
  33372. * @returns an array of Light
  33373. */
  33374. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33375. /**
  33376. * Get a list of materials by tags
  33377. * @param tagsQuery defines the tags query to use
  33378. * @param forEach defines a predicate used to filter results
  33379. * @returns an array of Material
  33380. */
  33381. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33382. /**
  33383. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33384. * This allowed control for front to back rendering or reversly depending of the special needs.
  33385. *
  33386. * @param renderingGroupId The rendering group id corresponding to its index
  33387. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33388. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33389. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33390. */
  33391. 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;
  33392. /**
  33393. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33394. *
  33395. * @param renderingGroupId The rendering group id corresponding to its index
  33396. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33397. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33398. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33399. */
  33400. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33401. /**
  33402. * Gets the current auto clear configuration for one rendering group of the rendering
  33403. * manager.
  33404. * @param index the rendering group index to get the information for
  33405. * @returns The auto clear setup for the requested rendering group
  33406. */
  33407. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33408. private _blockMaterialDirtyMechanism;
  33409. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33410. blockMaterialDirtyMechanism: boolean;
  33411. /**
  33412. * Will flag all materials as dirty to trigger new shader compilation
  33413. * @param flag defines the flag used to specify which material part must be marked as dirty
  33414. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33415. */
  33416. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33417. /** @hidden */
  33418. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33419. /** @hidden */
  33420. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33421. }
  33422. }
  33423. declare module "babylonjs/assetContainer" {
  33424. import { AbstractScene } from "babylonjs/abstractScene";
  33425. import { Scene } from "babylonjs/scene";
  33426. import { Mesh } from "babylonjs/Meshes/mesh";
  33427. /**
  33428. * Set of assets to keep when moving a scene into an asset container.
  33429. */
  33430. export class KeepAssets extends AbstractScene {
  33431. }
  33432. /**
  33433. * Container with a set of assets that can be added or removed from a scene.
  33434. */
  33435. export class AssetContainer extends AbstractScene {
  33436. /**
  33437. * The scene the AssetContainer belongs to.
  33438. */
  33439. scene: Scene;
  33440. /**
  33441. * Instantiates an AssetContainer.
  33442. * @param scene The scene the AssetContainer belongs to.
  33443. */
  33444. constructor(scene: Scene);
  33445. /**
  33446. * Adds all the assets from the container to the scene.
  33447. */
  33448. addAllToScene(): void;
  33449. /**
  33450. * Removes all the assets in the container from the scene
  33451. */
  33452. removeAllFromScene(): void;
  33453. /**
  33454. * Disposes all the assets in the container
  33455. */
  33456. dispose(): void;
  33457. private _moveAssets;
  33458. /**
  33459. * Removes all the assets contained in the scene and adds them to the container.
  33460. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33461. */
  33462. moveAllFromScene(keepAssets?: KeepAssets): void;
  33463. /**
  33464. * 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.
  33465. * @returns the root mesh
  33466. */
  33467. createRootMesh(): Mesh;
  33468. }
  33469. }
  33470. declare module "babylonjs/abstractScene" {
  33471. import { Scene } from "babylonjs/scene";
  33472. import { Nullable } from "babylonjs/types";
  33473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33474. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33475. import { Geometry } from "babylonjs/Meshes/geometry";
  33476. import { Skeleton } from "babylonjs/Bones/skeleton";
  33477. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33478. import { AssetContainer } from "babylonjs/assetContainer";
  33479. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33480. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33482. import { Material } from "babylonjs/Materials/material";
  33483. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33484. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33485. import { Camera } from "babylonjs/Cameras/camera";
  33486. import { Light } from "babylonjs/Lights/light";
  33487. import { Node } from "babylonjs/node";
  33488. import { Animation } from "babylonjs/Animations/animation";
  33489. /**
  33490. * Defines how the parser contract is defined.
  33491. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33492. */
  33493. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33494. /**
  33495. * Defines how the individual parser contract is defined.
  33496. * These parser can parse an individual asset
  33497. */
  33498. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33499. /**
  33500. * Base class of the scene acting as a container for the different elements composing a scene.
  33501. * This class is dynamically extended by the different components of the scene increasing
  33502. * flexibility and reducing coupling
  33503. */
  33504. export abstract class AbstractScene {
  33505. /**
  33506. * Stores the list of available parsers in the application.
  33507. */
  33508. private static _BabylonFileParsers;
  33509. /**
  33510. * Stores the list of available individual parsers in the application.
  33511. */
  33512. private static _IndividualBabylonFileParsers;
  33513. /**
  33514. * Adds a parser in the list of available ones
  33515. * @param name Defines the name of the parser
  33516. * @param parser Defines the parser to add
  33517. */
  33518. static AddParser(name: string, parser: BabylonFileParser): void;
  33519. /**
  33520. * Gets a general parser from the list of avaialble ones
  33521. * @param name Defines the name of the parser
  33522. * @returns the requested parser or null
  33523. */
  33524. static GetParser(name: string): Nullable<BabylonFileParser>;
  33525. /**
  33526. * Adds n individual parser in the list of available ones
  33527. * @param name Defines the name of the parser
  33528. * @param parser Defines the parser to add
  33529. */
  33530. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33531. /**
  33532. * Gets an individual parser from the list of avaialble ones
  33533. * @param name Defines the name of the parser
  33534. * @returns the requested parser or null
  33535. */
  33536. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33537. /**
  33538. * Parser json data and populate both a scene and its associated container object
  33539. * @param jsonData Defines the data to parse
  33540. * @param scene Defines the scene to parse the data for
  33541. * @param container Defines the container attached to the parsing sequence
  33542. * @param rootUrl Defines the root url of the data
  33543. */
  33544. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33545. /**
  33546. * Gets the list of root nodes (ie. nodes with no parent)
  33547. */
  33548. rootNodes: Node[];
  33549. /** All of the cameras added to this scene
  33550. * @see http://doc.babylonjs.com/babylon101/cameras
  33551. */
  33552. cameras: Camera[];
  33553. /**
  33554. * All of the lights added to this scene
  33555. * @see http://doc.babylonjs.com/babylon101/lights
  33556. */
  33557. lights: Light[];
  33558. /**
  33559. * All of the (abstract) meshes added to this scene
  33560. */
  33561. meshes: AbstractMesh[];
  33562. /**
  33563. * The list of skeletons added to the scene
  33564. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33565. */
  33566. skeletons: Skeleton[];
  33567. /**
  33568. * All of the particle systems added to this scene
  33569. * @see http://doc.babylonjs.com/babylon101/particles
  33570. */
  33571. particleSystems: IParticleSystem[];
  33572. /**
  33573. * Gets a list of Animations associated with the scene
  33574. */
  33575. animations: Animation[];
  33576. /**
  33577. * All of the animation groups added to this scene
  33578. * @see http://doc.babylonjs.com/how_to/group
  33579. */
  33580. animationGroups: AnimationGroup[];
  33581. /**
  33582. * All of the multi-materials added to this scene
  33583. * @see http://doc.babylonjs.com/how_to/multi_materials
  33584. */
  33585. multiMaterials: MultiMaterial[];
  33586. /**
  33587. * All of the materials added to this scene
  33588. * In the context of a Scene, it is not supposed to be modified manually.
  33589. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33590. * Note also that the order of the Material wihin the array is not significant and might change.
  33591. * @see http://doc.babylonjs.com/babylon101/materials
  33592. */
  33593. materials: Material[];
  33594. /**
  33595. * The list of morph target managers added to the scene
  33596. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33597. */
  33598. morphTargetManagers: MorphTargetManager[];
  33599. /**
  33600. * The list of geometries used in the scene.
  33601. */
  33602. geometries: Geometry[];
  33603. /**
  33604. * All of the tranform nodes added to this scene
  33605. * In the context of a Scene, it is not supposed to be modified manually.
  33606. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33607. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33608. * @see http://doc.babylonjs.com/how_to/transformnode
  33609. */
  33610. transformNodes: TransformNode[];
  33611. /**
  33612. * ActionManagers available on the scene.
  33613. */
  33614. actionManagers: AbstractActionManager[];
  33615. /**
  33616. * Textures to keep.
  33617. */
  33618. textures: BaseTexture[];
  33619. }
  33620. }
  33621. declare module "babylonjs/Audio/sound" {
  33622. import { Observable } from "babylonjs/Misc/observable";
  33623. import { Vector3 } from "babylonjs/Maths/math";
  33624. import { Nullable } from "babylonjs/types";
  33625. import { Scene } from "babylonjs/scene";
  33626. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33627. /**
  33628. * Defines a sound that can be played in the application.
  33629. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33631. */
  33632. export class Sound {
  33633. /**
  33634. * The name of the sound in the scene.
  33635. */
  33636. name: string;
  33637. /**
  33638. * Does the sound autoplay once loaded.
  33639. */
  33640. autoplay: boolean;
  33641. /**
  33642. * Does the sound loop after it finishes playing once.
  33643. */
  33644. loop: boolean;
  33645. /**
  33646. * Does the sound use a custom attenuation curve to simulate the falloff
  33647. * happening when the source gets further away from the camera.
  33648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33649. */
  33650. useCustomAttenuation: boolean;
  33651. /**
  33652. * The sound track id this sound belongs to.
  33653. */
  33654. soundTrackId: number;
  33655. /**
  33656. * Is this sound currently played.
  33657. */
  33658. isPlaying: boolean;
  33659. /**
  33660. * Is this sound currently paused.
  33661. */
  33662. isPaused: boolean;
  33663. /**
  33664. * Does this sound enables spatial sound.
  33665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33666. */
  33667. spatialSound: boolean;
  33668. /**
  33669. * Define the reference distance the sound should be heard perfectly.
  33670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33671. */
  33672. refDistance: number;
  33673. /**
  33674. * Define the roll off factor of spatial sounds.
  33675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33676. */
  33677. rolloffFactor: number;
  33678. /**
  33679. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33681. */
  33682. maxDistance: number;
  33683. /**
  33684. * Define the distance attenuation model the sound will follow.
  33685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33686. */
  33687. distanceModel: string;
  33688. /**
  33689. * @hidden
  33690. * Back Compat
  33691. **/
  33692. onended: () => any;
  33693. /**
  33694. * Observable event when the current playing sound finishes.
  33695. */
  33696. onEndedObservable: Observable<Sound>;
  33697. private _panningModel;
  33698. private _playbackRate;
  33699. private _streaming;
  33700. private _startTime;
  33701. private _startOffset;
  33702. private _position;
  33703. /** @hidden */
  33704. _positionInEmitterSpace: boolean;
  33705. private _localDirection;
  33706. private _volume;
  33707. private _isReadyToPlay;
  33708. private _isDirectional;
  33709. private _readyToPlayCallback;
  33710. private _audioBuffer;
  33711. private _soundSource;
  33712. private _streamingSource;
  33713. private _soundPanner;
  33714. private _soundGain;
  33715. private _inputAudioNode;
  33716. private _outputAudioNode;
  33717. private _coneInnerAngle;
  33718. private _coneOuterAngle;
  33719. private _coneOuterGain;
  33720. private _scene;
  33721. private _connectedTransformNode;
  33722. private _customAttenuationFunction;
  33723. private _registerFunc;
  33724. private _isOutputConnected;
  33725. private _htmlAudioElement;
  33726. private _urlType;
  33727. /** @hidden */
  33728. static _SceneComponentInitialization: (scene: Scene) => void;
  33729. /**
  33730. * Create a sound and attach it to a scene
  33731. * @param name Name of your sound
  33732. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33733. * @param scene defines the scene the sound belongs to
  33734. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33735. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33736. */
  33737. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33738. /**
  33739. * Release the sound and its associated resources
  33740. */
  33741. dispose(): void;
  33742. /**
  33743. * Gets if the sounds is ready to be played or not.
  33744. * @returns true if ready, otherwise false
  33745. */
  33746. isReady(): boolean;
  33747. private _soundLoaded;
  33748. /**
  33749. * Sets the data of the sound from an audiobuffer
  33750. * @param audioBuffer The audioBuffer containing the data
  33751. */
  33752. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33753. /**
  33754. * Updates the current sounds options such as maxdistance, loop...
  33755. * @param options A JSON object containing values named as the object properties
  33756. */
  33757. updateOptions(options: any): void;
  33758. private _createSpatialParameters;
  33759. private _updateSpatialParameters;
  33760. /**
  33761. * Switch the panning model to HRTF:
  33762. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33764. */
  33765. switchPanningModelToHRTF(): void;
  33766. /**
  33767. * Switch the panning model to Equal Power:
  33768. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33770. */
  33771. switchPanningModelToEqualPower(): void;
  33772. private _switchPanningModel;
  33773. /**
  33774. * Connect this sound to a sound track audio node like gain...
  33775. * @param soundTrackAudioNode the sound track audio node to connect to
  33776. */
  33777. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33778. /**
  33779. * Transform this sound into a directional source
  33780. * @param coneInnerAngle Size of the inner cone in degree
  33781. * @param coneOuterAngle Size of the outer cone in degree
  33782. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33783. */
  33784. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33785. /**
  33786. * Gets or sets the inner angle for the directional cone.
  33787. */
  33788. /**
  33789. * Gets or sets the inner angle for the directional cone.
  33790. */
  33791. directionalConeInnerAngle: number;
  33792. /**
  33793. * Gets or sets the outer angle for the directional cone.
  33794. */
  33795. /**
  33796. * Gets or sets the outer angle for the directional cone.
  33797. */
  33798. directionalConeOuterAngle: number;
  33799. /**
  33800. * Sets the position of the emitter if spatial sound is enabled
  33801. * @param newPosition Defines the new posisiton
  33802. */
  33803. setPosition(newPosition: Vector3): void;
  33804. /**
  33805. * Sets the local direction of the emitter if spatial sound is enabled
  33806. * @param newLocalDirection Defines the new local direction
  33807. */
  33808. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33809. private _updateDirection;
  33810. /** @hidden */
  33811. updateDistanceFromListener(): void;
  33812. /**
  33813. * Sets a new custom attenuation function for the sound.
  33814. * @param callback Defines the function used for the attenuation
  33815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33816. */
  33817. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33818. /**
  33819. * Play the sound
  33820. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33821. * @param offset (optional) Start the sound setting it at a specific time
  33822. */
  33823. play(time?: number, offset?: number): void;
  33824. private _onended;
  33825. /**
  33826. * Stop the sound
  33827. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33828. */
  33829. stop(time?: number): void;
  33830. /**
  33831. * Put the sound in pause
  33832. */
  33833. pause(): void;
  33834. /**
  33835. * Sets a dedicated volume for this sounds
  33836. * @param newVolume Define the new volume of the sound
  33837. * @param time Define in how long the sound should be at this value
  33838. */
  33839. setVolume(newVolume: number, time?: number): void;
  33840. /**
  33841. * Set the sound play back rate
  33842. * @param newPlaybackRate Define the playback rate the sound should be played at
  33843. */
  33844. setPlaybackRate(newPlaybackRate: number): void;
  33845. /**
  33846. * Gets the volume of the sound.
  33847. * @returns the volume of the sound
  33848. */
  33849. getVolume(): number;
  33850. /**
  33851. * Attach the sound to a dedicated mesh
  33852. * @param transformNode The transform node to connect the sound with
  33853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33854. */
  33855. attachToMesh(transformNode: TransformNode): void;
  33856. /**
  33857. * Detach the sound from the previously attached mesh
  33858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33859. */
  33860. detachFromMesh(): void;
  33861. private _onRegisterAfterWorldMatrixUpdate;
  33862. /**
  33863. * Clone the current sound in the scene.
  33864. * @returns the new sound clone
  33865. */
  33866. clone(): Nullable<Sound>;
  33867. /**
  33868. * Gets the current underlying audio buffer containing the data
  33869. * @returns the audio buffer
  33870. */
  33871. getAudioBuffer(): Nullable<AudioBuffer>;
  33872. /**
  33873. * Serializes the Sound in a JSON representation
  33874. * @returns the JSON representation of the sound
  33875. */
  33876. serialize(): any;
  33877. /**
  33878. * Parse a JSON representation of a sound to innstantiate in a given scene
  33879. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33880. * @param scene Define the scene the new parsed sound should be created in
  33881. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33882. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33883. * @returns the newly parsed sound
  33884. */
  33885. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33886. }
  33887. }
  33888. declare module "babylonjs/Actions/directAudioActions" {
  33889. import { Action } from "babylonjs/Actions/action";
  33890. import { Condition } from "babylonjs/Actions/condition";
  33891. import { Sound } from "babylonjs/Audio/sound";
  33892. /**
  33893. * This defines an action helpful to play a defined sound on a triggered action.
  33894. */
  33895. export class PlaySoundAction extends Action {
  33896. private _sound;
  33897. /**
  33898. * Instantiate the action
  33899. * @param triggerOptions defines the trigger options
  33900. * @param sound defines the sound to play
  33901. * @param condition defines the trigger related conditions
  33902. */
  33903. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33904. /** @hidden */
  33905. _prepare(): void;
  33906. /**
  33907. * Execute the action and play the sound.
  33908. */
  33909. execute(): void;
  33910. /**
  33911. * Serializes the actions and its related information.
  33912. * @param parent defines the object to serialize in
  33913. * @returns the serialized object
  33914. */
  33915. serialize(parent: any): any;
  33916. }
  33917. /**
  33918. * This defines an action helpful to stop a defined sound on a triggered action.
  33919. */
  33920. export class StopSoundAction extends Action {
  33921. private _sound;
  33922. /**
  33923. * Instantiate the action
  33924. * @param triggerOptions defines the trigger options
  33925. * @param sound defines the sound to stop
  33926. * @param condition defines the trigger related conditions
  33927. */
  33928. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33929. /** @hidden */
  33930. _prepare(): void;
  33931. /**
  33932. * Execute the action and stop the sound.
  33933. */
  33934. execute(): void;
  33935. /**
  33936. * Serializes the actions and its related information.
  33937. * @param parent defines the object to serialize in
  33938. * @returns the serialized object
  33939. */
  33940. serialize(parent: any): any;
  33941. }
  33942. }
  33943. declare module "babylonjs/Actions/interpolateValueAction" {
  33944. import { Action } from "babylonjs/Actions/action";
  33945. import { Condition } from "babylonjs/Actions/condition";
  33946. import { Observable } from "babylonjs/Misc/observable";
  33947. /**
  33948. * This defines an action responsible to change the value of a property
  33949. * by interpolating between its current value and the newly set one once triggered.
  33950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33951. */
  33952. export class InterpolateValueAction extends Action {
  33953. /**
  33954. * Defines the path of the property where the value should be interpolated
  33955. */
  33956. propertyPath: string;
  33957. /**
  33958. * Defines the target value at the end of the interpolation.
  33959. */
  33960. value: any;
  33961. /**
  33962. * Defines the time it will take for the property to interpolate to the value.
  33963. */
  33964. duration: number;
  33965. /**
  33966. * Defines if the other scene animations should be stopped when the action has been triggered
  33967. */
  33968. stopOtherAnimations?: boolean;
  33969. /**
  33970. * Defines a callback raised once the interpolation animation has been done.
  33971. */
  33972. onInterpolationDone?: () => void;
  33973. /**
  33974. * Observable triggered once the interpolation animation has been done.
  33975. */
  33976. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33977. private _target;
  33978. private _effectiveTarget;
  33979. private _property;
  33980. /**
  33981. * Instantiate the action
  33982. * @param triggerOptions defines the trigger options
  33983. * @param target defines the object containing the value to interpolate
  33984. * @param propertyPath defines the path to the property in the target object
  33985. * @param value defines the target value at the end of the interpolation
  33986. * @param duration deines the time it will take for the property to interpolate to the value.
  33987. * @param condition defines the trigger related conditions
  33988. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33989. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33990. */
  33991. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33992. /** @hidden */
  33993. _prepare(): void;
  33994. /**
  33995. * Execute the action starts the value interpolation.
  33996. */
  33997. execute(): void;
  33998. /**
  33999. * Serializes the actions and its related information.
  34000. * @param parent defines the object to serialize in
  34001. * @returns the serialized object
  34002. */
  34003. serialize(parent: any): any;
  34004. }
  34005. }
  34006. declare module "babylonjs/Actions/index" {
  34007. export * from "babylonjs/Actions/action";
  34008. export * from "babylonjs/Actions/actionEvent";
  34009. export * from "babylonjs/Actions/actionManager";
  34010. export * from "babylonjs/Actions/condition";
  34011. export * from "babylonjs/Actions/directActions";
  34012. export * from "babylonjs/Actions/directAudioActions";
  34013. export * from "babylonjs/Actions/interpolateValueAction";
  34014. }
  34015. declare module "babylonjs/Animations/index" {
  34016. export * from "babylonjs/Animations/animatable";
  34017. export * from "babylonjs/Animations/animation";
  34018. export * from "babylonjs/Animations/animationGroup";
  34019. export * from "babylonjs/Animations/animationPropertiesOverride";
  34020. export * from "babylonjs/Animations/easing";
  34021. export * from "babylonjs/Animations/runtimeAnimation";
  34022. export * from "babylonjs/Animations/animationEvent";
  34023. export * from "babylonjs/Animations/animationGroup";
  34024. export * from "babylonjs/Animations/animationKey";
  34025. export * from "babylonjs/Animations/animationRange";
  34026. }
  34027. declare module "babylonjs/Audio/soundTrack" {
  34028. import { Sound } from "babylonjs/Audio/sound";
  34029. import { Analyser } from "babylonjs/Audio/analyser";
  34030. import { Scene } from "babylonjs/scene";
  34031. /**
  34032. * Options allowed during the creation of a sound track.
  34033. */
  34034. export interface ISoundTrackOptions {
  34035. /**
  34036. * The volume the sound track should take during creation
  34037. */
  34038. volume?: number;
  34039. /**
  34040. * Define if the sound track is the main sound track of the scene
  34041. */
  34042. mainTrack?: boolean;
  34043. }
  34044. /**
  34045. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34046. * It will be also used in a future release to apply effects on a specific track.
  34047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34048. */
  34049. export class SoundTrack {
  34050. /**
  34051. * The unique identifier of the sound track in the scene.
  34052. */
  34053. id: number;
  34054. /**
  34055. * The list of sounds included in the sound track.
  34056. */
  34057. soundCollection: Array<Sound>;
  34058. private _outputAudioNode;
  34059. private _scene;
  34060. private _isMainTrack;
  34061. private _connectedAnalyser;
  34062. private _options;
  34063. private _isInitialized;
  34064. /**
  34065. * Creates a new sound track.
  34066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34067. * @param scene Define the scene the sound track belongs to
  34068. * @param options
  34069. */
  34070. constructor(scene: Scene, options?: ISoundTrackOptions);
  34071. private _initializeSoundTrackAudioGraph;
  34072. /**
  34073. * Release the sound track and its associated resources
  34074. */
  34075. dispose(): void;
  34076. /**
  34077. * Adds a sound to this sound track
  34078. * @param sound define the cound to add
  34079. * @ignoreNaming
  34080. */
  34081. AddSound(sound: Sound): void;
  34082. /**
  34083. * Removes a sound to this sound track
  34084. * @param sound define the cound to remove
  34085. * @ignoreNaming
  34086. */
  34087. RemoveSound(sound: Sound): void;
  34088. /**
  34089. * Set a global volume for the full sound track.
  34090. * @param newVolume Define the new volume of the sound track
  34091. */
  34092. setVolume(newVolume: number): void;
  34093. /**
  34094. * Switch the panning model to HRTF:
  34095. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34097. */
  34098. switchPanningModelToHRTF(): void;
  34099. /**
  34100. * Switch the panning model to Equal Power:
  34101. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34103. */
  34104. switchPanningModelToEqualPower(): void;
  34105. /**
  34106. * Connect the sound track to an audio analyser allowing some amazing
  34107. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34109. * @param analyser The analyser to connect to the engine
  34110. */
  34111. connectToAnalyser(analyser: Analyser): void;
  34112. }
  34113. }
  34114. declare module "babylonjs/Audio/audioSceneComponent" {
  34115. import { Sound } from "babylonjs/Audio/sound";
  34116. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34117. import { Nullable } from "babylonjs/types";
  34118. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34119. import { Scene } from "babylonjs/scene";
  34120. import { AbstractScene } from "babylonjs/abstractScene";
  34121. module "babylonjs/abstractScene" {
  34122. interface AbstractScene {
  34123. /**
  34124. * The list of sounds used in the scene.
  34125. */
  34126. sounds: Nullable<Array<Sound>>;
  34127. }
  34128. }
  34129. module "babylonjs/scene" {
  34130. interface Scene {
  34131. /**
  34132. * @hidden
  34133. * Backing field
  34134. */
  34135. _mainSoundTrack: SoundTrack;
  34136. /**
  34137. * The main sound track played by the scene.
  34138. * It cotains your primary collection of sounds.
  34139. */
  34140. mainSoundTrack: SoundTrack;
  34141. /**
  34142. * The list of sound tracks added to the scene
  34143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34144. */
  34145. soundTracks: Nullable<Array<SoundTrack>>;
  34146. /**
  34147. * Gets a sound using a given name
  34148. * @param name defines the name to search for
  34149. * @return the found sound or null if not found at all.
  34150. */
  34151. getSoundByName(name: string): Nullable<Sound>;
  34152. /**
  34153. * Gets or sets if audio support is enabled
  34154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34155. */
  34156. audioEnabled: boolean;
  34157. /**
  34158. * Gets or sets if audio will be output to headphones
  34159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34160. */
  34161. headphone: boolean;
  34162. }
  34163. }
  34164. /**
  34165. * Defines the sound scene component responsible to manage any sounds
  34166. * in a given scene.
  34167. */
  34168. export class AudioSceneComponent implements ISceneSerializableComponent {
  34169. /**
  34170. * The component name helpfull to identify the component in the list of scene components.
  34171. */
  34172. readonly name: string;
  34173. /**
  34174. * The scene the component belongs to.
  34175. */
  34176. scene: Scene;
  34177. private _audioEnabled;
  34178. /**
  34179. * Gets whether audio is enabled or not.
  34180. * Please use related enable/disable method to switch state.
  34181. */
  34182. readonly audioEnabled: boolean;
  34183. private _headphone;
  34184. /**
  34185. * Gets whether audio is outputing to headphone or not.
  34186. * Please use the according Switch methods to change output.
  34187. */
  34188. readonly headphone: boolean;
  34189. /**
  34190. * Creates a new instance of the component for the given scene
  34191. * @param scene Defines the scene to register the component in
  34192. */
  34193. constructor(scene: Scene);
  34194. /**
  34195. * Registers the component in a given scene
  34196. */
  34197. register(): void;
  34198. /**
  34199. * Rebuilds the elements related to this component in case of
  34200. * context lost for instance.
  34201. */
  34202. rebuild(): void;
  34203. /**
  34204. * Serializes the component data to the specified json object
  34205. * @param serializationObject The object to serialize to
  34206. */
  34207. serialize(serializationObject: any): void;
  34208. /**
  34209. * Adds all the element from the container to the scene
  34210. * @param container the container holding the elements
  34211. */
  34212. addFromContainer(container: AbstractScene): void;
  34213. /**
  34214. * Removes all the elements in the container from the scene
  34215. * @param container contains the elements to remove
  34216. */
  34217. removeFromContainer(container: AbstractScene): void;
  34218. /**
  34219. * Disposes the component and the associated ressources.
  34220. */
  34221. dispose(): void;
  34222. /**
  34223. * Disables audio in the associated scene.
  34224. */
  34225. disableAudio(): void;
  34226. /**
  34227. * Enables audio in the associated scene.
  34228. */
  34229. enableAudio(): void;
  34230. /**
  34231. * Switch audio to headphone output.
  34232. */
  34233. switchAudioModeForHeadphones(): void;
  34234. /**
  34235. * Switch audio to normal speakers.
  34236. */
  34237. switchAudioModeForNormalSpeakers(): void;
  34238. private _afterRender;
  34239. }
  34240. }
  34241. declare module "babylonjs/Audio/weightedsound" {
  34242. import { Sound } from "babylonjs/Audio/sound";
  34243. /**
  34244. * Wraps one or more Sound objects and selects one with random weight for playback.
  34245. */
  34246. export class WeightedSound {
  34247. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34248. loop: boolean;
  34249. private _coneInnerAngle;
  34250. private _coneOuterAngle;
  34251. private _volume;
  34252. /** A Sound is currently playing. */
  34253. isPlaying: boolean;
  34254. /** A Sound is currently paused. */
  34255. isPaused: boolean;
  34256. private _sounds;
  34257. private _weights;
  34258. private _currentIndex?;
  34259. /**
  34260. * Creates a new WeightedSound from the list of sounds given.
  34261. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34262. * @param sounds Array of Sounds that will be selected from.
  34263. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34264. */
  34265. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34266. /**
  34267. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34268. */
  34269. /**
  34270. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34271. */
  34272. directionalConeInnerAngle: number;
  34273. /**
  34274. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34275. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34276. */
  34277. /**
  34278. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34279. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34280. */
  34281. directionalConeOuterAngle: number;
  34282. /**
  34283. * Playback volume.
  34284. */
  34285. /**
  34286. * Playback volume.
  34287. */
  34288. volume: number;
  34289. private _onended;
  34290. /**
  34291. * Suspend playback
  34292. */
  34293. pause(): void;
  34294. /**
  34295. * Stop playback
  34296. */
  34297. stop(): void;
  34298. /**
  34299. * Start playback.
  34300. * @param startOffset Position the clip head at a specific time in seconds.
  34301. */
  34302. play(startOffset?: number): void;
  34303. }
  34304. }
  34305. declare module "babylonjs/Audio/index" {
  34306. export * from "babylonjs/Audio/analyser";
  34307. export * from "babylonjs/Audio/audioEngine";
  34308. export * from "babylonjs/Audio/audioSceneComponent";
  34309. export * from "babylonjs/Audio/sound";
  34310. export * from "babylonjs/Audio/soundTrack";
  34311. export * from "babylonjs/Audio/weightedsound";
  34312. }
  34313. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34314. import { Behavior } from "babylonjs/Behaviors/behavior";
  34315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34316. import { BackEase } from "babylonjs/Animations/easing";
  34317. /**
  34318. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34320. */
  34321. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34322. /**
  34323. * Gets the name of the behavior.
  34324. */
  34325. readonly name: string;
  34326. /**
  34327. * The easing function used by animations
  34328. */
  34329. static EasingFunction: BackEase;
  34330. /**
  34331. * The easing mode used by animations
  34332. */
  34333. static EasingMode: number;
  34334. /**
  34335. * The duration of the animation, in milliseconds
  34336. */
  34337. transitionDuration: number;
  34338. /**
  34339. * Length of the distance animated by the transition when lower radius is reached
  34340. */
  34341. lowerRadiusTransitionRange: number;
  34342. /**
  34343. * Length of the distance animated by the transition when upper radius is reached
  34344. */
  34345. upperRadiusTransitionRange: number;
  34346. private _autoTransitionRange;
  34347. /**
  34348. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34349. */
  34350. /**
  34351. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34352. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34353. */
  34354. autoTransitionRange: boolean;
  34355. private _attachedCamera;
  34356. private _onAfterCheckInputsObserver;
  34357. private _onMeshTargetChangedObserver;
  34358. /**
  34359. * Initializes the behavior.
  34360. */
  34361. init(): void;
  34362. /**
  34363. * Attaches the behavior to its arc rotate camera.
  34364. * @param camera Defines the camera to attach the behavior to
  34365. */
  34366. attach(camera: ArcRotateCamera): void;
  34367. /**
  34368. * Detaches the behavior from its current arc rotate camera.
  34369. */
  34370. detach(): void;
  34371. private _radiusIsAnimating;
  34372. private _radiusBounceTransition;
  34373. private _animatables;
  34374. private _cachedWheelPrecision;
  34375. /**
  34376. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34377. * @param radiusLimit The limit to check against.
  34378. * @return Bool to indicate if at limit.
  34379. */
  34380. private _isRadiusAtLimit;
  34381. /**
  34382. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34383. * @param radiusDelta The delta by which to animate to. Can be negative.
  34384. */
  34385. private _applyBoundRadiusAnimation;
  34386. /**
  34387. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34388. */
  34389. protected _clearAnimationLocks(): void;
  34390. /**
  34391. * Stops and removes all animations that have been applied to the camera
  34392. */
  34393. stopAllAnimations(): void;
  34394. }
  34395. }
  34396. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34397. import { Behavior } from "babylonjs/Behaviors/behavior";
  34398. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34399. import { ExponentialEase } from "babylonjs/Animations/easing";
  34400. import { Nullable } from "babylonjs/types";
  34401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34402. import { Vector3 } from "babylonjs/Maths/math";
  34403. /**
  34404. * 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.
  34405. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34406. */
  34407. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34408. /**
  34409. * Gets the name of the behavior.
  34410. */
  34411. readonly name: string;
  34412. private _mode;
  34413. private _radiusScale;
  34414. private _positionScale;
  34415. private _defaultElevation;
  34416. private _elevationReturnTime;
  34417. private _elevationReturnWaitTime;
  34418. private _zoomStopsAnimation;
  34419. private _framingTime;
  34420. /**
  34421. * The easing function used by animations
  34422. */
  34423. static EasingFunction: ExponentialEase;
  34424. /**
  34425. * The easing mode used by animations
  34426. */
  34427. static EasingMode: number;
  34428. /**
  34429. * Sets the current mode used by the behavior
  34430. */
  34431. /**
  34432. * Gets current mode used by the behavior.
  34433. */
  34434. mode: number;
  34435. /**
  34436. * Sets the scale applied to the radius (1 by default)
  34437. */
  34438. /**
  34439. * Gets the scale applied to the radius
  34440. */
  34441. radiusScale: number;
  34442. /**
  34443. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34444. */
  34445. /**
  34446. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34447. */
  34448. positionScale: number;
  34449. /**
  34450. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34451. * behaviour is triggered, in radians.
  34452. */
  34453. /**
  34454. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34455. * behaviour is triggered, in radians.
  34456. */
  34457. defaultElevation: number;
  34458. /**
  34459. * Sets the time (in milliseconds) taken to return to the default beta position.
  34460. * Negative value indicates camera should not return to default.
  34461. */
  34462. /**
  34463. * Gets the time (in milliseconds) taken to return to the default beta position.
  34464. * Negative value indicates camera should not return to default.
  34465. */
  34466. elevationReturnTime: number;
  34467. /**
  34468. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34469. */
  34470. /**
  34471. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34472. */
  34473. elevationReturnWaitTime: number;
  34474. /**
  34475. * Sets the flag that indicates if user zooming should stop animation.
  34476. */
  34477. /**
  34478. * Gets the flag that indicates if user zooming should stop animation.
  34479. */
  34480. zoomStopsAnimation: boolean;
  34481. /**
  34482. * Sets the transition time when framing the mesh, in milliseconds
  34483. */
  34484. /**
  34485. * Gets the transition time when framing the mesh, in milliseconds
  34486. */
  34487. framingTime: number;
  34488. /**
  34489. * Define if the behavior should automatically change the configured
  34490. * camera limits and sensibilities.
  34491. */
  34492. autoCorrectCameraLimitsAndSensibility: boolean;
  34493. private _onPrePointerObservableObserver;
  34494. private _onAfterCheckInputsObserver;
  34495. private _onMeshTargetChangedObserver;
  34496. private _attachedCamera;
  34497. private _isPointerDown;
  34498. private _lastInteractionTime;
  34499. /**
  34500. * Initializes the behavior.
  34501. */
  34502. init(): void;
  34503. /**
  34504. * Attaches the behavior to its arc rotate camera.
  34505. * @param camera Defines the camera to attach the behavior to
  34506. */
  34507. attach(camera: ArcRotateCamera): void;
  34508. /**
  34509. * Detaches the behavior from its current arc rotate camera.
  34510. */
  34511. detach(): void;
  34512. private _animatables;
  34513. private _betaIsAnimating;
  34514. private _betaTransition;
  34515. private _radiusTransition;
  34516. private _vectorTransition;
  34517. /**
  34518. * Targets the given mesh and updates zoom level accordingly.
  34519. * @param mesh The mesh to target.
  34520. * @param radius Optional. If a cached radius position already exists, overrides default.
  34521. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34522. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34523. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34524. */
  34525. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34526. /**
  34527. * Targets the given mesh with its children and updates zoom level accordingly.
  34528. * @param mesh The mesh to target.
  34529. * @param radius Optional. If a cached radius position already exists, overrides default.
  34530. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34531. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34532. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34533. */
  34534. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34535. /**
  34536. * Targets the given meshes with their children and updates zoom level accordingly.
  34537. * @param meshes The mesh to target.
  34538. * @param radius Optional. If a cached radius position already exists, overrides default.
  34539. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34542. */
  34543. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34544. /**
  34545. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34546. * @param minimumWorld Determines the smaller position of the bounding box extend
  34547. * @param maximumWorld Determines the bigger position of the bounding box extend
  34548. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34549. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34550. */
  34551. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34552. /**
  34553. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34554. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34555. * frustum width.
  34556. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34557. * to fully enclose the mesh in the viewing frustum.
  34558. */
  34559. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34560. /**
  34561. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34562. * is automatically returned to its default position (expected to be above ground plane).
  34563. */
  34564. private _maintainCameraAboveGround;
  34565. /**
  34566. * Returns the frustum slope based on the canvas ratio and camera FOV
  34567. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34568. */
  34569. private _getFrustumSlope;
  34570. /**
  34571. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34572. */
  34573. private _clearAnimationLocks;
  34574. /**
  34575. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34576. */
  34577. private _applyUserInteraction;
  34578. /**
  34579. * Stops and removes all animations that have been applied to the camera
  34580. */
  34581. stopAllAnimations(): void;
  34582. /**
  34583. * Gets a value indicating if the user is moving the camera
  34584. */
  34585. readonly isUserIsMoving: boolean;
  34586. /**
  34587. * The camera can move all the way towards the mesh.
  34588. */
  34589. static IgnoreBoundsSizeMode: number;
  34590. /**
  34591. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34592. */
  34593. static FitFrustumSidesMode: number;
  34594. }
  34595. }
  34596. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34597. import { Nullable } from "babylonjs/types";
  34598. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34600. /**
  34601. * Manage the pointers inputs to control an arc rotate camera.
  34602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34603. */
  34604. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34605. /**
  34606. * Defines the camera the input is attached to.
  34607. */
  34608. camera: ArcRotateCamera;
  34609. /**
  34610. * Defines the buttons associated with the input to handle camera move.
  34611. */
  34612. buttons: number[];
  34613. /**
  34614. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34615. */
  34616. angularSensibilityX: number;
  34617. /**
  34618. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34619. */
  34620. angularSensibilityY: number;
  34621. /**
  34622. * Defines the pointer pinch precision or how fast is the camera zooming.
  34623. */
  34624. pinchPrecision: number;
  34625. /**
  34626. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34627. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34628. */
  34629. pinchDeltaPercentage: number;
  34630. /**
  34631. * Defines the pointer panning sensibility or how fast is the camera moving.
  34632. */
  34633. panningSensibility: number;
  34634. /**
  34635. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34636. */
  34637. multiTouchPanning: boolean;
  34638. /**
  34639. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34640. */
  34641. multiTouchPanAndZoom: boolean;
  34642. /**
  34643. * Revers pinch action direction.
  34644. */
  34645. pinchInwards: boolean;
  34646. private _isPanClick;
  34647. private _pointerInput;
  34648. private _observer;
  34649. private _onMouseMove;
  34650. private _onGestureStart;
  34651. private _onGesture;
  34652. private _MSGestureHandler;
  34653. private _onLostFocus;
  34654. private _onContextMenu;
  34655. /**
  34656. * Attach the input controls to a specific dom element to get the input from.
  34657. * @param element Defines the element the controls should be listened from
  34658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34659. */
  34660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34661. /**
  34662. * Detach the current controls from the specified dom element.
  34663. * @param element Defines the element to stop listening the inputs from
  34664. */
  34665. detachControl(element: Nullable<HTMLElement>): void;
  34666. /**
  34667. * Gets the class name of the current intput.
  34668. * @returns the class name
  34669. */
  34670. getClassName(): string;
  34671. /**
  34672. * Get the friendly name associated with the input class.
  34673. * @returns the input friendly name
  34674. */
  34675. getSimpleName(): string;
  34676. }
  34677. }
  34678. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34679. import { Nullable } from "babylonjs/types";
  34680. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34681. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34682. /**
  34683. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34685. */
  34686. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34687. /**
  34688. * Defines the camera the input is attached to.
  34689. */
  34690. camera: ArcRotateCamera;
  34691. /**
  34692. * Defines the list of key codes associated with the up action (increase alpha)
  34693. */
  34694. keysUp: number[];
  34695. /**
  34696. * Defines the list of key codes associated with the down action (decrease alpha)
  34697. */
  34698. keysDown: number[];
  34699. /**
  34700. * Defines the list of key codes associated with the left action (increase beta)
  34701. */
  34702. keysLeft: number[];
  34703. /**
  34704. * Defines the list of key codes associated with the right action (decrease beta)
  34705. */
  34706. keysRight: number[];
  34707. /**
  34708. * Defines the list of key codes associated with the reset action.
  34709. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34710. */
  34711. keysReset: number[];
  34712. /**
  34713. * Defines the panning sensibility of the inputs.
  34714. * (How fast is the camera paning)
  34715. */
  34716. panningSensibility: number;
  34717. /**
  34718. * Defines the zooming sensibility of the inputs.
  34719. * (How fast is the camera zooming)
  34720. */
  34721. zoomingSensibility: number;
  34722. /**
  34723. * Defines wether maintaining the alt key down switch the movement mode from
  34724. * orientation to zoom.
  34725. */
  34726. useAltToZoom: boolean;
  34727. /**
  34728. * Rotation speed of the camera
  34729. */
  34730. angularSpeed: number;
  34731. private _keys;
  34732. private _ctrlPressed;
  34733. private _altPressed;
  34734. private _onCanvasBlurObserver;
  34735. private _onKeyboardObserver;
  34736. private _engine;
  34737. private _scene;
  34738. /**
  34739. * Attach the input controls to a specific dom element to get the input from.
  34740. * @param element Defines the element the controls should be listened from
  34741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34742. */
  34743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34744. /**
  34745. * Detach the current controls from the specified dom element.
  34746. * @param element Defines the element to stop listening the inputs from
  34747. */
  34748. detachControl(element: Nullable<HTMLElement>): void;
  34749. /**
  34750. * Update the current camera state depending on the inputs that have been used this frame.
  34751. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34752. */
  34753. checkInputs(): void;
  34754. /**
  34755. * Gets the class name of the current intput.
  34756. * @returns the class name
  34757. */
  34758. getClassName(): string;
  34759. /**
  34760. * Get the friendly name associated with the input class.
  34761. * @returns the input friendly name
  34762. */
  34763. getSimpleName(): string;
  34764. }
  34765. }
  34766. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34767. import { Nullable } from "babylonjs/types";
  34768. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34769. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34770. /**
  34771. * Manage the mouse wheel inputs to control an arc rotate camera.
  34772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34773. */
  34774. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34775. /**
  34776. * Defines the camera the input is attached to.
  34777. */
  34778. camera: ArcRotateCamera;
  34779. /**
  34780. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34781. */
  34782. wheelPrecision: number;
  34783. /**
  34784. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34785. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34786. */
  34787. wheelDeltaPercentage: number;
  34788. private _wheel;
  34789. private _observer;
  34790. /**
  34791. * Attach the input controls to a specific dom element to get the input from.
  34792. * @param element Defines the element the controls should be listened from
  34793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34794. */
  34795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34796. /**
  34797. * Detach the current controls from the specified dom element.
  34798. * @param element Defines the element to stop listening the inputs from
  34799. */
  34800. detachControl(element: Nullable<HTMLElement>): void;
  34801. /**
  34802. * Gets the class name of the current intput.
  34803. * @returns the class name
  34804. */
  34805. getClassName(): string;
  34806. /**
  34807. * Get the friendly name associated with the input class.
  34808. * @returns the input friendly name
  34809. */
  34810. getSimpleName(): string;
  34811. }
  34812. }
  34813. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34814. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34815. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34816. /**
  34817. * Default Inputs manager for the ArcRotateCamera.
  34818. * It groups all the default supported inputs for ease of use.
  34819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34820. */
  34821. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34822. /**
  34823. * Instantiates a new ArcRotateCameraInputsManager.
  34824. * @param camera Defines the camera the inputs belong to
  34825. */
  34826. constructor(camera: ArcRotateCamera);
  34827. /**
  34828. * Add mouse wheel input support to the input manager.
  34829. * @returns the current input manager
  34830. */
  34831. addMouseWheel(): ArcRotateCameraInputsManager;
  34832. /**
  34833. * Add pointers input support to the input manager.
  34834. * @returns the current input manager
  34835. */
  34836. addPointers(): ArcRotateCameraInputsManager;
  34837. /**
  34838. * Add keyboard input support to the input manager.
  34839. * @returns the current input manager
  34840. */
  34841. addKeyboard(): ArcRotateCameraInputsManager;
  34842. }
  34843. }
  34844. declare module "babylonjs/Cameras/arcRotateCamera" {
  34845. import { Observable } from "babylonjs/Misc/observable";
  34846. import { Nullable } from "babylonjs/types";
  34847. import { Scene } from "babylonjs/scene";
  34848. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34850. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34851. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34852. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34853. import { Camera } from "babylonjs/Cameras/camera";
  34854. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34855. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34856. import { Collider } from "babylonjs/Collisions/collider";
  34857. /**
  34858. * This represents an orbital type of camera.
  34859. *
  34860. * 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.
  34861. * 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.
  34862. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34863. */
  34864. export class ArcRotateCamera extends TargetCamera {
  34865. /**
  34866. * Defines the rotation angle of the camera along the longitudinal axis.
  34867. */
  34868. alpha: number;
  34869. /**
  34870. * Defines the rotation angle of the camera along the latitudinal axis.
  34871. */
  34872. beta: number;
  34873. /**
  34874. * Defines the radius of the camera from it s target point.
  34875. */
  34876. radius: number;
  34877. protected _target: Vector3;
  34878. protected _targetHost: Nullable<AbstractMesh>;
  34879. /**
  34880. * Defines the target point of the camera.
  34881. * The camera looks towards it form the radius distance.
  34882. */
  34883. target: Vector3;
  34884. /**
  34885. * Current inertia value on the longitudinal axis.
  34886. * The bigger this number the longer it will take for the camera to stop.
  34887. */
  34888. inertialAlphaOffset: number;
  34889. /**
  34890. * Current inertia value on the latitudinal axis.
  34891. * The bigger this number the longer it will take for the camera to stop.
  34892. */
  34893. inertialBetaOffset: number;
  34894. /**
  34895. * Current inertia value on the radius axis.
  34896. * The bigger this number the longer it will take for the camera to stop.
  34897. */
  34898. inertialRadiusOffset: number;
  34899. /**
  34900. * Minimum allowed angle on the longitudinal axis.
  34901. * This can help limiting how the Camera is able to move in the scene.
  34902. */
  34903. lowerAlphaLimit: Nullable<number>;
  34904. /**
  34905. * Maximum allowed angle on the longitudinal axis.
  34906. * This can help limiting how the Camera is able to move in the scene.
  34907. */
  34908. upperAlphaLimit: Nullable<number>;
  34909. /**
  34910. * Minimum allowed angle on the latitudinal axis.
  34911. * This can help limiting how the Camera is able to move in the scene.
  34912. */
  34913. lowerBetaLimit: number;
  34914. /**
  34915. * Maximum allowed angle on the latitudinal axis.
  34916. * This can help limiting how the Camera is able to move in the scene.
  34917. */
  34918. upperBetaLimit: number;
  34919. /**
  34920. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34921. * This can help limiting how the Camera is able to move in the scene.
  34922. */
  34923. lowerRadiusLimit: Nullable<number>;
  34924. /**
  34925. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34926. * This can help limiting how the Camera is able to move in the scene.
  34927. */
  34928. upperRadiusLimit: Nullable<number>;
  34929. /**
  34930. * Defines the current inertia value used during panning of the camera along the X axis.
  34931. */
  34932. inertialPanningX: number;
  34933. /**
  34934. * Defines the current inertia value used during panning of the camera along the Y axis.
  34935. */
  34936. inertialPanningY: number;
  34937. /**
  34938. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34939. * Basically if your fingers moves away from more than this distance you will be considered
  34940. * in pinch mode.
  34941. */
  34942. pinchToPanMaxDistance: number;
  34943. /**
  34944. * Defines the maximum distance the camera can pan.
  34945. * This could help keeping the cammera always in your scene.
  34946. */
  34947. panningDistanceLimit: Nullable<number>;
  34948. /**
  34949. * Defines the target of the camera before paning.
  34950. */
  34951. panningOriginTarget: Vector3;
  34952. /**
  34953. * Defines the value of the inertia used during panning.
  34954. * 0 would mean stop inertia and one would mean no decelleration at all.
  34955. */
  34956. panningInertia: number;
  34957. /**
  34958. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34959. */
  34960. angularSensibilityX: number;
  34961. /**
  34962. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34963. */
  34964. angularSensibilityY: number;
  34965. /**
  34966. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34967. */
  34968. pinchPrecision: number;
  34969. /**
  34970. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34971. * It will be used instead of pinchDeltaPrecision if different from 0.
  34972. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34973. */
  34974. pinchDeltaPercentage: number;
  34975. /**
  34976. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34977. */
  34978. panningSensibility: number;
  34979. /**
  34980. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34981. */
  34982. keysUp: number[];
  34983. /**
  34984. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34985. */
  34986. keysDown: number[];
  34987. /**
  34988. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34989. */
  34990. keysLeft: number[];
  34991. /**
  34992. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34993. */
  34994. keysRight: number[];
  34995. /**
  34996. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34997. */
  34998. wheelPrecision: number;
  34999. /**
  35000. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35001. * It will be used instead of pinchDeltaPrecision if different from 0.
  35002. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35003. */
  35004. wheelDeltaPercentage: number;
  35005. /**
  35006. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35007. */
  35008. zoomOnFactor: number;
  35009. /**
  35010. * Defines a screen offset for the camera position.
  35011. */
  35012. targetScreenOffset: Vector2;
  35013. /**
  35014. * Allows the camera to be completely reversed.
  35015. * If false the camera can not arrive upside down.
  35016. */
  35017. allowUpsideDown: boolean;
  35018. /**
  35019. * Define if double tap/click is used to restore the previously saved state of the camera.
  35020. */
  35021. useInputToRestoreState: boolean;
  35022. /** @hidden */
  35023. _viewMatrix: Matrix;
  35024. /** @hidden */
  35025. _useCtrlForPanning: boolean;
  35026. /** @hidden */
  35027. _panningMouseButton: number;
  35028. /**
  35029. * Defines the input associated to the camera.
  35030. */
  35031. inputs: ArcRotateCameraInputsManager;
  35032. /** @hidden */
  35033. _reset: () => void;
  35034. /**
  35035. * Defines the allowed panning axis.
  35036. */
  35037. panningAxis: Vector3;
  35038. protected _localDirection: Vector3;
  35039. protected _transformedDirection: Vector3;
  35040. private _bouncingBehavior;
  35041. /**
  35042. * Gets the bouncing behavior of the camera if it has been enabled.
  35043. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35044. */
  35045. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35046. /**
  35047. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35048. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35049. */
  35050. useBouncingBehavior: boolean;
  35051. private _framingBehavior;
  35052. /**
  35053. * Gets the framing behavior of the camera if it has been enabled.
  35054. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35055. */
  35056. readonly framingBehavior: Nullable<FramingBehavior>;
  35057. /**
  35058. * Defines if the framing behavior of the camera is enabled on the camera.
  35059. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35060. */
  35061. useFramingBehavior: boolean;
  35062. private _autoRotationBehavior;
  35063. /**
  35064. * Gets the auto rotation behavior of the camera if it has been enabled.
  35065. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35066. */
  35067. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35068. /**
  35069. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35071. */
  35072. useAutoRotationBehavior: boolean;
  35073. /**
  35074. * Observable triggered when the mesh target has been changed on the camera.
  35075. */
  35076. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35077. /**
  35078. * Event raised when the camera is colliding with a mesh.
  35079. */
  35080. onCollide: (collidedMesh: AbstractMesh) => void;
  35081. /**
  35082. * Defines whether the camera should check collision with the objects oh the scene.
  35083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35084. */
  35085. checkCollisions: boolean;
  35086. /**
  35087. * Defines the collision radius of the camera.
  35088. * This simulates a sphere around the camera.
  35089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35090. */
  35091. collisionRadius: Vector3;
  35092. protected _collider: Collider;
  35093. protected _previousPosition: Vector3;
  35094. protected _collisionVelocity: Vector3;
  35095. protected _newPosition: Vector3;
  35096. protected _previousAlpha: number;
  35097. protected _previousBeta: number;
  35098. protected _previousRadius: number;
  35099. protected _collisionTriggered: boolean;
  35100. protected _targetBoundingCenter: Nullable<Vector3>;
  35101. private _computationVector;
  35102. private _tempAxisVector;
  35103. private _tempAxisRotationMatrix;
  35104. /**
  35105. * Instantiates a new ArcRotateCamera in a given scene
  35106. * @param name Defines the name of the camera
  35107. * @param alpha Defines the camera rotation along the logitudinal axis
  35108. * @param beta Defines the camera rotation along the latitudinal axis
  35109. * @param radius Defines the camera distance from its target
  35110. * @param target Defines the camera target
  35111. * @param scene Defines the scene the camera belongs to
  35112. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35113. */
  35114. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35115. /** @hidden */
  35116. _initCache(): void;
  35117. /** @hidden */
  35118. _updateCache(ignoreParentClass?: boolean): void;
  35119. protected _getTargetPosition(): Vector3;
  35120. private _storedAlpha;
  35121. private _storedBeta;
  35122. private _storedRadius;
  35123. private _storedTarget;
  35124. /**
  35125. * Stores the current state of the camera (alpha, beta, radius and target)
  35126. * @returns the camera itself
  35127. */
  35128. storeState(): Camera;
  35129. /**
  35130. * @hidden
  35131. * Restored camera state. You must call storeState() first
  35132. */
  35133. _restoreStateValues(): boolean;
  35134. /** @hidden */
  35135. _isSynchronizedViewMatrix(): boolean;
  35136. /**
  35137. * Attached controls to the current camera.
  35138. * @param element Defines the element the controls should be listened from
  35139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35140. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35141. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35142. */
  35143. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35144. /**
  35145. * Detach the current controls from the camera.
  35146. * The camera will stop reacting to inputs.
  35147. * @param element Defines the element to stop listening the inputs from
  35148. */
  35149. detachControl(element: HTMLElement): void;
  35150. /** @hidden */
  35151. _checkInputs(): void;
  35152. protected _checkLimits(): void;
  35153. /**
  35154. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35155. */
  35156. rebuildAnglesAndRadius(): void;
  35157. /**
  35158. * Use a position to define the current camera related information like aplha, beta and radius
  35159. * @param position Defines the position to set the camera at
  35160. */
  35161. setPosition(position: Vector3): void;
  35162. /**
  35163. * Defines the target the camera should look at.
  35164. * This will automatically adapt alpha beta and radius to fit within the new target.
  35165. * @param target Defines the new target as a Vector or a mesh
  35166. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35167. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35168. */
  35169. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35170. /** @hidden */
  35171. _getViewMatrix(): Matrix;
  35172. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35173. /**
  35174. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35175. * @param meshes Defines the mesh to zoom on
  35176. * @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)
  35177. */
  35178. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35179. /**
  35180. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35181. * The target will be changed but the radius
  35182. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35183. * @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)
  35184. */
  35185. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35186. min: Vector3;
  35187. max: Vector3;
  35188. distance: number;
  35189. }, doNotUpdateMaxZ?: boolean): void;
  35190. /**
  35191. * @override
  35192. * Override Camera.createRigCamera
  35193. */
  35194. createRigCamera(name: string, cameraIndex: number): Camera;
  35195. /**
  35196. * @hidden
  35197. * @override
  35198. * Override Camera._updateRigCameras
  35199. */
  35200. _updateRigCameras(): void;
  35201. /**
  35202. * Destroy the camera and release the current resources hold by it.
  35203. */
  35204. dispose(): void;
  35205. /**
  35206. * Gets the current object class name.
  35207. * @return the class name
  35208. */
  35209. getClassName(): string;
  35210. }
  35211. }
  35212. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35213. import { Behavior } from "babylonjs/Behaviors/behavior";
  35214. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35215. /**
  35216. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35217. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35218. */
  35219. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35220. /**
  35221. * Gets the name of the behavior.
  35222. */
  35223. readonly name: string;
  35224. private _zoomStopsAnimation;
  35225. private _idleRotationSpeed;
  35226. private _idleRotationWaitTime;
  35227. private _idleRotationSpinupTime;
  35228. /**
  35229. * Sets the flag that indicates if user zooming should stop animation.
  35230. */
  35231. /**
  35232. * Gets the flag that indicates if user zooming should stop animation.
  35233. */
  35234. zoomStopsAnimation: boolean;
  35235. /**
  35236. * Sets the default speed at which the camera rotates around the model.
  35237. */
  35238. /**
  35239. * Gets the default speed at which the camera rotates around the model.
  35240. */
  35241. idleRotationSpeed: number;
  35242. /**
  35243. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35244. */
  35245. /**
  35246. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35247. */
  35248. idleRotationWaitTime: number;
  35249. /**
  35250. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35251. */
  35252. /**
  35253. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35254. */
  35255. idleRotationSpinupTime: number;
  35256. /**
  35257. * Gets a value indicating if the camera is currently rotating because of this behavior
  35258. */
  35259. readonly rotationInProgress: boolean;
  35260. private _onPrePointerObservableObserver;
  35261. private _onAfterCheckInputsObserver;
  35262. private _attachedCamera;
  35263. private _isPointerDown;
  35264. private _lastFrameTime;
  35265. private _lastInteractionTime;
  35266. private _cameraRotationSpeed;
  35267. /**
  35268. * Initializes the behavior.
  35269. */
  35270. init(): void;
  35271. /**
  35272. * Attaches the behavior to its arc rotate camera.
  35273. * @param camera Defines the camera to attach the behavior to
  35274. */
  35275. attach(camera: ArcRotateCamera): void;
  35276. /**
  35277. * Detaches the behavior from its current arc rotate camera.
  35278. */
  35279. detach(): void;
  35280. /**
  35281. * Returns true if user is scrolling.
  35282. * @return true if user is scrolling.
  35283. */
  35284. private _userIsZooming;
  35285. private _lastFrameRadius;
  35286. private _shouldAnimationStopForInteraction;
  35287. /**
  35288. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35289. */
  35290. private _applyUserInteraction;
  35291. private _userIsMoving;
  35292. }
  35293. }
  35294. declare module "babylonjs/Behaviors/Cameras/index" {
  35295. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35296. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35297. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35298. }
  35299. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35300. import { Mesh } from "babylonjs/Meshes/mesh";
  35301. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35302. import { Behavior } from "babylonjs/Behaviors/behavior";
  35303. /**
  35304. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35305. */
  35306. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35307. private ui;
  35308. /**
  35309. * The name of the behavior
  35310. */
  35311. name: string;
  35312. /**
  35313. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35314. */
  35315. distanceAwayFromFace: number;
  35316. /**
  35317. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35318. */
  35319. distanceAwayFromBottomOfFace: number;
  35320. private _faceVectors;
  35321. private _target;
  35322. private _scene;
  35323. private _onRenderObserver;
  35324. private _tmpMatrix;
  35325. private _tmpVector;
  35326. /**
  35327. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35328. * @param ui The transform node that should be attched to the mesh
  35329. */
  35330. constructor(ui: TransformNode);
  35331. /**
  35332. * Initializes the behavior
  35333. */
  35334. init(): void;
  35335. private _closestFace;
  35336. private _zeroVector;
  35337. private _lookAtTmpMatrix;
  35338. private _lookAtToRef;
  35339. /**
  35340. * Attaches the AttachToBoxBehavior to the passed in mesh
  35341. * @param target The mesh that the specified node will be attached to
  35342. */
  35343. attach(target: Mesh): void;
  35344. /**
  35345. * Detaches the behavior from the mesh
  35346. */
  35347. detach(): void;
  35348. }
  35349. }
  35350. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35351. import { Behavior } from "babylonjs/Behaviors/behavior";
  35352. import { Mesh } from "babylonjs/Meshes/mesh";
  35353. /**
  35354. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35355. */
  35356. export class FadeInOutBehavior implements Behavior<Mesh> {
  35357. /**
  35358. * Time in milliseconds to delay before fading in (Default: 0)
  35359. */
  35360. delay: number;
  35361. /**
  35362. * Time in milliseconds for the mesh to fade in (Default: 300)
  35363. */
  35364. fadeInTime: number;
  35365. private _millisecondsPerFrame;
  35366. private _hovered;
  35367. private _hoverValue;
  35368. private _ownerNode;
  35369. /**
  35370. * Instatiates the FadeInOutBehavior
  35371. */
  35372. constructor();
  35373. /**
  35374. * The name of the behavior
  35375. */
  35376. readonly name: string;
  35377. /**
  35378. * Initializes the behavior
  35379. */
  35380. init(): void;
  35381. /**
  35382. * Attaches the fade behavior on the passed in mesh
  35383. * @param ownerNode The mesh that will be faded in/out once attached
  35384. */
  35385. attach(ownerNode: Mesh): void;
  35386. /**
  35387. * Detaches the behavior from the mesh
  35388. */
  35389. detach(): void;
  35390. /**
  35391. * Triggers the mesh to begin fading in or out
  35392. * @param value if the object should fade in or out (true to fade in)
  35393. */
  35394. fadeIn(value: boolean): void;
  35395. private _update;
  35396. private _setAllVisibility;
  35397. }
  35398. }
  35399. declare module "babylonjs/Misc/pivotTools" {
  35400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35401. /**
  35402. * Class containing a set of static utilities functions for managing Pivots
  35403. * @hidden
  35404. */
  35405. export class PivotTools {
  35406. private static _PivotCached;
  35407. private static _OldPivotPoint;
  35408. private static _PivotTranslation;
  35409. private static _PivotTmpVector;
  35410. /** @hidden */
  35411. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35412. /** @hidden */
  35413. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35414. }
  35415. }
  35416. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35417. import { Scene } from "babylonjs/scene";
  35418. import { Vector4, Plane } from "babylonjs/Maths/math";
  35419. import { Mesh } from "babylonjs/Meshes/mesh";
  35420. /**
  35421. * Class containing static functions to help procedurally build meshes
  35422. */
  35423. export class PlaneBuilder {
  35424. /**
  35425. * Creates a plane mesh
  35426. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35427. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35428. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35432. * @param name defines the name of the mesh
  35433. * @param options defines the options used to create the mesh
  35434. * @param scene defines the hosting scene
  35435. * @returns the plane mesh
  35436. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35437. */
  35438. static CreatePlane(name: string, options: {
  35439. size?: number;
  35440. width?: number;
  35441. height?: number;
  35442. sideOrientation?: number;
  35443. frontUVs?: Vector4;
  35444. backUVs?: Vector4;
  35445. updatable?: boolean;
  35446. sourcePlane?: Plane;
  35447. }, scene: Scene): Mesh;
  35448. }
  35449. }
  35450. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35451. import { Behavior } from "babylonjs/Behaviors/behavior";
  35452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35453. import { Observable } from "babylonjs/Misc/observable";
  35454. import { Vector3 } from "babylonjs/Maths/math";
  35455. import { Ray } from "babylonjs/Culling/ray";
  35456. import "babylonjs/Meshes/Builders/planeBuilder";
  35457. /**
  35458. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35459. */
  35460. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35461. private static _AnyMouseID;
  35462. private _attachedNode;
  35463. private _dragPlane;
  35464. private _scene;
  35465. private _pointerObserver;
  35466. private _beforeRenderObserver;
  35467. private static _planeScene;
  35468. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35469. /**
  35470. * 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)
  35471. */
  35472. maxDragAngle: number;
  35473. /**
  35474. * @hidden
  35475. */
  35476. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35477. /**
  35478. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35479. */
  35480. currentDraggingPointerID: number;
  35481. /**
  35482. * The last position where the pointer hit the drag plane in world space
  35483. */
  35484. lastDragPosition: Vector3;
  35485. /**
  35486. * If the behavior is currently in a dragging state
  35487. */
  35488. dragging: boolean;
  35489. /**
  35490. * 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)
  35491. */
  35492. dragDeltaRatio: number;
  35493. /**
  35494. * If the drag plane orientation should be updated during the dragging (Default: true)
  35495. */
  35496. updateDragPlane: boolean;
  35497. private _debugMode;
  35498. private _moving;
  35499. /**
  35500. * Fires each time the attached mesh is dragged with the pointer
  35501. * * delta between last drag position and current drag position in world space
  35502. * * dragDistance along the drag axis
  35503. * * dragPlaneNormal normal of the current drag plane used during the drag
  35504. * * dragPlanePoint in world space where the drag intersects the drag plane
  35505. */
  35506. onDragObservable: Observable<{
  35507. delta: Vector3;
  35508. dragPlanePoint: Vector3;
  35509. dragPlaneNormal: Vector3;
  35510. dragDistance: number;
  35511. pointerId: number;
  35512. }>;
  35513. /**
  35514. * Fires each time a drag begins (eg. mouse down on mesh)
  35515. */
  35516. onDragStartObservable: Observable<{
  35517. dragPlanePoint: Vector3;
  35518. pointerId: number;
  35519. }>;
  35520. /**
  35521. * Fires each time a drag ends (eg. mouse release after drag)
  35522. */
  35523. onDragEndObservable: Observable<{
  35524. dragPlanePoint: Vector3;
  35525. pointerId: number;
  35526. }>;
  35527. /**
  35528. * If the attached mesh should be moved when dragged
  35529. */
  35530. moveAttached: boolean;
  35531. /**
  35532. * If the drag behavior will react to drag events (Default: true)
  35533. */
  35534. enabled: boolean;
  35535. /**
  35536. * If camera controls should be detached during the drag
  35537. */
  35538. detachCameraControls: boolean;
  35539. /**
  35540. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35541. */
  35542. useObjectOrienationForDragging: boolean;
  35543. private _options;
  35544. /**
  35545. * Creates a pointer drag behavior that can be attached to a mesh
  35546. * @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)
  35547. */
  35548. constructor(options?: {
  35549. dragAxis?: Vector3;
  35550. dragPlaneNormal?: Vector3;
  35551. });
  35552. /**
  35553. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35554. */
  35555. validateDrag: (targetPosition: Vector3) => boolean;
  35556. /**
  35557. * The name of the behavior
  35558. */
  35559. readonly name: string;
  35560. /**
  35561. * Initializes the behavior
  35562. */
  35563. init(): void;
  35564. private _tmpVector;
  35565. private _alternatePickedPoint;
  35566. private _worldDragAxis;
  35567. private _targetPosition;
  35568. private _attachedElement;
  35569. /**
  35570. * Attaches the drag behavior the passed in mesh
  35571. * @param ownerNode The mesh that will be dragged around once attached
  35572. */
  35573. attach(ownerNode: AbstractMesh): void;
  35574. /**
  35575. * Force relase the drag action by code.
  35576. */
  35577. releaseDrag(): void;
  35578. private _startDragRay;
  35579. private _lastPointerRay;
  35580. /**
  35581. * Simulates the start of a pointer drag event on the behavior
  35582. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35583. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35584. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35585. */
  35586. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35587. private _startDrag;
  35588. private _dragDelta;
  35589. private _moveDrag;
  35590. private _pickWithRayOnDragPlane;
  35591. private _pointA;
  35592. private _pointB;
  35593. private _pointC;
  35594. private _lineA;
  35595. private _lineB;
  35596. private _localAxis;
  35597. private _lookAt;
  35598. private _updateDragPlanePosition;
  35599. /**
  35600. * Detaches the behavior from the mesh
  35601. */
  35602. detach(): void;
  35603. }
  35604. }
  35605. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35606. import { Mesh } from "babylonjs/Meshes/mesh";
  35607. import { Behavior } from "babylonjs/Behaviors/behavior";
  35608. /**
  35609. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35610. */
  35611. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35612. private _dragBehaviorA;
  35613. private _dragBehaviorB;
  35614. private _startDistance;
  35615. private _initialScale;
  35616. private _targetScale;
  35617. private _ownerNode;
  35618. private _sceneRenderObserver;
  35619. /**
  35620. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35621. */
  35622. constructor();
  35623. /**
  35624. * The name of the behavior
  35625. */
  35626. readonly name: string;
  35627. /**
  35628. * Initializes the behavior
  35629. */
  35630. init(): void;
  35631. private _getCurrentDistance;
  35632. /**
  35633. * Attaches the scale behavior the passed in mesh
  35634. * @param ownerNode The mesh that will be scaled around once attached
  35635. */
  35636. attach(ownerNode: Mesh): void;
  35637. /**
  35638. * Detaches the behavior from the mesh
  35639. */
  35640. detach(): void;
  35641. }
  35642. }
  35643. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35644. import { Behavior } from "babylonjs/Behaviors/behavior";
  35645. import { Mesh } from "babylonjs/Meshes/mesh";
  35646. import { Observable } from "babylonjs/Misc/observable";
  35647. /**
  35648. * 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
  35649. */
  35650. export class SixDofDragBehavior implements Behavior<Mesh> {
  35651. private static _virtualScene;
  35652. private _ownerNode;
  35653. private _sceneRenderObserver;
  35654. private _scene;
  35655. private _targetPosition;
  35656. private _virtualOriginMesh;
  35657. private _virtualDragMesh;
  35658. private _pointerObserver;
  35659. private _moving;
  35660. private _startingOrientation;
  35661. /**
  35662. * 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)
  35663. */
  35664. private zDragFactor;
  35665. /**
  35666. * If the object should rotate to face the drag origin
  35667. */
  35668. rotateDraggedObject: boolean;
  35669. /**
  35670. * If the behavior is currently in a dragging state
  35671. */
  35672. dragging: boolean;
  35673. /**
  35674. * 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)
  35675. */
  35676. dragDeltaRatio: number;
  35677. /**
  35678. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35679. */
  35680. currentDraggingPointerID: number;
  35681. /**
  35682. * If camera controls should be detached during the drag
  35683. */
  35684. detachCameraControls: boolean;
  35685. /**
  35686. * Fires each time a drag starts
  35687. */
  35688. onDragStartObservable: Observable<{}>;
  35689. /**
  35690. * Fires each time a drag ends (eg. mouse release after drag)
  35691. */
  35692. onDragEndObservable: Observable<{}>;
  35693. /**
  35694. * 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
  35695. */
  35696. constructor();
  35697. /**
  35698. * The name of the behavior
  35699. */
  35700. readonly name: string;
  35701. /**
  35702. * Initializes the behavior
  35703. */
  35704. init(): void;
  35705. /**
  35706. * Attaches the scale behavior the passed in mesh
  35707. * @param ownerNode The mesh that will be scaled around once attached
  35708. */
  35709. attach(ownerNode: Mesh): void;
  35710. /**
  35711. * Detaches the behavior from the mesh
  35712. */
  35713. detach(): void;
  35714. }
  35715. }
  35716. declare module "babylonjs/Behaviors/Meshes/index" {
  35717. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35718. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35719. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35720. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35721. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35722. }
  35723. declare module "babylonjs/Behaviors/index" {
  35724. export * from "babylonjs/Behaviors/behavior";
  35725. export * from "babylonjs/Behaviors/Cameras/index";
  35726. export * from "babylonjs/Behaviors/Meshes/index";
  35727. }
  35728. declare module "babylonjs/Bones/boneIKController" {
  35729. import { Bone } from "babylonjs/Bones/bone";
  35730. import { Vector3 } from "babylonjs/Maths/math";
  35731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35732. import { Nullable } from "babylonjs/types";
  35733. /**
  35734. * Class used to apply inverse kinematics to bones
  35735. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35736. */
  35737. export class BoneIKController {
  35738. private static _tmpVecs;
  35739. private static _tmpQuat;
  35740. private static _tmpMats;
  35741. /**
  35742. * Gets or sets the target mesh
  35743. */
  35744. targetMesh: AbstractMesh;
  35745. /** Gets or sets the mesh used as pole */
  35746. poleTargetMesh: AbstractMesh;
  35747. /**
  35748. * Gets or sets the bone used as pole
  35749. */
  35750. poleTargetBone: Nullable<Bone>;
  35751. /**
  35752. * Gets or sets the target position
  35753. */
  35754. targetPosition: Vector3;
  35755. /**
  35756. * Gets or sets the pole target position
  35757. */
  35758. poleTargetPosition: Vector3;
  35759. /**
  35760. * Gets or sets the pole target local offset
  35761. */
  35762. poleTargetLocalOffset: Vector3;
  35763. /**
  35764. * Gets or sets the pole angle
  35765. */
  35766. poleAngle: number;
  35767. /**
  35768. * Gets or sets the mesh associated with the controller
  35769. */
  35770. mesh: AbstractMesh;
  35771. /**
  35772. * 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)
  35773. */
  35774. slerpAmount: number;
  35775. private _bone1Quat;
  35776. private _bone1Mat;
  35777. private _bone2Ang;
  35778. private _bone1;
  35779. private _bone2;
  35780. private _bone1Length;
  35781. private _bone2Length;
  35782. private _maxAngle;
  35783. private _maxReach;
  35784. private _rightHandedSystem;
  35785. private _bendAxis;
  35786. private _slerping;
  35787. private _adjustRoll;
  35788. /**
  35789. * Gets or sets maximum allowed angle
  35790. */
  35791. maxAngle: number;
  35792. /**
  35793. * Creates a new BoneIKController
  35794. * @param mesh defines the mesh to control
  35795. * @param bone defines the bone to control
  35796. * @param options defines options to set up the controller
  35797. */
  35798. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35799. targetMesh?: AbstractMesh;
  35800. poleTargetMesh?: AbstractMesh;
  35801. poleTargetBone?: Bone;
  35802. poleTargetLocalOffset?: Vector3;
  35803. poleAngle?: number;
  35804. bendAxis?: Vector3;
  35805. maxAngle?: number;
  35806. slerpAmount?: number;
  35807. });
  35808. private _setMaxAngle;
  35809. /**
  35810. * Force the controller to update the bones
  35811. */
  35812. update(): void;
  35813. }
  35814. }
  35815. declare module "babylonjs/Bones/boneLookController" {
  35816. import { Vector3, Space } from "babylonjs/Maths/math";
  35817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35818. import { Bone } from "babylonjs/Bones/bone";
  35819. /**
  35820. * Class used to make a bone look toward a point in space
  35821. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35822. */
  35823. export class BoneLookController {
  35824. private static _tmpVecs;
  35825. private static _tmpQuat;
  35826. private static _tmpMats;
  35827. /**
  35828. * The target Vector3 that the bone will look at
  35829. */
  35830. target: Vector3;
  35831. /**
  35832. * The mesh that the bone is attached to
  35833. */
  35834. mesh: AbstractMesh;
  35835. /**
  35836. * The bone that will be looking to the target
  35837. */
  35838. bone: Bone;
  35839. /**
  35840. * The up axis of the coordinate system that is used when the bone is rotated
  35841. */
  35842. upAxis: Vector3;
  35843. /**
  35844. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35845. */
  35846. upAxisSpace: Space;
  35847. /**
  35848. * Used to make an adjustment to the yaw of the bone
  35849. */
  35850. adjustYaw: number;
  35851. /**
  35852. * Used to make an adjustment to the pitch of the bone
  35853. */
  35854. adjustPitch: number;
  35855. /**
  35856. * Used to make an adjustment to the roll of the bone
  35857. */
  35858. adjustRoll: number;
  35859. /**
  35860. * 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)
  35861. */
  35862. slerpAmount: number;
  35863. private _minYaw;
  35864. private _maxYaw;
  35865. private _minPitch;
  35866. private _maxPitch;
  35867. private _minYawSin;
  35868. private _minYawCos;
  35869. private _maxYawSin;
  35870. private _maxYawCos;
  35871. private _midYawConstraint;
  35872. private _minPitchTan;
  35873. private _maxPitchTan;
  35874. private _boneQuat;
  35875. private _slerping;
  35876. private _transformYawPitch;
  35877. private _transformYawPitchInv;
  35878. private _firstFrameSkipped;
  35879. private _yawRange;
  35880. private _fowardAxis;
  35881. /**
  35882. * Gets or sets the minimum yaw angle that the bone can look to
  35883. */
  35884. minYaw: number;
  35885. /**
  35886. * Gets or sets the maximum yaw angle that the bone can look to
  35887. */
  35888. maxYaw: number;
  35889. /**
  35890. * Gets or sets the minimum pitch angle that the bone can look to
  35891. */
  35892. minPitch: number;
  35893. /**
  35894. * Gets or sets the maximum pitch angle that the bone can look to
  35895. */
  35896. maxPitch: number;
  35897. /**
  35898. * Create a BoneLookController
  35899. * @param mesh the mesh that the bone belongs to
  35900. * @param bone the bone that will be looking to the target
  35901. * @param target the target Vector3 to look at
  35902. * @param options optional settings:
  35903. * * maxYaw: the maximum angle the bone will yaw to
  35904. * * minYaw: the minimum angle the bone will yaw to
  35905. * * maxPitch: the maximum angle the bone will pitch to
  35906. * * minPitch: the minimum angle the bone will yaw to
  35907. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35908. * * upAxis: the up axis of the coordinate system
  35909. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35910. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35911. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35912. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35913. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35914. * * adjustRoll: used to make an adjustment to the roll of the bone
  35915. **/
  35916. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35917. maxYaw?: number;
  35918. minYaw?: number;
  35919. maxPitch?: number;
  35920. minPitch?: number;
  35921. slerpAmount?: number;
  35922. upAxis?: Vector3;
  35923. upAxisSpace?: Space;
  35924. yawAxis?: Vector3;
  35925. pitchAxis?: Vector3;
  35926. adjustYaw?: number;
  35927. adjustPitch?: number;
  35928. adjustRoll?: number;
  35929. });
  35930. /**
  35931. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35932. */
  35933. update(): void;
  35934. private _getAngleDiff;
  35935. private _getAngleBetween;
  35936. private _isAngleBetween;
  35937. }
  35938. }
  35939. declare module "babylonjs/Bones/index" {
  35940. export * from "babylonjs/Bones/bone";
  35941. export * from "babylonjs/Bones/boneIKController";
  35942. export * from "babylonjs/Bones/boneLookController";
  35943. export * from "babylonjs/Bones/skeleton";
  35944. }
  35945. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35946. import { Nullable } from "babylonjs/types";
  35947. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35949. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35950. /**
  35951. * Manage the gamepad inputs to control an arc rotate camera.
  35952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35953. */
  35954. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35955. /**
  35956. * Defines the camera the input is attached to.
  35957. */
  35958. camera: ArcRotateCamera;
  35959. /**
  35960. * Defines the gamepad the input is gathering event from.
  35961. */
  35962. gamepad: Nullable<Gamepad>;
  35963. /**
  35964. * Defines the gamepad rotation sensiblity.
  35965. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35966. */
  35967. gamepadRotationSensibility: number;
  35968. /**
  35969. * Defines the gamepad move sensiblity.
  35970. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35971. */
  35972. gamepadMoveSensibility: number;
  35973. private _onGamepadConnectedObserver;
  35974. private _onGamepadDisconnectedObserver;
  35975. /**
  35976. * Attach the input controls to a specific dom element to get the input from.
  35977. * @param element Defines the element the controls should be listened from
  35978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35979. */
  35980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35981. /**
  35982. * Detach the current controls from the specified dom element.
  35983. * @param element Defines the element to stop listening the inputs from
  35984. */
  35985. detachControl(element: Nullable<HTMLElement>): void;
  35986. /**
  35987. * Update the current camera state depending on the inputs that have been used this frame.
  35988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35989. */
  35990. checkInputs(): void;
  35991. /**
  35992. * Gets the class name of the current intput.
  35993. * @returns the class name
  35994. */
  35995. getClassName(): string;
  35996. /**
  35997. * Get the friendly name associated with the input class.
  35998. * @returns the input friendly name
  35999. */
  36000. getSimpleName(): string;
  36001. }
  36002. }
  36003. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36004. import { Nullable } from "babylonjs/types";
  36005. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36006. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36007. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36008. interface ArcRotateCameraInputsManager {
  36009. /**
  36010. * Add orientation input support to the input manager.
  36011. * @returns the current input manager
  36012. */
  36013. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36014. }
  36015. }
  36016. /**
  36017. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36019. */
  36020. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36021. /**
  36022. * Defines the camera the input is attached to.
  36023. */
  36024. camera: ArcRotateCamera;
  36025. /**
  36026. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36027. */
  36028. alphaCorrection: number;
  36029. /**
  36030. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36031. */
  36032. gammaCorrection: number;
  36033. private _alpha;
  36034. private _gamma;
  36035. private _dirty;
  36036. private _deviceOrientationHandler;
  36037. /**
  36038. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36039. */
  36040. constructor();
  36041. /**
  36042. * Attach the input controls to a specific dom element to get the input from.
  36043. * @param element Defines the element the controls should be listened from
  36044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36045. */
  36046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36047. /** @hidden */
  36048. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36049. /**
  36050. * Update the current camera state depending on the inputs that have been used this frame.
  36051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36052. */
  36053. checkInputs(): void;
  36054. /**
  36055. * Detach the current controls from the specified dom element.
  36056. * @param element Defines the element to stop listening the inputs from
  36057. */
  36058. detachControl(element: Nullable<HTMLElement>): void;
  36059. /**
  36060. * Gets the class name of the current intput.
  36061. * @returns the class name
  36062. */
  36063. getClassName(): string;
  36064. /**
  36065. * Get the friendly name associated with the input class.
  36066. * @returns the input friendly name
  36067. */
  36068. getSimpleName(): string;
  36069. }
  36070. }
  36071. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36072. import { Nullable } from "babylonjs/types";
  36073. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36074. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36075. /**
  36076. * Listen to mouse events to control the camera.
  36077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36078. */
  36079. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36080. /**
  36081. * Defines the camera the input is attached to.
  36082. */
  36083. camera: FlyCamera;
  36084. /**
  36085. * Defines if touch is enabled. (Default is true.)
  36086. */
  36087. touchEnabled: boolean;
  36088. /**
  36089. * Defines the buttons associated with the input to handle camera rotation.
  36090. */
  36091. buttons: number[];
  36092. /**
  36093. * Assign buttons for Yaw control.
  36094. */
  36095. buttonsYaw: number[];
  36096. /**
  36097. * Assign buttons for Pitch control.
  36098. */
  36099. buttonsPitch: number[];
  36100. /**
  36101. * Assign buttons for Roll control.
  36102. */
  36103. buttonsRoll: number[];
  36104. /**
  36105. * Detect if any button is being pressed while mouse is moved.
  36106. * -1 = Mouse locked.
  36107. * 0 = Left button.
  36108. * 1 = Middle Button.
  36109. * 2 = Right Button.
  36110. */
  36111. activeButton: number;
  36112. /**
  36113. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36114. * Higher values reduce its sensitivity.
  36115. */
  36116. angularSensibility: number;
  36117. private _mousemoveCallback;
  36118. private _observer;
  36119. private _rollObserver;
  36120. private previousPosition;
  36121. private noPreventDefault;
  36122. private element;
  36123. /**
  36124. * Listen to mouse events to control the camera.
  36125. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36127. */
  36128. constructor(touchEnabled?: boolean);
  36129. /**
  36130. * Attach the mouse control to the HTML DOM element.
  36131. * @param element Defines the element that listens to the input events.
  36132. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36133. */
  36134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36135. /**
  36136. * Detach the current controls from the specified dom element.
  36137. * @param element Defines the element to stop listening the inputs from
  36138. */
  36139. detachControl(element: Nullable<HTMLElement>): void;
  36140. /**
  36141. * Gets the class name of the current input.
  36142. * @returns the class name.
  36143. */
  36144. getClassName(): string;
  36145. /**
  36146. * Get the friendly name associated with the input class.
  36147. * @returns the input's friendly name.
  36148. */
  36149. getSimpleName(): string;
  36150. private _pointerInput;
  36151. private _onMouseMove;
  36152. /**
  36153. * Rotate camera by mouse offset.
  36154. */
  36155. private rotateCamera;
  36156. }
  36157. }
  36158. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36159. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36160. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36161. /**
  36162. * Default Inputs manager for the FlyCamera.
  36163. * It groups all the default supported inputs for ease of use.
  36164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36165. */
  36166. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36167. /**
  36168. * Instantiates a new FlyCameraInputsManager.
  36169. * @param camera Defines the camera the inputs belong to.
  36170. */
  36171. constructor(camera: FlyCamera);
  36172. /**
  36173. * Add keyboard input support to the input manager.
  36174. * @returns the new FlyCameraKeyboardMoveInput().
  36175. */
  36176. addKeyboard(): FlyCameraInputsManager;
  36177. /**
  36178. * Add mouse input support to the input manager.
  36179. * @param touchEnabled Enable touch screen support.
  36180. * @returns the new FlyCameraMouseInput().
  36181. */
  36182. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36183. }
  36184. }
  36185. declare module "babylonjs/Cameras/flyCamera" {
  36186. import { Scene } from "babylonjs/scene";
  36187. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36189. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36190. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36191. /**
  36192. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36193. * such as in a 3D Space Shooter or a Flight Simulator.
  36194. */
  36195. export class FlyCamera extends TargetCamera {
  36196. /**
  36197. * Define the collision ellipsoid of the camera.
  36198. * This is helpful for simulating a camera body, like a player's body.
  36199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36200. */
  36201. ellipsoid: Vector3;
  36202. /**
  36203. * Define an offset for the position of the ellipsoid around the camera.
  36204. * This can be helpful if the camera is attached away from the player's body center,
  36205. * such as at its head.
  36206. */
  36207. ellipsoidOffset: Vector3;
  36208. /**
  36209. * Enable or disable collisions of the camera with the rest of the scene objects.
  36210. */
  36211. checkCollisions: boolean;
  36212. /**
  36213. * Enable or disable gravity on the camera.
  36214. */
  36215. applyGravity: boolean;
  36216. /**
  36217. * Define the current direction the camera is moving to.
  36218. */
  36219. cameraDirection: Vector3;
  36220. /**
  36221. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36222. * This overrides and empties cameraRotation.
  36223. */
  36224. rotationQuaternion: Quaternion;
  36225. /**
  36226. * Track Roll to maintain the wanted Rolling when looking around.
  36227. */
  36228. _trackRoll: number;
  36229. /**
  36230. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36231. */
  36232. rollCorrect: number;
  36233. /**
  36234. * Mimic a banked turn, Rolling the camera when Yawing.
  36235. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36236. */
  36237. bankedTurn: boolean;
  36238. /**
  36239. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36240. */
  36241. bankedTurnLimit: number;
  36242. /**
  36243. * Value of 0 disables the banked Roll.
  36244. * Value of 1 is equal to the Yaw angle in radians.
  36245. */
  36246. bankedTurnMultiplier: number;
  36247. /**
  36248. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36249. */
  36250. inputs: FlyCameraInputsManager;
  36251. /**
  36252. * Gets the input sensibility for mouse input.
  36253. * Higher values reduce sensitivity.
  36254. */
  36255. /**
  36256. * Sets the input sensibility for a mouse input.
  36257. * Higher values reduce sensitivity.
  36258. */
  36259. angularSensibility: number;
  36260. /**
  36261. * Get the keys for camera movement forward.
  36262. */
  36263. /**
  36264. * Set the keys for camera movement forward.
  36265. */
  36266. keysForward: number[];
  36267. /**
  36268. * Get the keys for camera movement backward.
  36269. */
  36270. keysBackward: number[];
  36271. /**
  36272. * Get the keys for camera movement up.
  36273. */
  36274. /**
  36275. * Set the keys for camera movement up.
  36276. */
  36277. keysUp: number[];
  36278. /**
  36279. * Get the keys for camera movement down.
  36280. */
  36281. /**
  36282. * Set the keys for camera movement down.
  36283. */
  36284. keysDown: number[];
  36285. /**
  36286. * Get the keys for camera movement left.
  36287. */
  36288. /**
  36289. * Set the keys for camera movement left.
  36290. */
  36291. keysLeft: number[];
  36292. /**
  36293. * Set the keys for camera movement right.
  36294. */
  36295. /**
  36296. * Set the keys for camera movement right.
  36297. */
  36298. keysRight: number[];
  36299. /**
  36300. * Event raised when the camera collides with a mesh in the scene.
  36301. */
  36302. onCollide: (collidedMesh: AbstractMesh) => void;
  36303. private _collider;
  36304. private _needMoveForGravity;
  36305. private _oldPosition;
  36306. private _diffPosition;
  36307. private _newPosition;
  36308. /** @hidden */
  36309. _localDirection: Vector3;
  36310. /** @hidden */
  36311. _transformedDirection: Vector3;
  36312. /**
  36313. * Instantiates a FlyCamera.
  36314. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36315. * such as in a 3D Space Shooter or a Flight Simulator.
  36316. * @param name Define the name of the camera in the scene.
  36317. * @param position Define the starting position of the camera in the scene.
  36318. * @param scene Define the scene the camera belongs to.
  36319. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36320. */
  36321. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36322. /**
  36323. * Attach a control to the HTML DOM element.
  36324. * @param element Defines the element that listens to the input events.
  36325. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36326. */
  36327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36328. /**
  36329. * Detach a control from the HTML DOM element.
  36330. * The camera will stop reacting to that input.
  36331. * @param element Defines the element that listens to the input events.
  36332. */
  36333. detachControl(element: HTMLElement): void;
  36334. private _collisionMask;
  36335. /**
  36336. * Get the mask that the camera ignores in collision events.
  36337. */
  36338. /**
  36339. * Set the mask that the camera ignores in collision events.
  36340. */
  36341. collisionMask: number;
  36342. /** @hidden */
  36343. _collideWithWorld(displacement: Vector3): void;
  36344. /** @hidden */
  36345. private _onCollisionPositionChange;
  36346. /** @hidden */
  36347. _checkInputs(): void;
  36348. /** @hidden */
  36349. _decideIfNeedsToMove(): boolean;
  36350. /** @hidden */
  36351. _updatePosition(): void;
  36352. /**
  36353. * Restore the Roll to its target value at the rate specified.
  36354. * @param rate - Higher means slower restoring.
  36355. * @hidden
  36356. */
  36357. restoreRoll(rate: number): void;
  36358. /**
  36359. * Destroy the camera and release the current resources held by it.
  36360. */
  36361. dispose(): void;
  36362. /**
  36363. * Get the current object class name.
  36364. * @returns the class name.
  36365. */
  36366. getClassName(): string;
  36367. }
  36368. }
  36369. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36370. import { Nullable } from "babylonjs/types";
  36371. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36372. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36373. /**
  36374. * Listen to keyboard events to control the camera.
  36375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36376. */
  36377. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36378. /**
  36379. * Defines the camera the input is attached to.
  36380. */
  36381. camera: FlyCamera;
  36382. /**
  36383. * The list of keyboard keys used to control the forward move of the camera.
  36384. */
  36385. keysForward: number[];
  36386. /**
  36387. * The list of keyboard keys used to control the backward move of the camera.
  36388. */
  36389. keysBackward: number[];
  36390. /**
  36391. * The list of keyboard keys used to control the forward move of the camera.
  36392. */
  36393. keysUp: number[];
  36394. /**
  36395. * The list of keyboard keys used to control the backward move of the camera.
  36396. */
  36397. keysDown: number[];
  36398. /**
  36399. * The list of keyboard keys used to control the right strafe move of the camera.
  36400. */
  36401. keysRight: number[];
  36402. /**
  36403. * The list of keyboard keys used to control the left strafe move of the camera.
  36404. */
  36405. keysLeft: number[];
  36406. private _keys;
  36407. private _onCanvasBlurObserver;
  36408. private _onKeyboardObserver;
  36409. private _engine;
  36410. private _scene;
  36411. /**
  36412. * Attach the input controls to a specific dom element to get the input from.
  36413. * @param element Defines the element the controls should be listened from
  36414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36415. */
  36416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36417. /**
  36418. * Detach the current controls from the specified dom element.
  36419. * @param element Defines the element to stop listening the inputs from
  36420. */
  36421. detachControl(element: Nullable<HTMLElement>): void;
  36422. /**
  36423. * Gets the class name of the current intput.
  36424. * @returns the class name
  36425. */
  36426. getClassName(): string;
  36427. /** @hidden */
  36428. _onLostFocus(e: FocusEvent): void;
  36429. /**
  36430. * Get the friendly name associated with the input class.
  36431. * @returns the input friendly name
  36432. */
  36433. getSimpleName(): string;
  36434. /**
  36435. * Update the current camera state depending on the inputs that have been used this frame.
  36436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36437. */
  36438. checkInputs(): void;
  36439. }
  36440. }
  36441. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36442. import { Nullable } from "babylonjs/types";
  36443. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36444. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36445. module "babylonjs/Cameras/freeCameraInputsManager" {
  36446. interface FreeCameraInputsManager {
  36447. /**
  36448. * Add orientation input support to the input manager.
  36449. * @returns the current input manager
  36450. */
  36451. addDeviceOrientation(): FreeCameraInputsManager;
  36452. }
  36453. }
  36454. /**
  36455. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36456. * Screen rotation is taken into account.
  36457. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36458. */
  36459. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36460. private _camera;
  36461. private _screenOrientationAngle;
  36462. private _constantTranform;
  36463. private _screenQuaternion;
  36464. private _alpha;
  36465. private _beta;
  36466. private _gamma;
  36467. /**
  36468. * Instantiates a new input
  36469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36470. */
  36471. constructor();
  36472. /**
  36473. * Define the camera controlled by the input.
  36474. */
  36475. camera: FreeCamera;
  36476. /**
  36477. * Attach the input controls to a specific dom element to get the input from.
  36478. * @param element Defines the element the controls should be listened from
  36479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36480. */
  36481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36482. private _orientationChanged;
  36483. private _deviceOrientation;
  36484. /**
  36485. * Detach the current controls from the specified dom element.
  36486. * @param element Defines the element to stop listening the inputs from
  36487. */
  36488. detachControl(element: Nullable<HTMLElement>): void;
  36489. /**
  36490. * Update the current camera state depending on the inputs that have been used this frame.
  36491. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36492. */
  36493. checkInputs(): void;
  36494. /**
  36495. * Gets the class name of the current intput.
  36496. * @returns the class name
  36497. */
  36498. getClassName(): string;
  36499. /**
  36500. * Get the friendly name associated with the input class.
  36501. * @returns the input friendly name
  36502. */
  36503. getSimpleName(): string;
  36504. }
  36505. }
  36506. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36507. import { Nullable } from "babylonjs/types";
  36508. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36510. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36511. /**
  36512. * Manage the gamepad inputs to control a free camera.
  36513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36514. */
  36515. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36516. /**
  36517. * Define the camera the input is attached to.
  36518. */
  36519. camera: FreeCamera;
  36520. /**
  36521. * Define the Gamepad controlling the input
  36522. */
  36523. gamepad: Nullable<Gamepad>;
  36524. /**
  36525. * Defines the gamepad rotation sensiblity.
  36526. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36527. */
  36528. gamepadAngularSensibility: number;
  36529. /**
  36530. * Defines the gamepad move sensiblity.
  36531. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36532. */
  36533. gamepadMoveSensibility: number;
  36534. private _onGamepadConnectedObserver;
  36535. private _onGamepadDisconnectedObserver;
  36536. private _cameraTransform;
  36537. private _deltaTransform;
  36538. private _vector3;
  36539. private _vector2;
  36540. /**
  36541. * Attach the input controls to a specific dom element to get the input from.
  36542. * @param element Defines the element the controls should be listened from
  36543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36544. */
  36545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36546. /**
  36547. * Detach the current controls from the specified dom element.
  36548. * @param element Defines the element to stop listening the inputs from
  36549. */
  36550. detachControl(element: Nullable<HTMLElement>): void;
  36551. /**
  36552. * Update the current camera state depending on the inputs that have been used this frame.
  36553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36554. */
  36555. checkInputs(): void;
  36556. /**
  36557. * Gets the class name of the current intput.
  36558. * @returns the class name
  36559. */
  36560. getClassName(): string;
  36561. /**
  36562. * Get the friendly name associated with the input class.
  36563. * @returns the input friendly name
  36564. */
  36565. getSimpleName(): string;
  36566. }
  36567. }
  36568. declare module "babylonjs/Misc/virtualJoystick" {
  36569. import { Nullable } from "babylonjs/types";
  36570. import { Vector3 } from "babylonjs/Maths/math";
  36571. /**
  36572. * Defines the potential axis of a Joystick
  36573. */
  36574. export enum JoystickAxis {
  36575. /** X axis */
  36576. X = 0,
  36577. /** Y axis */
  36578. Y = 1,
  36579. /** Z axis */
  36580. Z = 2
  36581. }
  36582. /**
  36583. * Class used to define virtual joystick (used in touch mode)
  36584. */
  36585. export class VirtualJoystick {
  36586. /**
  36587. * Gets or sets a boolean indicating that left and right values must be inverted
  36588. */
  36589. reverseLeftRight: boolean;
  36590. /**
  36591. * Gets or sets a boolean indicating that up and down values must be inverted
  36592. */
  36593. reverseUpDown: boolean;
  36594. /**
  36595. * Gets the offset value for the position (ie. the change of the position value)
  36596. */
  36597. deltaPosition: Vector3;
  36598. /**
  36599. * Gets a boolean indicating if the virtual joystick was pressed
  36600. */
  36601. pressed: boolean;
  36602. /**
  36603. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36604. */
  36605. static Canvas: Nullable<HTMLCanvasElement>;
  36606. private static _globalJoystickIndex;
  36607. private static vjCanvasContext;
  36608. private static vjCanvasWidth;
  36609. private static vjCanvasHeight;
  36610. private static halfWidth;
  36611. private _action;
  36612. private _axisTargetedByLeftAndRight;
  36613. private _axisTargetedByUpAndDown;
  36614. private _joystickSensibility;
  36615. private _inversedSensibility;
  36616. private _joystickPointerID;
  36617. private _joystickColor;
  36618. private _joystickPointerPos;
  36619. private _joystickPreviousPointerPos;
  36620. private _joystickPointerStartPos;
  36621. private _deltaJoystickVector;
  36622. private _leftJoystick;
  36623. private _touches;
  36624. private _onPointerDownHandlerRef;
  36625. private _onPointerMoveHandlerRef;
  36626. private _onPointerUpHandlerRef;
  36627. private _onResize;
  36628. /**
  36629. * Creates a new virtual joystick
  36630. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36631. */
  36632. constructor(leftJoystick?: boolean);
  36633. /**
  36634. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36635. * @param newJoystickSensibility defines the new sensibility
  36636. */
  36637. setJoystickSensibility(newJoystickSensibility: number): void;
  36638. private _onPointerDown;
  36639. private _onPointerMove;
  36640. private _onPointerUp;
  36641. /**
  36642. * Change the color of the virtual joystick
  36643. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36644. */
  36645. setJoystickColor(newColor: string): void;
  36646. /**
  36647. * Defines a callback to call when the joystick is touched
  36648. * @param action defines the callback
  36649. */
  36650. setActionOnTouch(action: () => any): void;
  36651. /**
  36652. * Defines which axis you'd like to control for left & right
  36653. * @param axis defines the axis to use
  36654. */
  36655. setAxisForLeftRight(axis: JoystickAxis): void;
  36656. /**
  36657. * Defines which axis you'd like to control for up & down
  36658. * @param axis defines the axis to use
  36659. */
  36660. setAxisForUpDown(axis: JoystickAxis): void;
  36661. private _drawVirtualJoystick;
  36662. /**
  36663. * Release internal HTML canvas
  36664. */
  36665. releaseCanvas(): void;
  36666. }
  36667. }
  36668. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36669. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36670. import { Nullable } from "babylonjs/types";
  36671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36672. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36673. module "babylonjs/Cameras/freeCameraInputsManager" {
  36674. interface FreeCameraInputsManager {
  36675. /**
  36676. * Add virtual joystick input support to the input manager.
  36677. * @returns the current input manager
  36678. */
  36679. addVirtualJoystick(): FreeCameraInputsManager;
  36680. }
  36681. }
  36682. /**
  36683. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36685. */
  36686. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36687. /**
  36688. * Defines the camera the input is attached to.
  36689. */
  36690. camera: FreeCamera;
  36691. private _leftjoystick;
  36692. private _rightjoystick;
  36693. /**
  36694. * Gets the left stick of the virtual joystick.
  36695. * @returns The virtual Joystick
  36696. */
  36697. getLeftJoystick(): VirtualJoystick;
  36698. /**
  36699. * Gets the right stick of the virtual joystick.
  36700. * @returns The virtual Joystick
  36701. */
  36702. getRightJoystick(): VirtualJoystick;
  36703. /**
  36704. * Update the current camera state depending on the inputs that have been used this frame.
  36705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36706. */
  36707. checkInputs(): void;
  36708. /**
  36709. * Attach the input controls to a specific dom element to get the input from.
  36710. * @param element Defines the element the controls should be listened from
  36711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36712. */
  36713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36714. /**
  36715. * Detach the current controls from the specified dom element.
  36716. * @param element Defines the element to stop listening the inputs from
  36717. */
  36718. detachControl(element: Nullable<HTMLElement>): void;
  36719. /**
  36720. * Gets the class name of the current intput.
  36721. * @returns the class name
  36722. */
  36723. getClassName(): string;
  36724. /**
  36725. * Get the friendly name associated with the input class.
  36726. * @returns the input friendly name
  36727. */
  36728. getSimpleName(): string;
  36729. }
  36730. }
  36731. declare module "babylonjs/Cameras/Inputs/index" {
  36732. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36733. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36734. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36735. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36736. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36737. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36738. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36739. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36740. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36741. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36742. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36743. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36744. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36745. }
  36746. declare module "babylonjs/Cameras/touchCamera" {
  36747. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36748. import { Scene } from "babylonjs/scene";
  36749. import { Vector3 } from "babylonjs/Maths/math";
  36750. /**
  36751. * This represents a FPS type of camera controlled by touch.
  36752. * This is like a universal camera minus the Gamepad controls.
  36753. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36754. */
  36755. export class TouchCamera extends FreeCamera {
  36756. /**
  36757. * Defines the touch sensibility for rotation.
  36758. * The higher the faster.
  36759. */
  36760. touchAngularSensibility: number;
  36761. /**
  36762. * Defines the touch sensibility for move.
  36763. * The higher the faster.
  36764. */
  36765. touchMoveSensibility: number;
  36766. /**
  36767. * Instantiates a new touch camera.
  36768. * This represents a FPS type of camera controlled by touch.
  36769. * This is like a universal camera minus the Gamepad controls.
  36770. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36771. * @param name Define the name of the camera in the scene
  36772. * @param position Define the start position of the camera in the scene
  36773. * @param scene Define the scene the camera belongs to
  36774. */
  36775. constructor(name: string, position: Vector3, scene: Scene);
  36776. /**
  36777. * Gets the current object class name.
  36778. * @return the class name
  36779. */
  36780. getClassName(): string;
  36781. /** @hidden */
  36782. _setupInputs(): void;
  36783. }
  36784. }
  36785. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36786. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36787. import { Scene } from "babylonjs/scene";
  36788. import { Vector3, Axis } from "babylonjs/Maths/math";
  36789. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36790. /**
  36791. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36792. * being tilted forward or back and left or right.
  36793. */
  36794. export class DeviceOrientationCamera extends FreeCamera {
  36795. private _initialQuaternion;
  36796. private _quaternionCache;
  36797. /**
  36798. * Creates a new device orientation camera
  36799. * @param name The name of the camera
  36800. * @param position The start position camera
  36801. * @param scene The scene the camera belongs to
  36802. */
  36803. constructor(name: string, position: Vector3, scene: Scene);
  36804. /**
  36805. * Gets the current instance class name ("DeviceOrientationCamera").
  36806. * This helps avoiding instanceof at run time.
  36807. * @returns the class name
  36808. */
  36809. getClassName(): string;
  36810. /**
  36811. * @hidden
  36812. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36813. */
  36814. _checkInputs(): void;
  36815. /**
  36816. * Reset the camera to its default orientation on the specified axis only.
  36817. * @param axis The axis to reset
  36818. */
  36819. resetToCurrentRotation(axis?: Axis): void;
  36820. }
  36821. }
  36822. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36823. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36824. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36825. import { Nullable } from "babylonjs/types";
  36826. /**
  36827. * Manage the keyboard inputs to control the movement of a follow camera.
  36828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36829. */
  36830. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36831. /**
  36832. * Defines the camera the input is attached to.
  36833. */
  36834. camera: FollowCamera;
  36835. /**
  36836. * Defines the list of key codes associated with the up action (increase heightOffset)
  36837. */
  36838. keysHeightOffsetIncr: number[];
  36839. /**
  36840. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36841. */
  36842. keysHeightOffsetDecr: number[];
  36843. /**
  36844. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36845. */
  36846. keysHeightOffsetModifierAlt: boolean;
  36847. /**
  36848. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36849. */
  36850. keysHeightOffsetModifierCtrl: boolean;
  36851. /**
  36852. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36853. */
  36854. keysHeightOffsetModifierShift: boolean;
  36855. /**
  36856. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36857. */
  36858. keysRotationOffsetIncr: number[];
  36859. /**
  36860. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36861. */
  36862. keysRotationOffsetDecr: number[];
  36863. /**
  36864. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36865. */
  36866. keysRotationOffsetModifierAlt: boolean;
  36867. /**
  36868. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36869. */
  36870. keysRotationOffsetModifierCtrl: boolean;
  36871. /**
  36872. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36873. */
  36874. keysRotationOffsetModifierShift: boolean;
  36875. /**
  36876. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36877. */
  36878. keysRadiusIncr: number[];
  36879. /**
  36880. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36881. */
  36882. keysRadiusDecr: number[];
  36883. /**
  36884. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36885. */
  36886. keysRadiusModifierAlt: boolean;
  36887. /**
  36888. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36889. */
  36890. keysRadiusModifierCtrl: boolean;
  36891. /**
  36892. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36893. */
  36894. keysRadiusModifierShift: boolean;
  36895. /**
  36896. * Defines the rate of change of heightOffset.
  36897. */
  36898. heightSensibility: number;
  36899. /**
  36900. * Defines the rate of change of rotationOffset.
  36901. */
  36902. rotationSensibility: number;
  36903. /**
  36904. * Defines the rate of change of radius.
  36905. */
  36906. radiusSensibility: number;
  36907. private _keys;
  36908. private _ctrlPressed;
  36909. private _altPressed;
  36910. private _shiftPressed;
  36911. private _onCanvasBlurObserver;
  36912. private _onKeyboardObserver;
  36913. private _engine;
  36914. private _scene;
  36915. /**
  36916. * Attach the input controls to a specific dom element to get the input from.
  36917. * @param element Defines the element the controls should be listened from
  36918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36919. */
  36920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36921. /**
  36922. * Detach the current controls from the specified dom element.
  36923. * @param element Defines the element to stop listening the inputs from
  36924. */
  36925. detachControl(element: Nullable<HTMLElement>): void;
  36926. /**
  36927. * Update the current camera state depending on the inputs that have been used this frame.
  36928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36929. */
  36930. checkInputs(): void;
  36931. /**
  36932. * Gets the class name of the current input.
  36933. * @returns the class name
  36934. */
  36935. getClassName(): string;
  36936. /**
  36937. * Get the friendly name associated with the input class.
  36938. * @returns the input friendly name
  36939. */
  36940. getSimpleName(): string;
  36941. /**
  36942. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36943. * allow modification of the heightOffset value.
  36944. */
  36945. private _modifierHeightOffset;
  36946. /**
  36947. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36948. * allow modification of the rotationOffset value.
  36949. */
  36950. private _modifierRotationOffset;
  36951. /**
  36952. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36953. * allow modification of the radius value.
  36954. */
  36955. private _modifierRadius;
  36956. }
  36957. }
  36958. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36959. import { Nullable } from "babylonjs/types";
  36960. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36961. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36962. /**
  36963. * Manage the mouse wheel inputs to control a follow camera.
  36964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36965. */
  36966. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36967. /**
  36968. * Defines the camera the input is attached to.
  36969. */
  36970. camera: FollowCamera;
  36971. /**
  36972. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36973. */
  36974. axisControlRadius: boolean;
  36975. /**
  36976. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36977. */
  36978. axisControlHeight: boolean;
  36979. /**
  36980. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36981. */
  36982. axisControlRotation: boolean;
  36983. /**
  36984. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36985. * relation to mouseWheel events.
  36986. */
  36987. wheelPrecision: number;
  36988. /**
  36989. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36990. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36991. */
  36992. wheelDeltaPercentage: number;
  36993. private _wheel;
  36994. private _observer;
  36995. /**
  36996. * Attach the input controls to a specific dom element to get the input from.
  36997. * @param element Defines the element the controls should be listened from
  36998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36999. */
  37000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37001. /**
  37002. * Detach the current controls from the specified dom element.
  37003. * @param element Defines the element to stop listening the inputs from
  37004. */
  37005. detachControl(element: Nullable<HTMLElement>): void;
  37006. /**
  37007. * Gets the class name of the current intput.
  37008. * @returns the class name
  37009. */
  37010. getClassName(): string;
  37011. /**
  37012. * Get the friendly name associated with the input class.
  37013. * @returns the input friendly name
  37014. */
  37015. getSimpleName(): string;
  37016. }
  37017. }
  37018. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37019. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37020. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37021. /**
  37022. * Default Inputs manager for the FollowCamera.
  37023. * It groups all the default supported inputs for ease of use.
  37024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37025. */
  37026. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37027. /**
  37028. * Instantiates a new FollowCameraInputsManager.
  37029. * @param camera Defines the camera the inputs belong to
  37030. */
  37031. constructor(camera: FollowCamera);
  37032. /**
  37033. * Add keyboard input support to the input manager.
  37034. * @returns the current input manager
  37035. */
  37036. addKeyboard(): FollowCameraInputsManager;
  37037. /**
  37038. * Add mouse wheel input support to the input manager.
  37039. * @returns the current input manager
  37040. */
  37041. addMouseWheel(): FollowCameraInputsManager;
  37042. /**
  37043. * Add pointers input support to the input manager.
  37044. * @returns the current input manager
  37045. */
  37046. addPointers(): FollowCameraInputsManager;
  37047. /**
  37048. * Add orientation input support to the input manager.
  37049. * @returns the current input manager
  37050. */
  37051. addVRDeviceOrientation(): FollowCameraInputsManager;
  37052. }
  37053. }
  37054. declare module "babylonjs/Cameras/followCamera" {
  37055. import { Nullable } from "babylonjs/types";
  37056. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37057. import { Scene } from "babylonjs/scene";
  37058. import { Vector3 } from "babylonjs/Maths/math";
  37059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37060. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37061. /**
  37062. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37063. * an arc rotate version arcFollowCamera are available.
  37064. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37065. */
  37066. export class FollowCamera extends TargetCamera {
  37067. /**
  37068. * Distance the follow camera should follow an object at
  37069. */
  37070. radius: number;
  37071. /**
  37072. * Minimum allowed distance of the camera to the axis of rotation
  37073. * (The camera can not get closer).
  37074. * This can help limiting how the Camera is able to move in the scene.
  37075. */
  37076. lowerRadiusLimit: Nullable<number>;
  37077. /**
  37078. * Maximum allowed distance of the camera to the axis of rotation
  37079. * (The camera can not get further).
  37080. * This can help limiting how the Camera is able to move in the scene.
  37081. */
  37082. upperRadiusLimit: Nullable<number>;
  37083. /**
  37084. * Define a rotation offset between the camera and the object it follows
  37085. */
  37086. rotationOffset: number;
  37087. /**
  37088. * Minimum allowed angle to camera position relative to target object.
  37089. * This can help limiting how the Camera is able to move in the scene.
  37090. */
  37091. lowerRotationOffsetLimit: Nullable<number>;
  37092. /**
  37093. * Maximum allowed angle to camera position relative to target object.
  37094. * This can help limiting how the Camera is able to move in the scene.
  37095. */
  37096. upperRotationOffsetLimit: Nullable<number>;
  37097. /**
  37098. * Define a height offset between the camera and the object it follows.
  37099. * It can help following an object from the top (like a car chaing a plane)
  37100. */
  37101. heightOffset: number;
  37102. /**
  37103. * Minimum allowed height of camera position relative to target object.
  37104. * This can help limiting how the Camera is able to move in the scene.
  37105. */
  37106. lowerHeightOffsetLimit: Nullable<number>;
  37107. /**
  37108. * Maximum allowed height of camera position relative to target object.
  37109. * This can help limiting how the Camera is able to move in the scene.
  37110. */
  37111. upperHeightOffsetLimit: Nullable<number>;
  37112. /**
  37113. * Define how fast the camera can accelerate to follow it s target.
  37114. */
  37115. cameraAcceleration: number;
  37116. /**
  37117. * Define the speed limit of the camera following an object.
  37118. */
  37119. maxCameraSpeed: number;
  37120. /**
  37121. * Define the target of the camera.
  37122. */
  37123. lockedTarget: Nullable<AbstractMesh>;
  37124. /**
  37125. * Defines the input associated with the camera.
  37126. */
  37127. inputs: FollowCameraInputsManager;
  37128. /**
  37129. * Instantiates the follow camera.
  37130. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37131. * @param name Define the name of the camera in the scene
  37132. * @param position Define the position of the camera
  37133. * @param scene Define the scene the camera belong to
  37134. * @param lockedTarget Define the target of the camera
  37135. */
  37136. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37137. private _follow;
  37138. /**
  37139. * Attached controls to the current camera.
  37140. * @param element Defines the element the controls should be listened from
  37141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37142. */
  37143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37144. /**
  37145. * Detach the current controls from the camera.
  37146. * The camera will stop reacting to inputs.
  37147. * @param element Defines the element to stop listening the inputs from
  37148. */
  37149. detachControl(element: HTMLElement): void;
  37150. /** @hidden */
  37151. _checkInputs(): void;
  37152. private _checkLimits;
  37153. /**
  37154. * Gets the camera class name.
  37155. * @returns the class name
  37156. */
  37157. getClassName(): string;
  37158. }
  37159. /**
  37160. * Arc Rotate version of the follow camera.
  37161. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37162. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37163. */
  37164. export class ArcFollowCamera extends TargetCamera {
  37165. /** The longitudinal angle of the camera */
  37166. alpha: number;
  37167. /** The latitudinal angle of the camera */
  37168. beta: number;
  37169. /** The radius of the camera from its target */
  37170. radius: number;
  37171. /** Define the camera target (the messh it should follow) */
  37172. target: Nullable<AbstractMesh>;
  37173. private _cartesianCoordinates;
  37174. /**
  37175. * Instantiates a new ArcFollowCamera
  37176. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37177. * @param name Define the name of the camera
  37178. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37179. * @param beta Define the rotation angle of the camera around the elevation axis
  37180. * @param radius Define the radius of the camera from its target point
  37181. * @param target Define the target of the camera
  37182. * @param scene Define the scene the camera belongs to
  37183. */
  37184. constructor(name: string,
  37185. /** The longitudinal angle of the camera */
  37186. alpha: number,
  37187. /** The latitudinal angle of the camera */
  37188. beta: number,
  37189. /** The radius of the camera from its target */
  37190. radius: number,
  37191. /** Define the camera target (the messh it should follow) */
  37192. target: Nullable<AbstractMesh>, scene: Scene);
  37193. private _follow;
  37194. /** @hidden */
  37195. _checkInputs(): void;
  37196. /**
  37197. * Returns the class name of the object.
  37198. * It is mostly used internally for serialization purposes.
  37199. */
  37200. getClassName(): string;
  37201. }
  37202. }
  37203. declare module "babylonjs/Cameras/universalCamera" {
  37204. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37205. import { Scene } from "babylonjs/scene";
  37206. import { Vector3 } from "babylonjs/Maths/math";
  37207. /**
  37208. * 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,
  37209. * which still works and will still be found in many Playgrounds.
  37210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37211. */
  37212. export class UniversalCamera extends TouchCamera {
  37213. /**
  37214. * Defines the gamepad rotation sensiblity.
  37215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37216. */
  37217. gamepadAngularSensibility: number;
  37218. /**
  37219. * Defines the gamepad move sensiblity.
  37220. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37221. */
  37222. gamepadMoveSensibility: number;
  37223. /**
  37224. * 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,
  37225. * which still works and will still be found in many Playgrounds.
  37226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37227. * @param name Define the name of the camera in the scene
  37228. * @param position Define the start position of the camera in the scene
  37229. * @param scene Define the scene the camera belongs to
  37230. */
  37231. constructor(name: string, position: Vector3, scene: Scene);
  37232. /**
  37233. * Gets the current object class name.
  37234. * @return the class name
  37235. */
  37236. getClassName(): string;
  37237. }
  37238. }
  37239. declare module "babylonjs/Cameras/gamepadCamera" {
  37240. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37241. import { Scene } from "babylonjs/scene";
  37242. import { Vector3 } from "babylonjs/Maths/math";
  37243. /**
  37244. * This represents a FPS type of camera. This is only here for back compat purpose.
  37245. * Please use the UniversalCamera instead as both are identical.
  37246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37247. */
  37248. export class GamepadCamera extends UniversalCamera {
  37249. /**
  37250. * Instantiates a new Gamepad Camera
  37251. * This represents a FPS type of camera. This is only here for back compat purpose.
  37252. * Please use the UniversalCamera instead as both are identical.
  37253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37254. * @param name Define the name of the camera in the scene
  37255. * @param position Define the start position of the camera in the scene
  37256. * @param scene Define the scene the camera belongs to
  37257. */
  37258. constructor(name: string, position: Vector3, scene: Scene);
  37259. /**
  37260. * Gets the current object class name.
  37261. * @return the class name
  37262. */
  37263. getClassName(): string;
  37264. }
  37265. }
  37266. declare module "babylonjs/Shaders/pass.fragment" {
  37267. /** @hidden */
  37268. export var passPixelShader: {
  37269. name: string;
  37270. shader: string;
  37271. };
  37272. }
  37273. declare module "babylonjs/Shaders/passCube.fragment" {
  37274. /** @hidden */
  37275. export var passCubePixelShader: {
  37276. name: string;
  37277. shader: string;
  37278. };
  37279. }
  37280. declare module "babylonjs/PostProcesses/passPostProcess" {
  37281. import { Nullable } from "babylonjs/types";
  37282. import { Camera } from "babylonjs/Cameras/camera";
  37283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37284. import { Engine } from "babylonjs/Engines/engine";
  37285. import "babylonjs/Shaders/pass.fragment";
  37286. import "babylonjs/Shaders/passCube.fragment";
  37287. /**
  37288. * PassPostProcess which produces an output the same as it's input
  37289. */
  37290. export class PassPostProcess extends PostProcess {
  37291. /**
  37292. * Creates the PassPostProcess
  37293. * @param name The name of the effect.
  37294. * @param options The required width/height ratio to downsize to before computing the render pass.
  37295. * @param camera The camera to apply the render pass to.
  37296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37297. * @param engine The engine which the post process will be applied. (default: current engine)
  37298. * @param reusable If the post process can be reused on the same frame. (default: false)
  37299. * @param textureType The type of texture to be used when performing the post processing.
  37300. * @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)
  37301. */
  37302. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37303. }
  37304. /**
  37305. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37306. */
  37307. export class PassCubePostProcess extends PostProcess {
  37308. private _face;
  37309. /**
  37310. * Gets or sets the cube face to display.
  37311. * * 0 is +X
  37312. * * 1 is -X
  37313. * * 2 is +Y
  37314. * * 3 is -Y
  37315. * * 4 is +Z
  37316. * * 5 is -Z
  37317. */
  37318. face: number;
  37319. /**
  37320. * Creates the PassCubePostProcess
  37321. * @param name The name of the effect.
  37322. * @param options The required width/height ratio to downsize to before computing the render pass.
  37323. * @param camera The camera to apply the render pass to.
  37324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37325. * @param engine The engine which the post process will be applied. (default: current engine)
  37326. * @param reusable If the post process can be reused on the same frame. (default: false)
  37327. * @param textureType The type of texture to be used when performing the post processing.
  37328. * @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)
  37329. */
  37330. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37331. }
  37332. }
  37333. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37334. /** @hidden */
  37335. export var anaglyphPixelShader: {
  37336. name: string;
  37337. shader: string;
  37338. };
  37339. }
  37340. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37341. import { Engine } from "babylonjs/Engines/engine";
  37342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37343. import { Camera } from "babylonjs/Cameras/camera";
  37344. import "babylonjs/Shaders/anaglyph.fragment";
  37345. /**
  37346. * Postprocess used to generate anaglyphic rendering
  37347. */
  37348. export class AnaglyphPostProcess extends PostProcess {
  37349. private _passedProcess;
  37350. /**
  37351. * Creates a new AnaglyphPostProcess
  37352. * @param name defines postprocess name
  37353. * @param options defines creation options or target ratio scale
  37354. * @param rigCameras defines cameras using this postprocess
  37355. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37356. * @param engine defines hosting engine
  37357. * @param reusable defines if the postprocess will be reused multiple times per frame
  37358. */
  37359. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37360. }
  37361. }
  37362. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37363. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37364. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37365. import { Scene } from "babylonjs/scene";
  37366. import { Vector3 } from "babylonjs/Maths/math";
  37367. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37368. /**
  37369. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37370. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37371. */
  37372. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37373. /**
  37374. * Creates a new AnaglyphArcRotateCamera
  37375. * @param name defines camera name
  37376. * @param alpha defines alpha angle (in radians)
  37377. * @param beta defines beta angle (in radians)
  37378. * @param radius defines radius
  37379. * @param target defines camera target
  37380. * @param interaxialDistance defines distance between each color axis
  37381. * @param scene defines the hosting scene
  37382. */
  37383. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37384. /**
  37385. * Gets camera class name
  37386. * @returns AnaglyphArcRotateCamera
  37387. */
  37388. getClassName(): string;
  37389. }
  37390. }
  37391. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37392. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37393. import { Scene } from "babylonjs/scene";
  37394. import { Vector3 } from "babylonjs/Maths/math";
  37395. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37396. /**
  37397. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37398. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37399. */
  37400. export class AnaglyphFreeCamera extends FreeCamera {
  37401. /**
  37402. * Creates a new AnaglyphFreeCamera
  37403. * @param name defines camera name
  37404. * @param position defines initial position
  37405. * @param interaxialDistance defines distance between each color axis
  37406. * @param scene defines the hosting scene
  37407. */
  37408. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37409. /**
  37410. * Gets camera class name
  37411. * @returns AnaglyphFreeCamera
  37412. */
  37413. getClassName(): string;
  37414. }
  37415. }
  37416. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37417. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37418. import { Scene } from "babylonjs/scene";
  37419. import { Vector3 } from "babylonjs/Maths/math";
  37420. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37421. /**
  37422. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37423. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37424. */
  37425. export class AnaglyphGamepadCamera extends GamepadCamera {
  37426. /**
  37427. * Creates a new AnaglyphGamepadCamera
  37428. * @param name defines camera name
  37429. * @param position defines initial position
  37430. * @param interaxialDistance defines distance between each color axis
  37431. * @param scene defines the hosting scene
  37432. */
  37433. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37434. /**
  37435. * Gets camera class name
  37436. * @returns AnaglyphGamepadCamera
  37437. */
  37438. getClassName(): string;
  37439. }
  37440. }
  37441. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37442. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37443. import { Scene } from "babylonjs/scene";
  37444. import { Vector3 } from "babylonjs/Maths/math";
  37445. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37446. /**
  37447. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37449. */
  37450. export class AnaglyphUniversalCamera extends UniversalCamera {
  37451. /**
  37452. * Creates a new AnaglyphUniversalCamera
  37453. * @param name defines camera name
  37454. * @param position defines initial position
  37455. * @param interaxialDistance defines distance between each color axis
  37456. * @param scene defines the hosting scene
  37457. */
  37458. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37459. /**
  37460. * Gets camera class name
  37461. * @returns AnaglyphUniversalCamera
  37462. */
  37463. getClassName(): string;
  37464. }
  37465. }
  37466. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37467. /** @hidden */
  37468. export var stereoscopicInterlacePixelShader: {
  37469. name: string;
  37470. shader: string;
  37471. };
  37472. }
  37473. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37474. import { Camera } from "babylonjs/Cameras/camera";
  37475. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37476. import { Engine } from "babylonjs/Engines/engine";
  37477. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37478. /**
  37479. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37480. */
  37481. export class StereoscopicInterlacePostProcess extends PostProcess {
  37482. private _stepSize;
  37483. private _passedProcess;
  37484. /**
  37485. * Initializes a StereoscopicInterlacePostProcess
  37486. * @param name The name of the effect.
  37487. * @param rigCameras The rig cameras to be appled to the post process
  37488. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37490. * @param engine The engine which the post process will be applied. (default: current engine)
  37491. * @param reusable If the post process can be reused on the same frame. (default: false)
  37492. */
  37493. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37494. }
  37495. }
  37496. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37497. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37499. import { Scene } from "babylonjs/scene";
  37500. import { Vector3 } from "babylonjs/Maths/math";
  37501. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37502. /**
  37503. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37504. * @see http://doc.babylonjs.com/features/cameras
  37505. */
  37506. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37507. /**
  37508. * Creates a new StereoscopicArcRotateCamera
  37509. * @param name defines camera name
  37510. * @param alpha defines alpha angle (in radians)
  37511. * @param beta defines beta angle (in radians)
  37512. * @param radius defines radius
  37513. * @param target defines camera target
  37514. * @param interaxialDistance defines distance between each color axis
  37515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37516. * @param scene defines the hosting scene
  37517. */
  37518. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37519. /**
  37520. * Gets camera class name
  37521. * @returns StereoscopicArcRotateCamera
  37522. */
  37523. getClassName(): string;
  37524. }
  37525. }
  37526. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37527. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37528. import { Scene } from "babylonjs/scene";
  37529. import { Vector3 } from "babylonjs/Maths/math";
  37530. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37531. /**
  37532. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37533. * @see http://doc.babylonjs.com/features/cameras
  37534. */
  37535. export class StereoscopicFreeCamera extends FreeCamera {
  37536. /**
  37537. * Creates a new StereoscopicFreeCamera
  37538. * @param name defines camera name
  37539. * @param position defines initial position
  37540. * @param interaxialDistance defines distance between each color axis
  37541. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37542. * @param scene defines the hosting scene
  37543. */
  37544. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37545. /**
  37546. * Gets camera class name
  37547. * @returns StereoscopicFreeCamera
  37548. */
  37549. getClassName(): string;
  37550. }
  37551. }
  37552. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37553. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37554. import { Scene } from "babylonjs/scene";
  37555. import { Vector3 } from "babylonjs/Maths/math";
  37556. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37557. /**
  37558. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37559. * @see http://doc.babylonjs.com/features/cameras
  37560. */
  37561. export class StereoscopicGamepadCamera extends GamepadCamera {
  37562. /**
  37563. * Creates a new StereoscopicGamepadCamera
  37564. * @param name defines camera name
  37565. * @param position defines initial position
  37566. * @param interaxialDistance defines distance between each color axis
  37567. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37568. * @param scene defines the hosting scene
  37569. */
  37570. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37571. /**
  37572. * Gets camera class name
  37573. * @returns StereoscopicGamepadCamera
  37574. */
  37575. getClassName(): string;
  37576. }
  37577. }
  37578. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37579. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37580. import { Scene } from "babylonjs/scene";
  37581. import { Vector3 } from "babylonjs/Maths/math";
  37582. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37583. /**
  37584. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37585. * @see http://doc.babylonjs.com/features/cameras
  37586. */
  37587. export class StereoscopicUniversalCamera extends UniversalCamera {
  37588. /**
  37589. * Creates a new StereoscopicUniversalCamera
  37590. * @param name defines camera name
  37591. * @param position defines initial position
  37592. * @param interaxialDistance defines distance between each color axis
  37593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37594. * @param scene defines the hosting scene
  37595. */
  37596. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37597. /**
  37598. * Gets camera class name
  37599. * @returns StereoscopicUniversalCamera
  37600. */
  37601. getClassName(): string;
  37602. }
  37603. }
  37604. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37605. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37606. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37607. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37608. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37609. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37610. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37611. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37612. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37613. }
  37614. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37615. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37616. import { Scene } from "babylonjs/scene";
  37617. import { Vector3 } from "babylonjs/Maths/math";
  37618. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37619. /**
  37620. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37621. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37622. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37623. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37624. */
  37625. export class VirtualJoysticksCamera extends FreeCamera {
  37626. /**
  37627. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37628. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37629. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37630. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37631. * @param name Define the name of the camera in the scene
  37632. * @param position Define the start position of the camera in the scene
  37633. * @param scene Define the scene the camera belongs to
  37634. */
  37635. constructor(name: string, position: Vector3, scene: Scene);
  37636. /**
  37637. * Gets the current object class name.
  37638. * @return the class name
  37639. */
  37640. getClassName(): string;
  37641. }
  37642. }
  37643. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37644. import { Matrix } from "babylonjs/Maths/math";
  37645. /**
  37646. * This represents all the required metrics to create a VR camera.
  37647. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37648. */
  37649. export class VRCameraMetrics {
  37650. /**
  37651. * Define the horizontal resolution off the screen.
  37652. */
  37653. hResolution: number;
  37654. /**
  37655. * Define the vertical resolution off the screen.
  37656. */
  37657. vResolution: number;
  37658. /**
  37659. * Define the horizontal screen size.
  37660. */
  37661. hScreenSize: number;
  37662. /**
  37663. * Define the vertical screen size.
  37664. */
  37665. vScreenSize: number;
  37666. /**
  37667. * Define the vertical screen center position.
  37668. */
  37669. vScreenCenter: number;
  37670. /**
  37671. * Define the distance of the eyes to the screen.
  37672. */
  37673. eyeToScreenDistance: number;
  37674. /**
  37675. * Define the distance between both lenses
  37676. */
  37677. lensSeparationDistance: number;
  37678. /**
  37679. * Define the distance between both viewer's eyes.
  37680. */
  37681. interpupillaryDistance: number;
  37682. /**
  37683. * Define the distortion factor of the VR postprocess.
  37684. * Please, touch with care.
  37685. */
  37686. distortionK: number[];
  37687. /**
  37688. * Define the chromatic aberration correction factors for the VR post process.
  37689. */
  37690. chromaAbCorrection: number[];
  37691. /**
  37692. * Define the scale factor of the post process.
  37693. * The smaller the better but the slower.
  37694. */
  37695. postProcessScaleFactor: number;
  37696. /**
  37697. * Define an offset for the lens center.
  37698. */
  37699. lensCenterOffset: number;
  37700. /**
  37701. * Define if the current vr camera should compensate the distortion of the lense or not.
  37702. */
  37703. compensateDistortion: boolean;
  37704. /**
  37705. * Gets the rendering aspect ratio based on the provided resolutions.
  37706. */
  37707. readonly aspectRatio: number;
  37708. /**
  37709. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37710. */
  37711. readonly aspectRatioFov: number;
  37712. /**
  37713. * @hidden
  37714. */
  37715. readonly leftHMatrix: Matrix;
  37716. /**
  37717. * @hidden
  37718. */
  37719. readonly rightHMatrix: Matrix;
  37720. /**
  37721. * @hidden
  37722. */
  37723. readonly leftPreViewMatrix: Matrix;
  37724. /**
  37725. * @hidden
  37726. */
  37727. readonly rightPreViewMatrix: Matrix;
  37728. /**
  37729. * Get the default VRMetrics based on the most generic setup.
  37730. * @returns the default vr metrics
  37731. */
  37732. static GetDefault(): VRCameraMetrics;
  37733. }
  37734. }
  37735. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37736. /** @hidden */
  37737. export var vrDistortionCorrectionPixelShader: {
  37738. name: string;
  37739. shader: string;
  37740. };
  37741. }
  37742. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37743. import { Camera } from "babylonjs/Cameras/camera";
  37744. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37745. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37746. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37747. /**
  37748. * VRDistortionCorrectionPostProcess used for mobile VR
  37749. */
  37750. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37751. private _isRightEye;
  37752. private _distortionFactors;
  37753. private _postProcessScaleFactor;
  37754. private _lensCenterOffset;
  37755. private _scaleIn;
  37756. private _scaleFactor;
  37757. private _lensCenter;
  37758. /**
  37759. * Initializes the VRDistortionCorrectionPostProcess
  37760. * @param name The name of the effect.
  37761. * @param camera The camera to apply the render pass to.
  37762. * @param isRightEye If this is for the right eye distortion
  37763. * @param vrMetrics All the required metrics for the VR camera
  37764. */
  37765. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37766. }
  37767. }
  37768. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37769. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37770. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37771. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37772. import { Scene } from "babylonjs/scene";
  37773. import { Vector3 } from "babylonjs/Maths/math";
  37774. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37775. import "babylonjs/Cameras/RigModes/vrRigMode";
  37776. /**
  37777. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37778. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37779. */
  37780. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37781. /**
  37782. * Creates a new VRDeviceOrientationArcRotateCamera
  37783. * @param name defines camera name
  37784. * @param alpha defines the camera rotation along the logitudinal axis
  37785. * @param beta defines the camera rotation along the latitudinal axis
  37786. * @param radius defines the camera distance from its target
  37787. * @param target defines the camera target
  37788. * @param scene defines the scene the camera belongs to
  37789. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37790. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37791. */
  37792. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37793. /**
  37794. * Gets camera class name
  37795. * @returns VRDeviceOrientationArcRotateCamera
  37796. */
  37797. getClassName(): string;
  37798. }
  37799. }
  37800. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37801. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37802. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37803. import { Scene } from "babylonjs/scene";
  37804. import { Vector3 } from "babylonjs/Maths/math";
  37805. import "babylonjs/Cameras/RigModes/vrRigMode";
  37806. /**
  37807. * Camera used to simulate VR rendering (based on FreeCamera)
  37808. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37809. */
  37810. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37811. /**
  37812. * Creates a new VRDeviceOrientationFreeCamera
  37813. * @param name defines camera name
  37814. * @param position defines the start position of the camera
  37815. * @param scene defines the scene the camera belongs to
  37816. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37817. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37818. */
  37819. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37820. /**
  37821. * Gets camera class name
  37822. * @returns VRDeviceOrientationFreeCamera
  37823. */
  37824. getClassName(): string;
  37825. }
  37826. }
  37827. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37828. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37829. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37830. import { Scene } from "babylonjs/scene";
  37831. import { Vector3 } from "babylonjs/Maths/math";
  37832. /**
  37833. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37834. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37835. */
  37836. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37837. /**
  37838. * Creates a new VRDeviceOrientationGamepadCamera
  37839. * @param name defines camera name
  37840. * @param position defines the start position of the camera
  37841. * @param scene defines the scene the camera belongs to
  37842. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37843. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37844. */
  37845. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37846. /**
  37847. * Gets camera class name
  37848. * @returns VRDeviceOrientationGamepadCamera
  37849. */
  37850. getClassName(): string;
  37851. }
  37852. }
  37853. declare module "babylonjs/Gamepads/xboxGamepad" {
  37854. import { Observable } from "babylonjs/Misc/observable";
  37855. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37856. /**
  37857. * Defines supported buttons for XBox360 compatible gamepads
  37858. */
  37859. export enum Xbox360Button {
  37860. /** A */
  37861. A = 0,
  37862. /** B */
  37863. B = 1,
  37864. /** X */
  37865. X = 2,
  37866. /** Y */
  37867. Y = 3,
  37868. /** Start */
  37869. Start = 4,
  37870. /** Back */
  37871. Back = 5,
  37872. /** Left button */
  37873. LB = 6,
  37874. /** Right button */
  37875. RB = 7,
  37876. /** Left stick */
  37877. LeftStick = 8,
  37878. /** Right stick */
  37879. RightStick = 9
  37880. }
  37881. /** Defines values for XBox360 DPad */
  37882. export enum Xbox360Dpad {
  37883. /** Up */
  37884. Up = 0,
  37885. /** Down */
  37886. Down = 1,
  37887. /** Left */
  37888. Left = 2,
  37889. /** Right */
  37890. Right = 3
  37891. }
  37892. /**
  37893. * Defines a XBox360 gamepad
  37894. */
  37895. export class Xbox360Pad extends Gamepad {
  37896. private _leftTrigger;
  37897. private _rightTrigger;
  37898. private _onlefttriggerchanged;
  37899. private _onrighttriggerchanged;
  37900. private _onbuttondown;
  37901. private _onbuttonup;
  37902. private _ondpaddown;
  37903. private _ondpadup;
  37904. /** Observable raised when a button is pressed */
  37905. onButtonDownObservable: Observable<Xbox360Button>;
  37906. /** Observable raised when a button is released */
  37907. onButtonUpObservable: Observable<Xbox360Button>;
  37908. /** Observable raised when a pad is pressed */
  37909. onPadDownObservable: Observable<Xbox360Dpad>;
  37910. /** Observable raised when a pad is released */
  37911. onPadUpObservable: Observable<Xbox360Dpad>;
  37912. private _buttonA;
  37913. private _buttonB;
  37914. private _buttonX;
  37915. private _buttonY;
  37916. private _buttonBack;
  37917. private _buttonStart;
  37918. private _buttonLB;
  37919. private _buttonRB;
  37920. private _buttonLeftStick;
  37921. private _buttonRightStick;
  37922. private _dPadUp;
  37923. private _dPadDown;
  37924. private _dPadLeft;
  37925. private _dPadRight;
  37926. private _isXboxOnePad;
  37927. /**
  37928. * Creates a new XBox360 gamepad object
  37929. * @param id defines the id of this gamepad
  37930. * @param index defines its index
  37931. * @param gamepad defines the internal HTML gamepad object
  37932. * @param xboxOne defines if it is a XBox One gamepad
  37933. */
  37934. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37935. /**
  37936. * Defines the callback to call when left trigger is pressed
  37937. * @param callback defines the callback to use
  37938. */
  37939. onlefttriggerchanged(callback: (value: number) => void): void;
  37940. /**
  37941. * Defines the callback to call when right trigger is pressed
  37942. * @param callback defines the callback to use
  37943. */
  37944. onrighttriggerchanged(callback: (value: number) => void): void;
  37945. /**
  37946. * Gets the left trigger value
  37947. */
  37948. /**
  37949. * Sets the left trigger value
  37950. */
  37951. leftTrigger: number;
  37952. /**
  37953. * Gets the right trigger value
  37954. */
  37955. /**
  37956. * Sets the right trigger value
  37957. */
  37958. rightTrigger: number;
  37959. /**
  37960. * Defines the callback to call when a button is pressed
  37961. * @param callback defines the callback to use
  37962. */
  37963. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37964. /**
  37965. * Defines the callback to call when a button is released
  37966. * @param callback defines the callback to use
  37967. */
  37968. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37969. /**
  37970. * Defines the callback to call when a pad is pressed
  37971. * @param callback defines the callback to use
  37972. */
  37973. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37974. /**
  37975. * Defines the callback to call when a pad is released
  37976. * @param callback defines the callback to use
  37977. */
  37978. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37979. private _setButtonValue;
  37980. private _setDPadValue;
  37981. /**
  37982. * Gets the value of the `A` button
  37983. */
  37984. /**
  37985. * Sets the value of the `A` button
  37986. */
  37987. buttonA: number;
  37988. /**
  37989. * Gets the value of the `B` button
  37990. */
  37991. /**
  37992. * Sets the value of the `B` button
  37993. */
  37994. buttonB: number;
  37995. /**
  37996. * Gets the value of the `X` button
  37997. */
  37998. /**
  37999. * Sets the value of the `X` button
  38000. */
  38001. buttonX: number;
  38002. /**
  38003. * Gets the value of the `Y` button
  38004. */
  38005. /**
  38006. * Sets the value of the `Y` button
  38007. */
  38008. buttonY: number;
  38009. /**
  38010. * Gets the value of the `Start` button
  38011. */
  38012. /**
  38013. * Sets the value of the `Start` button
  38014. */
  38015. buttonStart: number;
  38016. /**
  38017. * Gets the value of the `Back` button
  38018. */
  38019. /**
  38020. * Sets the value of the `Back` button
  38021. */
  38022. buttonBack: number;
  38023. /**
  38024. * Gets the value of the `Left` button
  38025. */
  38026. /**
  38027. * Sets the value of the `Left` button
  38028. */
  38029. buttonLB: number;
  38030. /**
  38031. * Gets the value of the `Right` button
  38032. */
  38033. /**
  38034. * Sets the value of the `Right` button
  38035. */
  38036. buttonRB: number;
  38037. /**
  38038. * Gets the value of the Left joystick
  38039. */
  38040. /**
  38041. * Sets the value of the Left joystick
  38042. */
  38043. buttonLeftStick: number;
  38044. /**
  38045. * Gets the value of the Right joystick
  38046. */
  38047. /**
  38048. * Sets the value of the Right joystick
  38049. */
  38050. buttonRightStick: number;
  38051. /**
  38052. * Gets the value of D-pad up
  38053. */
  38054. /**
  38055. * Sets the value of D-pad up
  38056. */
  38057. dPadUp: number;
  38058. /**
  38059. * Gets the value of D-pad down
  38060. */
  38061. /**
  38062. * Sets the value of D-pad down
  38063. */
  38064. dPadDown: number;
  38065. /**
  38066. * Gets the value of D-pad left
  38067. */
  38068. /**
  38069. * Sets the value of D-pad left
  38070. */
  38071. dPadLeft: number;
  38072. /**
  38073. * Gets the value of D-pad right
  38074. */
  38075. /**
  38076. * Sets the value of D-pad right
  38077. */
  38078. dPadRight: number;
  38079. /**
  38080. * Force the gamepad to synchronize with device values
  38081. */
  38082. update(): void;
  38083. /**
  38084. * Disposes the gamepad
  38085. */
  38086. dispose(): void;
  38087. }
  38088. }
  38089. declare module "babylonjs/Materials/pushMaterial" {
  38090. import { Nullable } from "babylonjs/types";
  38091. import { Scene } from "babylonjs/scene";
  38092. import { Matrix } from "babylonjs/Maths/math";
  38093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38094. import { Mesh } from "babylonjs/Meshes/mesh";
  38095. import { Material } from "babylonjs/Materials/material";
  38096. import { Effect } from "babylonjs/Materials/effect";
  38097. /**
  38098. * Base class of materials working in push mode in babylon JS
  38099. * @hidden
  38100. */
  38101. export class PushMaterial extends Material {
  38102. protected _activeEffect: Effect;
  38103. protected _normalMatrix: Matrix;
  38104. /**
  38105. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38106. * This means that the material can keep using a previous shader while a new one is being compiled.
  38107. * This is mostly used when shader parallel compilation is supported (true by default)
  38108. */
  38109. allowShaderHotSwapping: boolean;
  38110. constructor(name: string, scene: Scene);
  38111. getEffect(): Effect;
  38112. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38113. /**
  38114. * Binds the given world matrix to the active effect
  38115. *
  38116. * @param world the matrix to bind
  38117. */
  38118. bindOnlyWorldMatrix(world: Matrix): void;
  38119. /**
  38120. * Binds the given normal matrix to the active effect
  38121. *
  38122. * @param normalMatrix the matrix to bind
  38123. */
  38124. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38125. bind(world: Matrix, mesh?: Mesh): void;
  38126. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38127. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38128. }
  38129. }
  38130. declare module "babylonjs/Materials/materialFlags" {
  38131. /**
  38132. * This groups all the flags used to control the materials channel.
  38133. */
  38134. export class MaterialFlags {
  38135. private static _DiffuseTextureEnabled;
  38136. /**
  38137. * Are diffuse textures enabled in the application.
  38138. */
  38139. static DiffuseTextureEnabled: boolean;
  38140. private static _AmbientTextureEnabled;
  38141. /**
  38142. * Are ambient textures enabled in the application.
  38143. */
  38144. static AmbientTextureEnabled: boolean;
  38145. private static _OpacityTextureEnabled;
  38146. /**
  38147. * Are opacity textures enabled in the application.
  38148. */
  38149. static OpacityTextureEnabled: boolean;
  38150. private static _ReflectionTextureEnabled;
  38151. /**
  38152. * Are reflection textures enabled in the application.
  38153. */
  38154. static ReflectionTextureEnabled: boolean;
  38155. private static _EmissiveTextureEnabled;
  38156. /**
  38157. * Are emissive textures enabled in the application.
  38158. */
  38159. static EmissiveTextureEnabled: boolean;
  38160. private static _SpecularTextureEnabled;
  38161. /**
  38162. * Are specular textures enabled in the application.
  38163. */
  38164. static SpecularTextureEnabled: boolean;
  38165. private static _BumpTextureEnabled;
  38166. /**
  38167. * Are bump textures enabled in the application.
  38168. */
  38169. static BumpTextureEnabled: boolean;
  38170. private static _LightmapTextureEnabled;
  38171. /**
  38172. * Are lightmap textures enabled in the application.
  38173. */
  38174. static LightmapTextureEnabled: boolean;
  38175. private static _RefractionTextureEnabled;
  38176. /**
  38177. * Are refraction textures enabled in the application.
  38178. */
  38179. static RefractionTextureEnabled: boolean;
  38180. private static _ColorGradingTextureEnabled;
  38181. /**
  38182. * Are color grading textures enabled in the application.
  38183. */
  38184. static ColorGradingTextureEnabled: boolean;
  38185. private static _FresnelEnabled;
  38186. /**
  38187. * Are fresnels enabled in the application.
  38188. */
  38189. static FresnelEnabled: boolean;
  38190. }
  38191. }
  38192. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38193. /** @hidden */
  38194. export var defaultFragmentDeclaration: {
  38195. name: string;
  38196. shader: string;
  38197. };
  38198. }
  38199. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38200. /** @hidden */
  38201. export var defaultUboDeclaration: {
  38202. name: string;
  38203. shader: string;
  38204. };
  38205. }
  38206. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38207. /** @hidden */
  38208. export var lightFragmentDeclaration: {
  38209. name: string;
  38210. shader: string;
  38211. };
  38212. }
  38213. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38214. /** @hidden */
  38215. export var lightUboDeclaration: {
  38216. name: string;
  38217. shader: string;
  38218. };
  38219. }
  38220. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38221. /** @hidden */
  38222. export var lightsFragmentFunctions: {
  38223. name: string;
  38224. shader: string;
  38225. };
  38226. }
  38227. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38228. /** @hidden */
  38229. export var shadowsFragmentFunctions: {
  38230. name: string;
  38231. shader: string;
  38232. };
  38233. }
  38234. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38235. /** @hidden */
  38236. export var fresnelFunction: {
  38237. name: string;
  38238. shader: string;
  38239. };
  38240. }
  38241. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38242. /** @hidden */
  38243. export var reflectionFunction: {
  38244. name: string;
  38245. shader: string;
  38246. };
  38247. }
  38248. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38249. /** @hidden */
  38250. export var bumpFragmentFunctions: {
  38251. name: string;
  38252. shader: string;
  38253. };
  38254. }
  38255. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38256. /** @hidden */
  38257. export var logDepthDeclaration: {
  38258. name: string;
  38259. shader: string;
  38260. };
  38261. }
  38262. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38263. /** @hidden */
  38264. export var bumpFragment: {
  38265. name: string;
  38266. shader: string;
  38267. };
  38268. }
  38269. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38270. /** @hidden */
  38271. export var depthPrePass: {
  38272. name: string;
  38273. shader: string;
  38274. };
  38275. }
  38276. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38277. /** @hidden */
  38278. export var lightFragment: {
  38279. name: string;
  38280. shader: string;
  38281. };
  38282. }
  38283. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38284. /** @hidden */
  38285. export var logDepthFragment: {
  38286. name: string;
  38287. shader: string;
  38288. };
  38289. }
  38290. declare module "babylonjs/Shaders/default.fragment" {
  38291. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38292. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38294. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38295. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38296. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38297. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38298. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38299. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38300. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38301. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38302. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38303. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38304. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38305. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38306. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38307. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38308. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38309. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38310. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38311. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38312. /** @hidden */
  38313. export var defaultPixelShader: {
  38314. name: string;
  38315. shader: string;
  38316. };
  38317. }
  38318. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38319. /** @hidden */
  38320. export var defaultVertexDeclaration: {
  38321. name: string;
  38322. shader: string;
  38323. };
  38324. }
  38325. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38326. /** @hidden */
  38327. export var bumpVertexDeclaration: {
  38328. name: string;
  38329. shader: string;
  38330. };
  38331. }
  38332. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38333. /** @hidden */
  38334. export var bumpVertex: {
  38335. name: string;
  38336. shader: string;
  38337. };
  38338. }
  38339. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38340. /** @hidden */
  38341. export var fogVertex: {
  38342. name: string;
  38343. shader: string;
  38344. };
  38345. }
  38346. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38347. /** @hidden */
  38348. export var shadowsVertex: {
  38349. name: string;
  38350. shader: string;
  38351. };
  38352. }
  38353. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38354. /** @hidden */
  38355. export var pointCloudVertex: {
  38356. name: string;
  38357. shader: string;
  38358. };
  38359. }
  38360. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38361. /** @hidden */
  38362. export var logDepthVertex: {
  38363. name: string;
  38364. shader: string;
  38365. };
  38366. }
  38367. declare module "babylonjs/Shaders/default.vertex" {
  38368. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38369. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38371. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38372. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38373. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38375. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38376. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38377. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38378. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38379. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38380. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38384. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38385. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38386. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38387. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38388. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38389. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38390. /** @hidden */
  38391. export var defaultVertexShader: {
  38392. name: string;
  38393. shader: string;
  38394. };
  38395. }
  38396. declare module "babylonjs/Materials/standardMaterial" {
  38397. import { SmartArray } from "babylonjs/Misc/smartArray";
  38398. import { IAnimatable } from "babylonjs/Misc/tools";
  38399. import { Nullable } from "babylonjs/types";
  38400. import { Scene } from "babylonjs/scene";
  38401. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38404. import { Mesh } from "babylonjs/Meshes/mesh";
  38405. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38406. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38407. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38408. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38409. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38410. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38411. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38412. import "babylonjs/Shaders/default.fragment";
  38413. import "babylonjs/Shaders/default.vertex";
  38414. /** @hidden */
  38415. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38416. MAINUV1: boolean;
  38417. MAINUV2: boolean;
  38418. DIFFUSE: boolean;
  38419. DIFFUSEDIRECTUV: number;
  38420. AMBIENT: boolean;
  38421. AMBIENTDIRECTUV: number;
  38422. OPACITY: boolean;
  38423. OPACITYDIRECTUV: number;
  38424. OPACITYRGB: boolean;
  38425. REFLECTION: boolean;
  38426. EMISSIVE: boolean;
  38427. EMISSIVEDIRECTUV: number;
  38428. SPECULAR: boolean;
  38429. SPECULARDIRECTUV: number;
  38430. BUMP: boolean;
  38431. BUMPDIRECTUV: number;
  38432. PARALLAX: boolean;
  38433. PARALLAXOCCLUSION: boolean;
  38434. SPECULAROVERALPHA: boolean;
  38435. CLIPPLANE: boolean;
  38436. CLIPPLANE2: boolean;
  38437. CLIPPLANE3: boolean;
  38438. CLIPPLANE4: boolean;
  38439. ALPHATEST: boolean;
  38440. DEPTHPREPASS: boolean;
  38441. ALPHAFROMDIFFUSE: boolean;
  38442. POINTSIZE: boolean;
  38443. FOG: boolean;
  38444. SPECULARTERM: boolean;
  38445. DIFFUSEFRESNEL: boolean;
  38446. OPACITYFRESNEL: boolean;
  38447. REFLECTIONFRESNEL: boolean;
  38448. REFRACTIONFRESNEL: boolean;
  38449. EMISSIVEFRESNEL: boolean;
  38450. FRESNEL: boolean;
  38451. NORMAL: boolean;
  38452. UV1: boolean;
  38453. UV2: boolean;
  38454. VERTEXCOLOR: boolean;
  38455. VERTEXALPHA: boolean;
  38456. NUM_BONE_INFLUENCERS: number;
  38457. BonesPerMesh: number;
  38458. BONETEXTURE: boolean;
  38459. INSTANCES: boolean;
  38460. GLOSSINESS: boolean;
  38461. ROUGHNESS: boolean;
  38462. EMISSIVEASILLUMINATION: boolean;
  38463. LINKEMISSIVEWITHDIFFUSE: boolean;
  38464. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38465. LIGHTMAP: boolean;
  38466. LIGHTMAPDIRECTUV: number;
  38467. OBJECTSPACE_NORMALMAP: boolean;
  38468. USELIGHTMAPASSHADOWMAP: boolean;
  38469. REFLECTIONMAP_3D: boolean;
  38470. REFLECTIONMAP_SPHERICAL: boolean;
  38471. REFLECTIONMAP_PLANAR: boolean;
  38472. REFLECTIONMAP_CUBIC: boolean;
  38473. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38474. REFLECTIONMAP_PROJECTION: boolean;
  38475. REFLECTIONMAP_SKYBOX: boolean;
  38476. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38477. REFLECTIONMAP_EXPLICIT: boolean;
  38478. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38479. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38480. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38481. INVERTCUBICMAP: boolean;
  38482. LOGARITHMICDEPTH: boolean;
  38483. REFRACTION: boolean;
  38484. REFRACTIONMAP_3D: boolean;
  38485. REFLECTIONOVERALPHA: boolean;
  38486. TWOSIDEDLIGHTING: boolean;
  38487. SHADOWFLOAT: boolean;
  38488. MORPHTARGETS: boolean;
  38489. MORPHTARGETS_NORMAL: boolean;
  38490. MORPHTARGETS_TANGENT: boolean;
  38491. NUM_MORPH_INFLUENCERS: number;
  38492. NONUNIFORMSCALING: boolean;
  38493. PREMULTIPLYALPHA: boolean;
  38494. IMAGEPROCESSING: boolean;
  38495. VIGNETTE: boolean;
  38496. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38497. VIGNETTEBLENDMODEOPAQUE: boolean;
  38498. TONEMAPPING: boolean;
  38499. TONEMAPPING_ACES: boolean;
  38500. CONTRAST: boolean;
  38501. COLORCURVES: boolean;
  38502. COLORGRADING: boolean;
  38503. COLORGRADING3D: boolean;
  38504. SAMPLER3DGREENDEPTH: boolean;
  38505. SAMPLER3DBGRMAP: boolean;
  38506. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38507. /**
  38508. * If the reflection texture on this material is in linear color space
  38509. * @hidden
  38510. */
  38511. IS_REFLECTION_LINEAR: boolean;
  38512. /**
  38513. * If the refraction texture on this material is in linear color space
  38514. * @hidden
  38515. */
  38516. IS_REFRACTION_LINEAR: boolean;
  38517. EXPOSURE: boolean;
  38518. constructor();
  38519. setReflectionMode(modeToEnable: string): void;
  38520. }
  38521. /**
  38522. * This is the default material used in Babylon. It is the best trade off between quality
  38523. * and performances.
  38524. * @see http://doc.babylonjs.com/babylon101/materials
  38525. */
  38526. export class StandardMaterial extends PushMaterial {
  38527. private _diffuseTexture;
  38528. /**
  38529. * The basic texture of the material as viewed under a light.
  38530. */
  38531. diffuseTexture: Nullable<BaseTexture>;
  38532. private _ambientTexture;
  38533. /**
  38534. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38535. */
  38536. ambientTexture: Nullable<BaseTexture>;
  38537. private _opacityTexture;
  38538. /**
  38539. * Define the transparency of the material from a texture.
  38540. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38541. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38542. */
  38543. opacityTexture: Nullable<BaseTexture>;
  38544. private _reflectionTexture;
  38545. /**
  38546. * Define the texture used to display the reflection.
  38547. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38548. */
  38549. reflectionTexture: Nullable<BaseTexture>;
  38550. private _emissiveTexture;
  38551. /**
  38552. * Define texture of the material as if self lit.
  38553. * This will be mixed in the final result even in the absence of light.
  38554. */
  38555. emissiveTexture: Nullable<BaseTexture>;
  38556. private _specularTexture;
  38557. /**
  38558. * Define how the color and intensity of the highlight given by the light in the material.
  38559. */
  38560. specularTexture: Nullable<BaseTexture>;
  38561. private _bumpTexture;
  38562. /**
  38563. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38564. * 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.
  38565. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38566. */
  38567. bumpTexture: Nullable<BaseTexture>;
  38568. private _lightmapTexture;
  38569. /**
  38570. * Complex lighting can be computationally expensive to compute at runtime.
  38571. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38572. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38573. */
  38574. lightmapTexture: Nullable<BaseTexture>;
  38575. private _refractionTexture;
  38576. /**
  38577. * Define the texture used to display the refraction.
  38578. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38579. */
  38580. refractionTexture: Nullable<BaseTexture>;
  38581. /**
  38582. * The color of the material lit by the environmental background lighting.
  38583. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38584. */
  38585. ambientColor: Color3;
  38586. /**
  38587. * The basic color of the material as viewed under a light.
  38588. */
  38589. diffuseColor: Color3;
  38590. /**
  38591. * Define how the color and intensity of the highlight given by the light in the material.
  38592. */
  38593. specularColor: Color3;
  38594. /**
  38595. * Define the color of the material as if self lit.
  38596. * This will be mixed in the final result even in the absence of light.
  38597. */
  38598. emissiveColor: Color3;
  38599. /**
  38600. * Defines how sharp are the highlights in the material.
  38601. * The bigger the value the sharper giving a more glossy feeling to the result.
  38602. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38603. */
  38604. specularPower: number;
  38605. private _useAlphaFromDiffuseTexture;
  38606. /**
  38607. * Does the transparency come from the diffuse texture alpha channel.
  38608. */
  38609. useAlphaFromDiffuseTexture: boolean;
  38610. private _useEmissiveAsIllumination;
  38611. /**
  38612. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38613. */
  38614. useEmissiveAsIllumination: boolean;
  38615. private _linkEmissiveWithDiffuse;
  38616. /**
  38617. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38618. * the emissive level when the final color is close to one.
  38619. */
  38620. linkEmissiveWithDiffuse: boolean;
  38621. private _useSpecularOverAlpha;
  38622. /**
  38623. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38624. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38625. */
  38626. useSpecularOverAlpha: boolean;
  38627. private _useReflectionOverAlpha;
  38628. /**
  38629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38631. */
  38632. useReflectionOverAlpha: boolean;
  38633. private _disableLighting;
  38634. /**
  38635. * Does lights from the scene impacts this material.
  38636. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38637. */
  38638. disableLighting: boolean;
  38639. private _useObjectSpaceNormalMap;
  38640. /**
  38641. * Allows using an object space normal map (instead of tangent space).
  38642. */
  38643. useObjectSpaceNormalMap: boolean;
  38644. private _useParallax;
  38645. /**
  38646. * Is parallax enabled or not.
  38647. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38648. */
  38649. useParallax: boolean;
  38650. private _useParallaxOcclusion;
  38651. /**
  38652. * Is parallax occlusion enabled or not.
  38653. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38654. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38655. */
  38656. useParallaxOcclusion: boolean;
  38657. /**
  38658. * 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.
  38659. */
  38660. parallaxScaleBias: number;
  38661. private _roughness;
  38662. /**
  38663. * Helps to define how blurry the reflections should appears in the material.
  38664. */
  38665. roughness: number;
  38666. /**
  38667. * In case of refraction, define the value of the indice of refraction.
  38668. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38669. */
  38670. indexOfRefraction: number;
  38671. /**
  38672. * Invert the refraction texture alongside the y axis.
  38673. * It can be useful with procedural textures or probe for instance.
  38674. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38675. */
  38676. invertRefractionY: boolean;
  38677. /**
  38678. * Defines the alpha limits in alpha test mode.
  38679. */
  38680. alphaCutOff: number;
  38681. private _useLightmapAsShadowmap;
  38682. /**
  38683. * In case of light mapping, define whether the map contains light or shadow informations.
  38684. */
  38685. useLightmapAsShadowmap: boolean;
  38686. private _diffuseFresnelParameters;
  38687. /**
  38688. * Define the diffuse fresnel parameters of the material.
  38689. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38690. */
  38691. diffuseFresnelParameters: FresnelParameters;
  38692. private _opacityFresnelParameters;
  38693. /**
  38694. * Define the opacity fresnel parameters of the material.
  38695. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38696. */
  38697. opacityFresnelParameters: FresnelParameters;
  38698. private _reflectionFresnelParameters;
  38699. /**
  38700. * Define the reflection fresnel parameters of the material.
  38701. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38702. */
  38703. reflectionFresnelParameters: FresnelParameters;
  38704. private _refractionFresnelParameters;
  38705. /**
  38706. * Define the refraction fresnel parameters of the material.
  38707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38708. */
  38709. refractionFresnelParameters: FresnelParameters;
  38710. private _emissiveFresnelParameters;
  38711. /**
  38712. * Define the emissive fresnel parameters of the material.
  38713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38714. */
  38715. emissiveFresnelParameters: FresnelParameters;
  38716. private _useReflectionFresnelFromSpecular;
  38717. /**
  38718. * If true automatically deducts the fresnels values from the material specularity.
  38719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38720. */
  38721. useReflectionFresnelFromSpecular: boolean;
  38722. private _useGlossinessFromSpecularMapAlpha;
  38723. /**
  38724. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38725. */
  38726. useGlossinessFromSpecularMapAlpha: boolean;
  38727. private _maxSimultaneousLights;
  38728. /**
  38729. * Defines the maximum number of lights that can be used in the material
  38730. */
  38731. maxSimultaneousLights: number;
  38732. private _invertNormalMapX;
  38733. /**
  38734. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38735. */
  38736. invertNormalMapX: boolean;
  38737. private _invertNormalMapY;
  38738. /**
  38739. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38740. */
  38741. invertNormalMapY: boolean;
  38742. private _twoSidedLighting;
  38743. /**
  38744. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38745. */
  38746. twoSidedLighting: boolean;
  38747. /**
  38748. * Default configuration related to image processing available in the standard Material.
  38749. */
  38750. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38751. /**
  38752. * Gets the image processing configuration used either in this material.
  38753. */
  38754. /**
  38755. * Sets the Default image processing configuration used either in the this material.
  38756. *
  38757. * If sets to null, the scene one is in use.
  38758. */
  38759. imageProcessingConfiguration: ImageProcessingConfiguration;
  38760. /**
  38761. * Keep track of the image processing observer to allow dispose and replace.
  38762. */
  38763. private _imageProcessingObserver;
  38764. /**
  38765. * Attaches a new image processing configuration to the Standard Material.
  38766. * @param configuration
  38767. */
  38768. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38769. /**
  38770. * Gets wether the color curves effect is enabled.
  38771. */
  38772. /**
  38773. * Sets wether the color curves effect is enabled.
  38774. */
  38775. cameraColorCurvesEnabled: boolean;
  38776. /**
  38777. * Gets wether the color grading effect is enabled.
  38778. */
  38779. /**
  38780. * Gets wether the color grading effect is enabled.
  38781. */
  38782. cameraColorGradingEnabled: boolean;
  38783. /**
  38784. * Gets wether tonemapping is enabled or not.
  38785. */
  38786. /**
  38787. * Sets wether tonemapping is enabled or not
  38788. */
  38789. cameraToneMappingEnabled: boolean;
  38790. /**
  38791. * The camera exposure used on this material.
  38792. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38793. * This corresponds to a photographic exposure.
  38794. */
  38795. /**
  38796. * The camera exposure used on this material.
  38797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38798. * This corresponds to a photographic exposure.
  38799. */
  38800. cameraExposure: number;
  38801. /**
  38802. * Gets The camera contrast used on this material.
  38803. */
  38804. /**
  38805. * Sets The camera contrast used on this material.
  38806. */
  38807. cameraContrast: number;
  38808. /**
  38809. * Gets the Color Grading 2D Lookup Texture.
  38810. */
  38811. /**
  38812. * Sets the Color Grading 2D Lookup Texture.
  38813. */
  38814. cameraColorGradingTexture: Nullable<BaseTexture>;
  38815. /**
  38816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38818. * 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;
  38819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38820. */
  38821. /**
  38822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38824. * 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;
  38825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38826. */
  38827. cameraColorCurves: Nullable<ColorCurves>;
  38828. /**
  38829. * Custom callback helping to override the default shader used in the material.
  38830. */
  38831. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38832. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38833. protected _worldViewProjectionMatrix: Matrix;
  38834. protected _globalAmbientColor: Color3;
  38835. protected _useLogarithmicDepth: boolean;
  38836. /**
  38837. * Instantiates a new standard material.
  38838. * This is the default material used in Babylon. It is the best trade off between quality
  38839. * and performances.
  38840. * @see http://doc.babylonjs.com/babylon101/materials
  38841. * @param name Define the name of the material in the scene
  38842. * @param scene Define the scene the material belong to
  38843. */
  38844. constructor(name: string, scene: Scene);
  38845. /**
  38846. * Gets a boolean indicating that current material needs to register RTT
  38847. */
  38848. readonly hasRenderTargetTextures: boolean;
  38849. /**
  38850. * Gets the current class name of the material e.g. "StandardMaterial"
  38851. * Mainly use in serialization.
  38852. * @returns the class name
  38853. */
  38854. getClassName(): string;
  38855. /**
  38856. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38857. * You can try switching to logarithmic depth.
  38858. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38859. */
  38860. useLogarithmicDepth: boolean;
  38861. /**
  38862. * Specifies if the material will require alpha blending
  38863. * @returns a boolean specifying if alpha blending is needed
  38864. */
  38865. needAlphaBlending(): boolean;
  38866. /**
  38867. * Specifies if this material should be rendered in alpha test mode
  38868. * @returns a boolean specifying if an alpha test is needed.
  38869. */
  38870. needAlphaTesting(): boolean;
  38871. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38872. /**
  38873. * Get the texture used for alpha test purpose.
  38874. * @returns the diffuse texture in case of the standard material.
  38875. */
  38876. getAlphaTestTexture(): Nullable<BaseTexture>;
  38877. /**
  38878. * Get if the submesh is ready to be used and all its information available.
  38879. * Child classes can use it to update shaders
  38880. * @param mesh defines the mesh to check
  38881. * @param subMesh defines which submesh to check
  38882. * @param useInstances specifies that instances should be used
  38883. * @returns a boolean indicating that the submesh is ready or not
  38884. */
  38885. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38886. /**
  38887. * Builds the material UBO layouts.
  38888. * Used internally during the effect preparation.
  38889. */
  38890. buildUniformLayout(): void;
  38891. /**
  38892. * Unbinds the material from the mesh
  38893. */
  38894. unbind(): void;
  38895. /**
  38896. * Binds the submesh to this material by preparing the effect and shader to draw
  38897. * @param world defines the world transformation matrix
  38898. * @param mesh defines the mesh containing the submesh
  38899. * @param subMesh defines the submesh to bind the material to
  38900. */
  38901. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38902. /**
  38903. * Get the list of animatables in the material.
  38904. * @returns the list of animatables object used in the material
  38905. */
  38906. getAnimatables(): IAnimatable[];
  38907. /**
  38908. * Gets the active textures from the material
  38909. * @returns an array of textures
  38910. */
  38911. getActiveTextures(): BaseTexture[];
  38912. /**
  38913. * Specifies if the material uses a texture
  38914. * @param texture defines the texture to check against the material
  38915. * @returns a boolean specifying if the material uses the texture
  38916. */
  38917. hasTexture(texture: BaseTexture): boolean;
  38918. /**
  38919. * Disposes the material
  38920. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38921. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38922. */
  38923. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38924. /**
  38925. * Makes a duplicate of the material, and gives it a new name
  38926. * @param name defines the new name for the duplicated material
  38927. * @returns the cloned material
  38928. */
  38929. clone(name: string): StandardMaterial;
  38930. /**
  38931. * Serializes this material in a JSON representation
  38932. * @returns the serialized material object
  38933. */
  38934. serialize(): any;
  38935. /**
  38936. * Creates a standard material from parsed material data
  38937. * @param source defines the JSON representation of the material
  38938. * @param scene defines the hosting scene
  38939. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38940. * @returns a new standard material
  38941. */
  38942. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38943. /**
  38944. * Are diffuse textures enabled in the application.
  38945. */
  38946. static DiffuseTextureEnabled: boolean;
  38947. /**
  38948. * Are ambient textures enabled in the application.
  38949. */
  38950. static AmbientTextureEnabled: boolean;
  38951. /**
  38952. * Are opacity textures enabled in the application.
  38953. */
  38954. static OpacityTextureEnabled: boolean;
  38955. /**
  38956. * Are reflection textures enabled in the application.
  38957. */
  38958. static ReflectionTextureEnabled: boolean;
  38959. /**
  38960. * Are emissive textures enabled in the application.
  38961. */
  38962. static EmissiveTextureEnabled: boolean;
  38963. /**
  38964. * Are specular textures enabled in the application.
  38965. */
  38966. static SpecularTextureEnabled: boolean;
  38967. /**
  38968. * Are bump textures enabled in the application.
  38969. */
  38970. static BumpTextureEnabled: boolean;
  38971. /**
  38972. * Are lightmap textures enabled in the application.
  38973. */
  38974. static LightmapTextureEnabled: boolean;
  38975. /**
  38976. * Are refraction textures enabled in the application.
  38977. */
  38978. static RefractionTextureEnabled: boolean;
  38979. /**
  38980. * Are color grading textures enabled in the application.
  38981. */
  38982. static ColorGradingTextureEnabled: boolean;
  38983. /**
  38984. * Are fresnels enabled in the application.
  38985. */
  38986. static FresnelEnabled: boolean;
  38987. }
  38988. }
  38989. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  38990. import { Scene } from "babylonjs/scene";
  38991. import { Texture } from "babylonjs/Materials/Textures/texture";
  38992. /**
  38993. * A class extending Texture allowing drawing on a texture
  38994. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38995. */
  38996. export class DynamicTexture extends Texture {
  38997. private _generateMipMaps;
  38998. private _canvas;
  38999. private _context;
  39000. private _engine;
  39001. /**
  39002. * Creates a DynamicTexture
  39003. * @param name defines the name of the texture
  39004. * @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
  39005. * @param scene defines the scene where you want the texture
  39006. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39007. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39008. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39009. */
  39010. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39011. /**
  39012. * Get the current class name of the texture useful for serialization or dynamic coding.
  39013. * @returns "DynamicTexture"
  39014. */
  39015. getClassName(): string;
  39016. /**
  39017. * Gets the current state of canRescale
  39018. */
  39019. readonly canRescale: boolean;
  39020. private _recreate;
  39021. /**
  39022. * Scales the texture
  39023. * @param ratio the scale factor to apply to both width and height
  39024. */
  39025. scale(ratio: number): void;
  39026. /**
  39027. * Resizes the texture
  39028. * @param width the new width
  39029. * @param height the new height
  39030. */
  39031. scaleTo(width: number, height: number): void;
  39032. /**
  39033. * Gets the context of the canvas used by the texture
  39034. * @returns the canvas context of the dynamic texture
  39035. */
  39036. getContext(): CanvasRenderingContext2D;
  39037. /**
  39038. * Clears the texture
  39039. */
  39040. clear(): void;
  39041. /**
  39042. * Updates the texture
  39043. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39044. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39045. */
  39046. update(invertY?: boolean, premulAlpha?: boolean): void;
  39047. /**
  39048. * Draws text onto the texture
  39049. * @param text defines the text to be drawn
  39050. * @param x defines the placement of the text from the left
  39051. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39052. * @param font defines the font to be used with font-style, font-size, font-name
  39053. * @param color defines the color used for the text
  39054. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39055. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39056. * @param update defines whether texture is immediately update (default is true)
  39057. */
  39058. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39059. /**
  39060. * Clones the texture
  39061. * @returns the clone of the texture.
  39062. */
  39063. clone(): DynamicTexture;
  39064. /**
  39065. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39066. * @returns a serialized dynamic texture object
  39067. */
  39068. serialize(): any;
  39069. /** @hidden */
  39070. _rebuild(): void;
  39071. }
  39072. }
  39073. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39074. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39075. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39076. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39077. /** @hidden */
  39078. export var imageProcessingPixelShader: {
  39079. name: string;
  39080. shader: string;
  39081. };
  39082. }
  39083. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39084. import { Nullable } from "babylonjs/types";
  39085. import { Color4 } from "babylonjs/Maths/math";
  39086. import { Camera } from "babylonjs/Cameras/camera";
  39087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39088. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39089. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39091. import { Engine } from "babylonjs/Engines/engine";
  39092. import "babylonjs/Shaders/imageProcessing.fragment";
  39093. import "babylonjs/Shaders/postprocess.vertex";
  39094. /**
  39095. * ImageProcessingPostProcess
  39096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39097. */
  39098. export class ImageProcessingPostProcess extends PostProcess {
  39099. /**
  39100. * Default configuration related to image processing available in the PBR Material.
  39101. */
  39102. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39103. /**
  39104. * Gets the image processing configuration used either in this material.
  39105. */
  39106. /**
  39107. * Sets the Default image processing configuration used either in the this material.
  39108. *
  39109. * If sets to null, the scene one is in use.
  39110. */
  39111. imageProcessingConfiguration: ImageProcessingConfiguration;
  39112. /**
  39113. * Keep track of the image processing observer to allow dispose and replace.
  39114. */
  39115. private _imageProcessingObserver;
  39116. /**
  39117. * Attaches a new image processing configuration to the PBR Material.
  39118. * @param configuration
  39119. */
  39120. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39121. /**
  39122. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39123. */
  39124. /**
  39125. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39126. */
  39127. colorCurves: Nullable<ColorCurves>;
  39128. /**
  39129. * Gets wether the color curves effect is enabled.
  39130. */
  39131. /**
  39132. * Sets wether the color curves effect is enabled.
  39133. */
  39134. colorCurvesEnabled: boolean;
  39135. /**
  39136. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39137. */
  39138. /**
  39139. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39140. */
  39141. colorGradingTexture: Nullable<BaseTexture>;
  39142. /**
  39143. * Gets wether the color grading effect is enabled.
  39144. */
  39145. /**
  39146. * Gets wether the color grading effect is enabled.
  39147. */
  39148. colorGradingEnabled: boolean;
  39149. /**
  39150. * Gets exposure used in the effect.
  39151. */
  39152. /**
  39153. * Sets exposure used in the effect.
  39154. */
  39155. exposure: number;
  39156. /**
  39157. * Gets wether tonemapping is enabled or not.
  39158. */
  39159. /**
  39160. * Sets wether tonemapping is enabled or not
  39161. */
  39162. toneMappingEnabled: boolean;
  39163. /**
  39164. * Gets contrast used in the effect.
  39165. */
  39166. /**
  39167. * Sets contrast used in the effect.
  39168. */
  39169. contrast: number;
  39170. /**
  39171. * Gets Vignette stretch size.
  39172. */
  39173. /**
  39174. * Sets Vignette stretch size.
  39175. */
  39176. vignetteStretch: number;
  39177. /**
  39178. * Gets Vignette centre X Offset.
  39179. */
  39180. /**
  39181. * Sets Vignette centre X Offset.
  39182. */
  39183. vignetteCentreX: number;
  39184. /**
  39185. * Gets Vignette centre Y Offset.
  39186. */
  39187. /**
  39188. * Sets Vignette centre Y Offset.
  39189. */
  39190. vignetteCentreY: number;
  39191. /**
  39192. * Gets Vignette weight or intensity of the vignette effect.
  39193. */
  39194. /**
  39195. * Sets Vignette weight or intensity of the vignette effect.
  39196. */
  39197. vignetteWeight: number;
  39198. /**
  39199. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39200. * if vignetteEnabled is set to true.
  39201. */
  39202. /**
  39203. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39204. * if vignetteEnabled is set to true.
  39205. */
  39206. vignetteColor: Color4;
  39207. /**
  39208. * Gets Camera field of view used by the Vignette effect.
  39209. */
  39210. /**
  39211. * Sets Camera field of view used by the Vignette effect.
  39212. */
  39213. vignetteCameraFov: number;
  39214. /**
  39215. * Gets the vignette blend mode allowing different kind of effect.
  39216. */
  39217. /**
  39218. * Sets the vignette blend mode allowing different kind of effect.
  39219. */
  39220. vignetteBlendMode: number;
  39221. /**
  39222. * Gets wether the vignette effect is enabled.
  39223. */
  39224. /**
  39225. * Sets wether the vignette effect is enabled.
  39226. */
  39227. vignetteEnabled: boolean;
  39228. private _fromLinearSpace;
  39229. /**
  39230. * Gets wether the input of the processing is in Gamma or Linear Space.
  39231. */
  39232. /**
  39233. * Sets wether the input of the processing is in Gamma or Linear Space.
  39234. */
  39235. fromLinearSpace: boolean;
  39236. /**
  39237. * Defines cache preventing GC.
  39238. */
  39239. private _defines;
  39240. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39241. /**
  39242. * "ImageProcessingPostProcess"
  39243. * @returns "ImageProcessingPostProcess"
  39244. */
  39245. getClassName(): string;
  39246. protected _updateParameters(): void;
  39247. dispose(camera?: Camera): void;
  39248. }
  39249. }
  39250. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39251. import { Scene } from "babylonjs/scene";
  39252. import { Color3 } from "babylonjs/Maths/math";
  39253. import { Mesh } from "babylonjs/Meshes/mesh";
  39254. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39255. /**
  39256. * Class containing static functions to help procedurally build meshes
  39257. */
  39258. export class GroundBuilder {
  39259. /**
  39260. * Creates a ground mesh
  39261. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39262. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39264. * @param name defines the name of the mesh
  39265. * @param options defines the options used to create the mesh
  39266. * @param scene defines the hosting scene
  39267. * @returns the ground mesh
  39268. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39269. */
  39270. static CreateGround(name: string, options: {
  39271. width?: number;
  39272. height?: number;
  39273. subdivisions?: number;
  39274. subdivisionsX?: number;
  39275. subdivisionsY?: number;
  39276. updatable?: boolean;
  39277. }, scene: any): Mesh;
  39278. /**
  39279. * Creates a tiled ground mesh
  39280. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39281. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39282. * * 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
  39283. * * 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
  39284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39285. * @param name defines the name of the mesh
  39286. * @param options defines the options used to create the mesh
  39287. * @param scene defines the hosting scene
  39288. * @returns the tiled ground mesh
  39289. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39290. */
  39291. static CreateTiledGround(name: string, options: {
  39292. xmin: number;
  39293. zmin: number;
  39294. xmax: number;
  39295. zmax: number;
  39296. subdivisions?: {
  39297. w: number;
  39298. h: number;
  39299. };
  39300. precision?: {
  39301. w: number;
  39302. h: number;
  39303. };
  39304. updatable?: boolean;
  39305. }, scene: Scene): Mesh;
  39306. /**
  39307. * Creates a ground mesh from a height map
  39308. * * The parameter `url` sets the URL of the height map image resource.
  39309. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39310. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39311. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39312. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39313. * * 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.
  39314. * * 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).
  39315. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39317. * @param name defines the name of the mesh
  39318. * @param url defines the url to the height map
  39319. * @param options defines the options used to create the mesh
  39320. * @param scene defines the hosting scene
  39321. * @returns the ground mesh
  39322. * @see https://doc.babylonjs.com/babylon101/height_map
  39323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39324. */
  39325. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39326. width?: number;
  39327. height?: number;
  39328. subdivisions?: number;
  39329. minHeight?: number;
  39330. maxHeight?: number;
  39331. colorFilter?: Color3;
  39332. alphaFilter?: number;
  39333. updatable?: boolean;
  39334. onReady?: (mesh: GroundMesh) => void;
  39335. }, scene: Scene): GroundMesh;
  39336. }
  39337. }
  39338. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39339. import { Vector4 } from "babylonjs/Maths/math";
  39340. import { Mesh } from "babylonjs/Meshes/mesh";
  39341. /**
  39342. * Class containing static functions to help procedurally build meshes
  39343. */
  39344. export class TorusBuilder {
  39345. /**
  39346. * Creates a torus mesh
  39347. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39348. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39349. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39353. * @param name defines the name of the mesh
  39354. * @param options defines the options used to create the mesh
  39355. * @param scene defines the hosting scene
  39356. * @returns the torus mesh
  39357. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39358. */
  39359. static CreateTorus(name: string, options: {
  39360. diameter?: number;
  39361. thickness?: number;
  39362. tessellation?: number;
  39363. updatable?: boolean;
  39364. sideOrientation?: number;
  39365. frontUVs?: Vector4;
  39366. backUVs?: Vector4;
  39367. }, scene: any): Mesh;
  39368. }
  39369. }
  39370. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39371. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39372. import { Mesh } from "babylonjs/Meshes/mesh";
  39373. /**
  39374. * Class containing static functions to help procedurally build meshes
  39375. */
  39376. export class CylinderBuilder {
  39377. /**
  39378. * Creates a cylinder or a cone mesh
  39379. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39380. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39381. * * 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.
  39382. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39383. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39384. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39385. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39386. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39387. * * 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).
  39388. * * 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
  39389. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39390. * * 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
  39391. * * 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.
  39392. * * If `enclose` is false, a ring surface is one element.
  39393. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39394. * * 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
  39395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39398. * @param name defines the name of the mesh
  39399. * @param options defines the options used to create the mesh
  39400. * @param scene defines the hosting scene
  39401. * @returns the cylinder mesh
  39402. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39403. */
  39404. static CreateCylinder(name: string, options: {
  39405. height?: number;
  39406. diameterTop?: number;
  39407. diameterBottom?: number;
  39408. diameter?: number;
  39409. tessellation?: number;
  39410. subdivisions?: number;
  39411. arc?: number;
  39412. faceColors?: Color4[];
  39413. faceUV?: Vector4[];
  39414. updatable?: boolean;
  39415. hasRings?: boolean;
  39416. enclose?: boolean;
  39417. sideOrientation?: number;
  39418. frontUVs?: Vector4;
  39419. backUVs?: Vector4;
  39420. }, scene: any): Mesh;
  39421. }
  39422. }
  39423. declare module "babylonjs/Gamepads/gamepadManager" {
  39424. import { Observable } from "babylonjs/Misc/observable";
  39425. import { Nullable } from "babylonjs/types";
  39426. import { Scene } from "babylonjs/scene";
  39427. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39428. /**
  39429. * Manager for handling gamepads
  39430. */
  39431. export class GamepadManager {
  39432. private _scene?;
  39433. private _babylonGamepads;
  39434. private _oneGamepadConnected;
  39435. /** @hidden */
  39436. _isMonitoring: boolean;
  39437. private _gamepadEventSupported;
  39438. private _gamepadSupport;
  39439. /**
  39440. * observable to be triggered when the gamepad controller has been connected
  39441. */
  39442. onGamepadConnectedObservable: Observable<Gamepad>;
  39443. /**
  39444. * observable to be triggered when the gamepad controller has been disconnected
  39445. */
  39446. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39447. private _onGamepadConnectedEvent;
  39448. private _onGamepadDisconnectedEvent;
  39449. /**
  39450. * Initializes the gamepad manager
  39451. * @param _scene BabylonJS scene
  39452. */
  39453. constructor(_scene?: Scene | undefined);
  39454. /**
  39455. * The gamepads in the game pad manager
  39456. */
  39457. readonly gamepads: Gamepad[];
  39458. /**
  39459. * Get the gamepad controllers based on type
  39460. * @param type The type of gamepad controller
  39461. * @returns Nullable gamepad
  39462. */
  39463. getGamepadByType(type?: number): Nullable<Gamepad>;
  39464. /**
  39465. * Disposes the gamepad manager
  39466. */
  39467. dispose(): void;
  39468. private _addNewGamepad;
  39469. private _startMonitoringGamepads;
  39470. private _stopMonitoringGamepads;
  39471. /** @hidden */
  39472. _checkGamepadsStatus(): void;
  39473. private _updateGamepadObjects;
  39474. }
  39475. }
  39476. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39477. import { Nullable } from "babylonjs/types";
  39478. import { Scene } from "babylonjs/scene";
  39479. import { ISceneComponent } from "babylonjs/sceneComponent";
  39480. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39481. module "babylonjs/scene" {
  39482. interface Scene {
  39483. /** @hidden */
  39484. _gamepadManager: Nullable<GamepadManager>;
  39485. /**
  39486. * Gets the gamepad manager associated with the scene
  39487. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39488. */
  39489. gamepadManager: GamepadManager;
  39490. }
  39491. }
  39492. module "babylonjs/Cameras/freeCameraInputsManager" {
  39493. /**
  39494. * Interface representing a free camera inputs manager
  39495. */
  39496. interface FreeCameraInputsManager {
  39497. /**
  39498. * Adds gamepad input support to the FreeCameraInputsManager.
  39499. * @returns the FreeCameraInputsManager
  39500. */
  39501. addGamepad(): FreeCameraInputsManager;
  39502. }
  39503. }
  39504. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39505. /**
  39506. * Interface representing an arc rotate camera inputs manager
  39507. */
  39508. interface ArcRotateCameraInputsManager {
  39509. /**
  39510. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39511. * @returns the camera inputs manager
  39512. */
  39513. addGamepad(): ArcRotateCameraInputsManager;
  39514. }
  39515. }
  39516. /**
  39517. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39518. */
  39519. export class GamepadSystemSceneComponent implements ISceneComponent {
  39520. /**
  39521. * The component name helpfull to identify the component in the list of scene components.
  39522. */
  39523. readonly name: string;
  39524. /**
  39525. * The scene the component belongs to.
  39526. */
  39527. scene: Scene;
  39528. /**
  39529. * Creates a new instance of the component for the given scene
  39530. * @param scene Defines the scene to register the component in
  39531. */
  39532. constructor(scene: Scene);
  39533. /**
  39534. * Registers the component in a given scene
  39535. */
  39536. register(): void;
  39537. /**
  39538. * Rebuilds the elements related to this component in case of
  39539. * context lost for instance.
  39540. */
  39541. rebuild(): void;
  39542. /**
  39543. * Disposes the component and the associated ressources
  39544. */
  39545. dispose(): void;
  39546. private _beforeCameraUpdate;
  39547. }
  39548. }
  39549. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39550. import { Observable } from "babylonjs/Misc/observable";
  39551. import { Nullable } from "babylonjs/types";
  39552. import { Camera } from "babylonjs/Cameras/camera";
  39553. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39554. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39555. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39556. import { Scene } from "babylonjs/scene";
  39557. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39558. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39560. import { Mesh } from "babylonjs/Meshes/mesh";
  39561. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39562. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39563. import "babylonjs/Meshes/Builders/groundBuilder";
  39564. import "babylonjs/Meshes/Builders/torusBuilder";
  39565. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39566. import "babylonjs/Gamepads/gamepadSceneComponent";
  39567. import "babylonjs/Animations/animatable";
  39568. /**
  39569. * Options to modify the vr teleportation behavior.
  39570. */
  39571. export interface VRTeleportationOptions {
  39572. /**
  39573. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39574. */
  39575. floorMeshName?: string;
  39576. /**
  39577. * A list of meshes to be used as the teleportation floor. (default: empty)
  39578. */
  39579. floorMeshes?: Mesh[];
  39580. }
  39581. /**
  39582. * Options to modify the vr experience helper's behavior.
  39583. */
  39584. export interface VRExperienceHelperOptions extends WebVROptions {
  39585. /**
  39586. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39587. */
  39588. createDeviceOrientationCamera?: boolean;
  39589. /**
  39590. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39591. */
  39592. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39593. /**
  39594. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39595. */
  39596. laserToggle?: boolean;
  39597. /**
  39598. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39599. */
  39600. floorMeshes?: Mesh[];
  39601. /**
  39602. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39603. */
  39604. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39605. }
  39606. /**
  39607. * Helps to quickly add VR support to an existing scene.
  39608. * See http://doc.babylonjs.com/how_to/webvr_helper
  39609. */
  39610. export class VRExperienceHelper {
  39611. /** Options to modify the vr experience helper's behavior. */
  39612. webVROptions: VRExperienceHelperOptions;
  39613. private _scene;
  39614. private _position;
  39615. private _btnVR;
  39616. private _btnVRDisplayed;
  39617. private _webVRsupported;
  39618. private _webVRready;
  39619. private _webVRrequesting;
  39620. private _webVRpresenting;
  39621. private _hasEnteredVR;
  39622. private _fullscreenVRpresenting;
  39623. private _canvas;
  39624. private _webVRCamera;
  39625. private _vrDeviceOrientationCamera;
  39626. private _deviceOrientationCamera;
  39627. private _existingCamera;
  39628. private _onKeyDown;
  39629. private _onVrDisplayPresentChange;
  39630. private _onVRDisplayChanged;
  39631. private _onVRRequestPresentStart;
  39632. private _onVRRequestPresentComplete;
  39633. /**
  39634. * Observable raised when entering VR.
  39635. */
  39636. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39637. /**
  39638. * Observable raised when exiting VR.
  39639. */
  39640. onExitingVRObservable: Observable<VRExperienceHelper>;
  39641. /**
  39642. * Observable raised when controller mesh is loaded.
  39643. */
  39644. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39645. /** Return this.onEnteringVRObservable
  39646. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39647. */
  39648. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39649. /** Return this.onExitingVRObservable
  39650. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39651. */
  39652. readonly onExitingVR: Observable<VRExperienceHelper>;
  39653. /** Return this.onControllerMeshLoadedObservable
  39654. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39655. */
  39656. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39657. private _rayLength;
  39658. private _useCustomVRButton;
  39659. private _teleportationRequested;
  39660. private _teleportActive;
  39661. private _floorMeshName;
  39662. private _floorMeshesCollection;
  39663. private _rotationAllowed;
  39664. private _teleportBackwardsVector;
  39665. private _teleportationTarget;
  39666. private _isDefaultTeleportationTarget;
  39667. private _postProcessMove;
  39668. private _teleportationFillColor;
  39669. private _teleportationBorderColor;
  39670. private _rotationAngle;
  39671. private _haloCenter;
  39672. private _cameraGazer;
  39673. private _padSensibilityUp;
  39674. private _padSensibilityDown;
  39675. private _leftController;
  39676. private _rightController;
  39677. /**
  39678. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39679. */
  39680. onNewMeshSelected: Observable<AbstractMesh>;
  39681. /**
  39682. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39683. */
  39684. onNewMeshPicked: Observable<PickingInfo>;
  39685. private _circleEase;
  39686. /**
  39687. * Observable raised before camera teleportation
  39688. */
  39689. onBeforeCameraTeleport: Observable<Vector3>;
  39690. /**
  39691. * Observable raised after camera teleportation
  39692. */
  39693. onAfterCameraTeleport: Observable<Vector3>;
  39694. /**
  39695. * Observable raised when current selected mesh gets unselected
  39696. */
  39697. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39698. private _raySelectionPredicate;
  39699. /**
  39700. * To be optionaly changed by user to define custom ray selection
  39701. */
  39702. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39703. /**
  39704. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39705. */
  39706. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39707. /**
  39708. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39709. */
  39710. teleportationEnabled: boolean;
  39711. private _defaultHeight;
  39712. private _teleportationInitialized;
  39713. private _interactionsEnabled;
  39714. private _interactionsRequested;
  39715. private _displayGaze;
  39716. private _displayLaserPointer;
  39717. /**
  39718. * The mesh used to display where the user is going to teleport.
  39719. */
  39720. /**
  39721. * Sets the mesh to be used to display where the user is going to teleport.
  39722. */
  39723. teleportationTarget: Mesh;
  39724. /**
  39725. * 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
  39726. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39727. * See http://doc.babylonjs.com/resources/baking_transformations
  39728. */
  39729. gazeTrackerMesh: Mesh;
  39730. /**
  39731. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39732. */
  39733. updateGazeTrackerScale: boolean;
  39734. /**
  39735. * If the gaze trackers color should be updated when selecting meshes
  39736. */
  39737. updateGazeTrackerColor: boolean;
  39738. /**
  39739. * The gaze tracking mesh corresponding to the left controller
  39740. */
  39741. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39742. /**
  39743. * The gaze tracking mesh corresponding to the right controller
  39744. */
  39745. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39746. /**
  39747. * If the ray of the gaze should be displayed.
  39748. */
  39749. /**
  39750. * Sets if the ray of the gaze should be displayed.
  39751. */
  39752. displayGaze: boolean;
  39753. /**
  39754. * If the ray of the LaserPointer should be displayed.
  39755. */
  39756. /**
  39757. * Sets if the ray of the LaserPointer should be displayed.
  39758. */
  39759. displayLaserPointer: boolean;
  39760. /**
  39761. * The deviceOrientationCamera used as the camera when not in VR.
  39762. */
  39763. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39764. /**
  39765. * Based on the current WebVR support, returns the current VR camera used.
  39766. */
  39767. readonly currentVRCamera: Nullable<Camera>;
  39768. /**
  39769. * The webVRCamera which is used when in VR.
  39770. */
  39771. readonly webVRCamera: WebVRFreeCamera;
  39772. /**
  39773. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39774. */
  39775. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39776. private readonly _teleportationRequestInitiated;
  39777. /**
  39778. * Defines wether or not Pointer lock should be requested when switching to
  39779. * full screen.
  39780. */
  39781. requestPointerLockOnFullScreen: boolean;
  39782. /**
  39783. * Instantiates a VRExperienceHelper.
  39784. * Helps to quickly add VR support to an existing scene.
  39785. * @param scene The scene the VRExperienceHelper belongs to.
  39786. * @param webVROptions Options to modify the vr experience helper's behavior.
  39787. */
  39788. constructor(scene: Scene,
  39789. /** Options to modify the vr experience helper's behavior. */
  39790. webVROptions?: VRExperienceHelperOptions);
  39791. private _onDefaultMeshLoaded;
  39792. private _onResize;
  39793. private _onFullscreenChange;
  39794. /**
  39795. * Gets a value indicating if we are currently in VR mode.
  39796. */
  39797. readonly isInVRMode: boolean;
  39798. private onVrDisplayPresentChange;
  39799. private onVRDisplayChanged;
  39800. private moveButtonToBottomRight;
  39801. private displayVRButton;
  39802. private updateButtonVisibility;
  39803. private _cachedAngularSensibility;
  39804. /**
  39805. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39806. * Otherwise, will use the fullscreen API.
  39807. */
  39808. enterVR(): void;
  39809. /**
  39810. * Attempt to exit VR, or fullscreen.
  39811. */
  39812. exitVR(): void;
  39813. /**
  39814. * The position of the vr experience helper.
  39815. */
  39816. /**
  39817. * Sets the position of the vr experience helper.
  39818. */
  39819. position: Vector3;
  39820. /**
  39821. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39822. */
  39823. enableInteractions(): void;
  39824. private readonly _noControllerIsActive;
  39825. private beforeRender;
  39826. private _isTeleportationFloor;
  39827. /**
  39828. * Adds a floor mesh to be used for teleportation.
  39829. * @param floorMesh the mesh to be used for teleportation.
  39830. */
  39831. addFloorMesh(floorMesh: Mesh): void;
  39832. /**
  39833. * Removes a floor mesh from being used for teleportation.
  39834. * @param floorMesh the mesh to be removed.
  39835. */
  39836. removeFloorMesh(floorMesh: Mesh): void;
  39837. /**
  39838. * Enables interactions and teleportation using the VR controllers and gaze.
  39839. * @param vrTeleportationOptions options to modify teleportation behavior.
  39840. */
  39841. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39842. private _onNewGamepadConnected;
  39843. private _tryEnableInteractionOnController;
  39844. private _onNewGamepadDisconnected;
  39845. private _enableInteractionOnController;
  39846. private _checkTeleportWithRay;
  39847. private _checkRotate;
  39848. private _checkTeleportBackwards;
  39849. private _enableTeleportationOnController;
  39850. private _createTeleportationCircles;
  39851. private _displayTeleportationTarget;
  39852. private _hideTeleportationTarget;
  39853. private _rotateCamera;
  39854. private _moveTeleportationSelectorTo;
  39855. private _workingVector;
  39856. private _workingQuaternion;
  39857. private _workingMatrix;
  39858. /**
  39859. * Teleports the users feet to the desired location
  39860. * @param location The location where the user's feet should be placed
  39861. */
  39862. teleportCamera(location: Vector3): void;
  39863. private _convertNormalToDirectionOfRay;
  39864. private _castRayAndSelectObject;
  39865. private _notifySelectedMeshUnselected;
  39866. /**
  39867. * Sets the color of the laser ray from the vr controllers.
  39868. * @param color new color for the ray.
  39869. */
  39870. changeLaserColor(color: Color3): void;
  39871. /**
  39872. * Sets the color of the ray from the vr headsets gaze.
  39873. * @param color new color for the ray.
  39874. */
  39875. changeGazeColor(color: Color3): void;
  39876. /**
  39877. * Exits VR and disposes of the vr experience helper
  39878. */
  39879. dispose(): void;
  39880. /**
  39881. * Gets the name of the VRExperienceHelper class
  39882. * @returns "VRExperienceHelper"
  39883. */
  39884. getClassName(): string;
  39885. }
  39886. }
  39887. declare module "babylonjs/Cameras/VR/index" {
  39888. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39889. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39890. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39891. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39892. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39893. export * from "babylonjs/Cameras/VR/webVRCamera";
  39894. }
  39895. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39896. import { Observable } from "babylonjs/Misc/observable";
  39897. import { Nullable } from "babylonjs/types";
  39898. import { IDisposable, Scene } from "babylonjs/scene";
  39899. import { Vector3 } from "babylonjs/Maths/math";
  39900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39901. import { Ray } from "babylonjs/Culling/ray";
  39902. /**
  39903. * Manages an XRSession
  39904. * @see https://doc.babylonjs.com/how_to/webxr
  39905. */
  39906. export class WebXRSessionManager implements IDisposable {
  39907. private scene;
  39908. /**
  39909. * Fires every time a new xrFrame arrives which can be used to update the camera
  39910. */
  39911. onXRFrameObservable: Observable<any>;
  39912. /**
  39913. * Fires when the xr session is ended either by the device or manually done
  39914. */
  39915. onXRSessionEnded: Observable<any>;
  39916. /** @hidden */
  39917. _xrSession: XRSession;
  39918. /** @hidden */
  39919. _frameOfReference: XRFrameOfReference;
  39920. /** @hidden */
  39921. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39922. /** @hidden */
  39923. _currentXRFrame: Nullable<XRFrame>;
  39924. private _xrNavigator;
  39925. private _xrDevice;
  39926. private _tmpMatrix;
  39927. /**
  39928. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39929. * @param scene The scene which the session should be created for
  39930. */
  39931. constructor(scene: Scene);
  39932. /**
  39933. * Initializes the manager
  39934. * After initialization enterXR can be called to start an XR session
  39935. * @returns Promise which resolves after it is initialized
  39936. */
  39937. initializeAsync(): Promise<void>;
  39938. /**
  39939. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39940. * @param sessionCreationOptions xr options to create the session with
  39941. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39942. * @returns Promise which resolves after it enters XR
  39943. */
  39944. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39945. /**
  39946. * Stops the xrSession and restores the renderloop
  39947. * @returns Promise which resolves after it exits XR
  39948. */
  39949. exitXRAsync(): Promise<void>;
  39950. /**
  39951. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39952. * @param ray ray to cast into the environment
  39953. * @returns Promise which resolves with a collision point in the environment if it exists
  39954. */
  39955. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39956. /**
  39957. * Checks if a session would be supported for the creation options specified
  39958. * @param options creation options to check if they are supported
  39959. * @returns true if supported
  39960. */
  39961. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39962. /**
  39963. * @hidden
  39964. * Converts the render layer of xrSession to a render target
  39965. * @param session session to create render target for
  39966. * @param scene scene the new render target should be created for
  39967. */
  39968. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39969. /**
  39970. * Disposes of the session manager
  39971. */
  39972. dispose(): void;
  39973. }
  39974. }
  39975. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39976. import { Scene } from "babylonjs/scene";
  39977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39978. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39979. /**
  39980. * WebXR Camera which holds the views for the xrSession
  39981. * @see https://doc.babylonjs.com/how_to/webxr
  39982. */
  39983. export class WebXRCamera extends FreeCamera {
  39984. private static _TmpMatrix;
  39985. /**
  39986. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39987. * @param name the name of the camera
  39988. * @param scene the scene to add the camera to
  39989. */
  39990. constructor(name: string, scene: Scene);
  39991. private _updateNumberOfRigCameras;
  39992. /** @hidden */
  39993. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39994. /**
  39995. * Updates the cameras position from the current pose information of the XR session
  39996. * @param xrSessionManager the session containing pose information
  39997. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39998. */
  39999. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40000. }
  40001. }
  40002. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40003. import { Nullable } from "babylonjs/types";
  40004. import { Observable } from "babylonjs/Misc/observable";
  40005. import { IDisposable, Scene } from "babylonjs/scene";
  40006. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40008. import { Ray } from "babylonjs/Culling/ray";
  40009. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40010. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40011. /**
  40012. * States of the webXR experience
  40013. */
  40014. export enum WebXRState {
  40015. /**
  40016. * Transitioning to being in XR mode
  40017. */
  40018. ENTERING_XR = 0,
  40019. /**
  40020. * Transitioning to non XR mode
  40021. */
  40022. EXITING_XR = 1,
  40023. /**
  40024. * In XR mode and presenting
  40025. */
  40026. IN_XR = 2,
  40027. /**
  40028. * Not entered XR mode
  40029. */
  40030. NOT_IN_XR = 3
  40031. }
  40032. /**
  40033. * Helper class used to enable XR
  40034. * @see https://doc.babylonjs.com/how_to/webxr
  40035. */
  40036. export class WebXRExperienceHelper implements IDisposable {
  40037. private scene;
  40038. /**
  40039. * 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
  40040. */
  40041. container: AbstractMesh;
  40042. /**
  40043. * Camera used to render xr content
  40044. */
  40045. camera: WebXRCamera;
  40046. /**
  40047. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40048. */
  40049. state: WebXRState;
  40050. private _setState;
  40051. private static _TmpVector;
  40052. /**
  40053. * Fires when the state of the experience helper has changed
  40054. */
  40055. onStateChangedObservable: Observable<WebXRState>;
  40056. /** @hidden */
  40057. _sessionManager: WebXRSessionManager;
  40058. private _nonVRCamera;
  40059. private _originalSceneAutoClear;
  40060. private _supported;
  40061. /**
  40062. * Creates the experience helper
  40063. * @param scene the scene to attach the experience helper to
  40064. * @returns a promise for the experience helper
  40065. */
  40066. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40067. /**
  40068. * Creates a WebXRExperienceHelper
  40069. * @param scene The scene the helper should be created in
  40070. */
  40071. private constructor();
  40072. /**
  40073. * Exits XR mode and returns the scene to its original state
  40074. * @returns promise that resolves after xr mode has exited
  40075. */
  40076. exitXRAsync(): Promise<void>;
  40077. /**
  40078. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40079. * @param sessionCreationOptions options for the XR session
  40080. * @param frameOfReference frame of reference of the XR session
  40081. * @returns promise that resolves after xr mode has entered
  40082. */
  40083. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40084. /**
  40085. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40086. * @param ray ray to cast into the environment
  40087. * @returns Promise which resolves with a collision point in the environment if it exists
  40088. */
  40089. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40090. /**
  40091. * Updates the global position of the camera by moving the camera's container
  40092. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40093. * @param position The desired global position of the camera
  40094. */
  40095. setPositionOfCameraUsingContainer(position: Vector3): void;
  40096. /**
  40097. * Rotates the xr camera by rotating the camera's container around the camera's position
  40098. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40099. * @param rotation the desired quaternion rotation to apply to the camera
  40100. */
  40101. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40102. /**
  40103. * Checks if the creation options are supported by the xr session
  40104. * @param options creation options
  40105. * @returns true if supported
  40106. */
  40107. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40108. /**
  40109. * Disposes of the experience helper
  40110. */
  40111. dispose(): void;
  40112. }
  40113. }
  40114. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40115. import { Nullable } from "babylonjs/types";
  40116. import { Observable } from "babylonjs/Misc/observable";
  40117. import { IDisposable, Scene } from "babylonjs/scene";
  40118. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40119. /**
  40120. * Button which can be used to enter a different mode of XR
  40121. */
  40122. export class WebXREnterExitUIButton {
  40123. /** button element */
  40124. element: HTMLElement;
  40125. /** XR initialization options for the button */
  40126. initializationOptions: XRSessionCreationOptions;
  40127. /**
  40128. * Creates a WebXREnterExitUIButton
  40129. * @param element button element
  40130. * @param initializationOptions XR initialization options for the button
  40131. */
  40132. constructor(
  40133. /** button element */
  40134. element: HTMLElement,
  40135. /** XR initialization options for the button */
  40136. initializationOptions: XRSessionCreationOptions);
  40137. /**
  40138. * Overwritable function which can be used to update the button's visuals when the state changes
  40139. * @param activeButton the current active button in the UI
  40140. */
  40141. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40142. }
  40143. /**
  40144. * Options to create the webXR UI
  40145. */
  40146. export class WebXREnterExitUIOptions {
  40147. /**
  40148. * Context to enter xr with
  40149. */
  40150. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40151. /**
  40152. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40153. */
  40154. customButtons?: Array<WebXREnterExitUIButton>;
  40155. }
  40156. /**
  40157. * UI to allow the user to enter/exit XR mode
  40158. */
  40159. export class WebXREnterExitUI implements IDisposable {
  40160. private scene;
  40161. private _overlay;
  40162. private _buttons;
  40163. private _activeButton;
  40164. /**
  40165. * Fired every time the active button is changed.
  40166. *
  40167. * When xr is entered via a button that launches xr that button will be the callback parameter
  40168. *
  40169. * When exiting xr the callback parameter will be null)
  40170. */
  40171. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40172. /**
  40173. * Creates UI to allow the user to enter/exit XR mode
  40174. * @param scene the scene to add the ui to
  40175. * @param helper the xr experience helper to enter/exit xr with
  40176. * @param options options to configure the UI
  40177. * @returns the created ui
  40178. */
  40179. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40180. private constructor();
  40181. private _updateButtons;
  40182. /**
  40183. * Disposes of the object
  40184. */
  40185. dispose(): void;
  40186. }
  40187. }
  40188. declare module "babylonjs/Cameras/XR/webXRInput" {
  40189. import { IDisposable, Scene } from "babylonjs/scene";
  40190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40191. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40192. /**
  40193. * Represents an XR input
  40194. */
  40195. export class WebXRController {
  40196. /**
  40197. * 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
  40198. */
  40199. grip?: AbstractMesh;
  40200. /**
  40201. * Pointer which can be used to select objects or attach a visible laser to
  40202. */
  40203. pointer: AbstractMesh;
  40204. /**
  40205. * Creates the controller
  40206. * @see https://doc.babylonjs.com/how_to/webxr
  40207. * @param scene the scene which the controller should be associated to
  40208. */
  40209. constructor(scene: Scene);
  40210. /**
  40211. * Disposes of the object
  40212. */
  40213. dispose(): void;
  40214. }
  40215. /**
  40216. * XR input used to track XR inputs such as controllers/rays
  40217. */
  40218. export class WebXRInput implements IDisposable {
  40219. private helper;
  40220. /**
  40221. * XR controllers being tracked
  40222. */
  40223. controllers: Array<WebXRController>;
  40224. private _tmpMatrix;
  40225. private _frameObserver;
  40226. /**
  40227. * Initializes the WebXRInput
  40228. * @param helper experience helper which the input should be created for
  40229. */
  40230. constructor(helper: WebXRExperienceHelper);
  40231. /**
  40232. * Disposes of the object
  40233. */
  40234. dispose(): void;
  40235. }
  40236. }
  40237. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40238. import { Nullable } from "babylonjs/types";
  40239. import { IDisposable } from "babylonjs/scene";
  40240. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40241. /**
  40242. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40243. */
  40244. export class WebXRManagedOutputCanvas implements IDisposable {
  40245. private _canvas;
  40246. /**
  40247. * xrpresent context of the canvas which can be used to display/mirror xr content
  40248. */
  40249. canvasContext: Nullable<WebGLRenderingContext>;
  40250. /**
  40251. * Initializes the canvas to be added/removed upon entering/exiting xr
  40252. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40253. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40254. */
  40255. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40256. /**
  40257. * Disposes of the object
  40258. */
  40259. dispose(): void;
  40260. private _setManagedOutputCanvas;
  40261. private _addCanvas;
  40262. private _removeCanvas;
  40263. }
  40264. }
  40265. declare module "babylonjs/Cameras/XR/index" {
  40266. export * from "babylonjs/Cameras/XR/webXRCamera";
  40267. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40268. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40269. export * from "babylonjs/Cameras/XR/webXRInput";
  40270. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40271. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40272. }
  40273. declare module "babylonjs/Cameras/RigModes/index" {
  40274. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40275. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40276. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40277. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40278. }
  40279. declare module "babylonjs/Cameras/index" {
  40280. export * from "babylonjs/Cameras/Inputs/index";
  40281. export * from "babylonjs/Cameras/cameraInputsManager";
  40282. export * from "babylonjs/Cameras/camera";
  40283. export * from "babylonjs/Cameras/targetCamera";
  40284. export * from "babylonjs/Cameras/freeCamera";
  40285. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40286. export * from "babylonjs/Cameras/touchCamera";
  40287. export * from "babylonjs/Cameras/arcRotateCamera";
  40288. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40289. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40290. export * from "babylonjs/Cameras/flyCamera";
  40291. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40292. export * from "babylonjs/Cameras/followCamera";
  40293. export * from "babylonjs/Cameras/gamepadCamera";
  40294. export * from "babylonjs/Cameras/Stereoscopic/index";
  40295. export * from "babylonjs/Cameras/universalCamera";
  40296. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40297. export * from "babylonjs/Cameras/VR/index";
  40298. export * from "babylonjs/Cameras/XR/index";
  40299. export * from "babylonjs/Cameras/RigModes/index";
  40300. }
  40301. declare module "babylonjs/Collisions/index" {
  40302. export * from "babylonjs/Collisions/collider";
  40303. export * from "babylonjs/Collisions/collisionCoordinator";
  40304. export * from "babylonjs/Collisions/pickingInfo";
  40305. export * from "babylonjs/Collisions/intersectionInfo";
  40306. }
  40307. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40308. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40309. import { Vector3, Plane } from "babylonjs/Maths/math";
  40310. import { Ray } from "babylonjs/Culling/ray";
  40311. /**
  40312. * Contains an array of blocks representing the octree
  40313. */
  40314. export interface IOctreeContainer<T> {
  40315. /**
  40316. * Blocks within the octree
  40317. */
  40318. blocks: Array<OctreeBlock<T>>;
  40319. }
  40320. /**
  40321. * Class used to store a cell in an octree
  40322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40323. */
  40324. export class OctreeBlock<T> {
  40325. /**
  40326. * Gets the content of the current block
  40327. */
  40328. entries: T[];
  40329. /**
  40330. * Gets the list of block children
  40331. */
  40332. blocks: Array<OctreeBlock<T>>;
  40333. private _depth;
  40334. private _maxDepth;
  40335. private _capacity;
  40336. private _minPoint;
  40337. private _maxPoint;
  40338. private _boundingVectors;
  40339. private _creationFunc;
  40340. /**
  40341. * Creates a new block
  40342. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40343. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40344. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40345. * @param depth defines the current depth of this block in the octree
  40346. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40347. * @param creationFunc defines a callback to call when an element is added to the block
  40348. */
  40349. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40350. /**
  40351. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40352. */
  40353. readonly capacity: number;
  40354. /**
  40355. * Gets the minimum vector (in world space) of the block's bounding box
  40356. */
  40357. readonly minPoint: Vector3;
  40358. /**
  40359. * Gets the maximum vector (in world space) of the block's bounding box
  40360. */
  40361. readonly maxPoint: Vector3;
  40362. /**
  40363. * Add a new element to this block
  40364. * @param entry defines the element to add
  40365. */
  40366. addEntry(entry: T): void;
  40367. /**
  40368. * Remove an element from this block
  40369. * @param entry defines the element to remove
  40370. */
  40371. removeEntry(entry: T): void;
  40372. /**
  40373. * Add an array of elements to this block
  40374. * @param entries defines the array of elements to add
  40375. */
  40376. addEntries(entries: T[]): void;
  40377. /**
  40378. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40379. * @param frustumPlanes defines the frustum planes to test
  40380. * @param selection defines the array to store current content if selection is positive
  40381. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40382. */
  40383. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40384. /**
  40385. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40386. * @param sphereCenter defines the bounding sphere center
  40387. * @param sphereRadius defines the bounding sphere radius
  40388. * @param selection defines the array to store current content if selection is positive
  40389. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40390. */
  40391. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40392. /**
  40393. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40394. * @param ray defines the ray to test with
  40395. * @param selection defines the array to store current content if selection is positive
  40396. */
  40397. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40398. /**
  40399. * Subdivide the content into child blocks (this block will then be empty)
  40400. */
  40401. createInnerBlocks(): void;
  40402. /**
  40403. * @hidden
  40404. */
  40405. 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;
  40406. }
  40407. }
  40408. declare module "babylonjs/Culling/Octrees/octree" {
  40409. import { SmartArray } from "babylonjs/Misc/smartArray";
  40410. import { Vector3, Plane } from "babylonjs/Maths/math";
  40411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40413. import { Ray } from "babylonjs/Culling/ray";
  40414. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40415. /**
  40416. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40418. */
  40419. export class Octree<T> {
  40420. /** 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.) */
  40421. maxDepth: number;
  40422. /**
  40423. * Blocks within the octree containing objects
  40424. */
  40425. blocks: Array<OctreeBlock<T>>;
  40426. /**
  40427. * Content stored in the octree
  40428. */
  40429. dynamicContent: T[];
  40430. private _maxBlockCapacity;
  40431. private _selectionContent;
  40432. private _creationFunc;
  40433. /**
  40434. * Creates a octree
  40435. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40436. * @param creationFunc function to be used to instatiate the octree
  40437. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40438. * @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.)
  40439. */
  40440. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40441. /** 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.) */
  40442. maxDepth?: number);
  40443. /**
  40444. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40445. * @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);
  40446. * @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);
  40447. * @param entries meshes to be added to the octree blocks
  40448. */
  40449. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40450. /**
  40451. * Adds a mesh to the octree
  40452. * @param entry Mesh to add to the octree
  40453. */
  40454. addMesh(entry: T): void;
  40455. /**
  40456. * Remove an element from the octree
  40457. * @param entry defines the element to remove
  40458. */
  40459. removeMesh(entry: T): void;
  40460. /**
  40461. * Selects an array of meshes within the frustum
  40462. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40463. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40464. * @returns array of meshes within the frustum
  40465. */
  40466. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40467. /**
  40468. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40469. * @param sphereCenter defines the bounding sphere center
  40470. * @param sphereRadius defines the bounding sphere radius
  40471. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40472. * @returns an array of objects that intersect the sphere
  40473. */
  40474. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40475. /**
  40476. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40477. * @param ray defines the ray to test with
  40478. * @returns array of intersected objects
  40479. */
  40480. intersectsRay(ray: Ray): SmartArray<T>;
  40481. /**
  40482. * Adds a mesh into the octree block if it intersects the block
  40483. */
  40484. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40485. /**
  40486. * Adds a submesh into the octree block if it intersects the block
  40487. */
  40488. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40489. }
  40490. }
  40491. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40492. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40493. import { Scene } from "babylonjs/scene";
  40494. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40496. import { Ray } from "babylonjs/Culling/ray";
  40497. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40498. import { Collider } from "babylonjs/Collisions/collider";
  40499. module "babylonjs/scene" {
  40500. interface Scene {
  40501. /**
  40502. * @hidden
  40503. * Backing Filed
  40504. */
  40505. _selectionOctree: Octree<AbstractMesh>;
  40506. /**
  40507. * Gets the octree used to boost mesh selection (picking)
  40508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40509. */
  40510. selectionOctree: Octree<AbstractMesh>;
  40511. /**
  40512. * Creates or updates the octree used to boost selection (picking)
  40513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40514. * @param maxCapacity defines the maximum capacity per leaf
  40515. * @param maxDepth defines the maximum depth of the octree
  40516. * @returns an octree of AbstractMesh
  40517. */
  40518. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40519. }
  40520. }
  40521. module "babylonjs/Meshes/abstractMesh" {
  40522. interface AbstractMesh {
  40523. /**
  40524. * @hidden
  40525. * Backing Field
  40526. */
  40527. _submeshesOctree: Octree<SubMesh>;
  40528. /**
  40529. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40530. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40531. * @param maxCapacity defines the maximum size of each block (64 by default)
  40532. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40533. * @returns the new octree
  40534. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40536. */
  40537. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40538. }
  40539. }
  40540. /**
  40541. * Defines the octree scene component responsible to manage any octrees
  40542. * in a given scene.
  40543. */
  40544. export class OctreeSceneComponent {
  40545. /**
  40546. * The component name helpfull to identify the component in the list of scene components.
  40547. */
  40548. readonly name: string;
  40549. /**
  40550. * The scene the component belongs to.
  40551. */
  40552. scene: Scene;
  40553. /**
  40554. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40555. */
  40556. readonly checksIsEnabled: boolean;
  40557. /**
  40558. * Creates a new instance of the component for the given scene
  40559. * @param scene Defines the scene to register the component in
  40560. */
  40561. constructor(scene: Scene);
  40562. /**
  40563. * Registers the component in a given scene
  40564. */
  40565. register(): void;
  40566. /**
  40567. * Return the list of active meshes
  40568. * @returns the list of active meshes
  40569. */
  40570. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40571. /**
  40572. * Return the list of active sub meshes
  40573. * @param mesh The mesh to get the candidates sub meshes from
  40574. * @returns the list of active sub meshes
  40575. */
  40576. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40577. private _tempRay;
  40578. /**
  40579. * Return the list of sub meshes intersecting with a given local ray
  40580. * @param mesh defines the mesh to find the submesh for
  40581. * @param localRay defines the ray in local space
  40582. * @returns the list of intersecting sub meshes
  40583. */
  40584. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40585. /**
  40586. * Return the list of sub meshes colliding with a collider
  40587. * @param mesh defines the mesh to find the submesh for
  40588. * @param collider defines the collider to evaluate the collision against
  40589. * @returns the list of colliding sub meshes
  40590. */
  40591. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40592. /**
  40593. * Rebuilds the elements related to this component in case of
  40594. * context lost for instance.
  40595. */
  40596. rebuild(): void;
  40597. /**
  40598. * Disposes the component and the associated ressources.
  40599. */
  40600. dispose(): void;
  40601. }
  40602. }
  40603. declare module "babylonjs/Culling/Octrees/index" {
  40604. export * from "babylonjs/Culling/Octrees/octree";
  40605. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40606. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40607. }
  40608. declare module "babylonjs/Culling/index" {
  40609. export * from "babylonjs/Culling/boundingBox";
  40610. export * from "babylonjs/Culling/boundingInfo";
  40611. export * from "babylonjs/Culling/boundingSphere";
  40612. export * from "babylonjs/Culling/Octrees/index";
  40613. export * from "babylonjs/Culling/ray";
  40614. }
  40615. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40616. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40617. import { Nullable } from "babylonjs/types";
  40618. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40619. import { Scene } from "babylonjs/scene";
  40620. /**
  40621. * Class containing static functions to help procedurally build meshes
  40622. */
  40623. export class LinesBuilder {
  40624. /**
  40625. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40626. * * 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
  40627. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40628. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40629. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40630. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40631. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40632. * * 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
  40633. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40636. * @param name defines the name of the new line system
  40637. * @param options defines the options used to create the line system
  40638. * @param scene defines the hosting scene
  40639. * @returns a new line system mesh
  40640. */
  40641. static CreateLineSystem(name: string, options: {
  40642. lines: Vector3[][];
  40643. updatable?: boolean;
  40644. instance?: Nullable<LinesMesh>;
  40645. colors?: Nullable<Color4[][]>;
  40646. useVertexAlpha?: boolean;
  40647. }, scene: Nullable<Scene>): LinesMesh;
  40648. /**
  40649. * Creates a line mesh
  40650. * 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
  40651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40652. * * The parameter `points` is an array successive Vector3
  40653. * * 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
  40654. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40655. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40656. * * When updating an instance, remember that only point positions can change, not the number of points
  40657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40659. * @param name defines the name of the new line system
  40660. * @param options defines the options used to create the line system
  40661. * @param scene defines the hosting scene
  40662. * @returns a new line mesh
  40663. */
  40664. static CreateLines(name: string, options: {
  40665. points: Vector3[];
  40666. updatable?: boolean;
  40667. instance?: Nullable<LinesMesh>;
  40668. colors?: Color4[];
  40669. useVertexAlpha?: boolean;
  40670. }, scene?: Nullable<Scene>): LinesMesh;
  40671. /**
  40672. * Creates a dashed line mesh
  40673. * * 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
  40674. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40675. * * The parameter `points` is an array successive Vector3
  40676. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40677. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40678. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40679. * * 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
  40680. * * When updating an instance, remember that only point positions can change, not the number of points
  40681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40682. * @param name defines the name of the mesh
  40683. * @param options defines the options used to create the mesh
  40684. * @param scene defines the hosting scene
  40685. * @returns the dashed line mesh
  40686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40687. */
  40688. static CreateDashedLines(name: string, options: {
  40689. points: Vector3[];
  40690. dashSize?: number;
  40691. gapSize?: number;
  40692. dashNb?: number;
  40693. updatable?: boolean;
  40694. instance?: LinesMesh;
  40695. }, scene?: Nullable<Scene>): LinesMesh;
  40696. }
  40697. }
  40698. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40699. import { IDisposable, Scene } from "babylonjs/scene";
  40700. import { Nullable } from "babylonjs/types";
  40701. import { Observable } from "babylonjs/Misc/observable";
  40702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40703. /**
  40704. * Renders a layer on top of an existing scene
  40705. */
  40706. export class UtilityLayerRenderer implements IDisposable {
  40707. /** the original scene that will be rendered on top of */
  40708. originalScene: Scene;
  40709. private _pointerCaptures;
  40710. private _lastPointerEvents;
  40711. private static _DefaultUtilityLayer;
  40712. private static _DefaultKeepDepthUtilityLayer;
  40713. /**
  40714. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40715. */
  40716. pickUtilitySceneFirst: boolean;
  40717. /**
  40718. * 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)
  40719. */
  40720. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40721. /**
  40722. * 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)
  40723. */
  40724. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40725. /**
  40726. * The scene that is rendered on top of the original scene
  40727. */
  40728. utilityLayerScene: Scene;
  40729. /**
  40730. * If the utility layer should automatically be rendered on top of existing scene
  40731. */
  40732. shouldRender: boolean;
  40733. /**
  40734. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40735. */
  40736. onlyCheckPointerDownEvents: boolean;
  40737. /**
  40738. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40739. */
  40740. processAllEvents: boolean;
  40741. /**
  40742. * Observable raised when the pointer move from the utility layer scene to the main scene
  40743. */
  40744. onPointerOutObservable: Observable<number>;
  40745. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40746. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40747. private _afterRenderObserver;
  40748. private _sceneDisposeObserver;
  40749. private _originalPointerObserver;
  40750. /**
  40751. * Instantiates a UtilityLayerRenderer
  40752. * @param originalScene the original scene that will be rendered on top of
  40753. * @param handleEvents boolean indicating if the utility layer should handle events
  40754. */
  40755. constructor(
  40756. /** the original scene that will be rendered on top of */
  40757. originalScene: Scene, handleEvents?: boolean);
  40758. private _notifyObservers;
  40759. /**
  40760. * Renders the utility layers scene on top of the original scene
  40761. */
  40762. render(): void;
  40763. /**
  40764. * Disposes of the renderer
  40765. */
  40766. dispose(): void;
  40767. private _updateCamera;
  40768. }
  40769. }
  40770. declare module "babylonjs/Gizmos/gizmo" {
  40771. import { Nullable } from "babylonjs/types";
  40772. import { IDisposable } from "babylonjs/scene";
  40773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40774. import { Mesh } from "babylonjs/Meshes/mesh";
  40775. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40776. /**
  40777. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40778. */
  40779. export class Gizmo implements IDisposable {
  40780. /** The utility layer the gizmo will be added to */
  40781. gizmoLayer: UtilityLayerRenderer;
  40782. /**
  40783. * The root mesh of the gizmo
  40784. */
  40785. _rootMesh: Mesh;
  40786. private _attachedMesh;
  40787. /**
  40788. * Ratio for the scale of the gizmo (Default: 1)
  40789. */
  40790. scaleRatio: number;
  40791. private _tmpMatrix;
  40792. /**
  40793. * If a custom mesh has been set (Default: false)
  40794. */
  40795. protected _customMeshSet: boolean;
  40796. /**
  40797. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40798. * * When set, interactions will be enabled
  40799. */
  40800. attachedMesh: Nullable<AbstractMesh>;
  40801. /**
  40802. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40803. * @param mesh The mesh to replace the default mesh of the gizmo
  40804. */
  40805. setCustomMesh(mesh: Mesh): void;
  40806. /**
  40807. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40808. */
  40809. updateGizmoRotationToMatchAttachedMesh: boolean;
  40810. /**
  40811. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40812. */
  40813. updateGizmoPositionToMatchAttachedMesh: boolean;
  40814. /**
  40815. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40816. */
  40817. protected _updateScale: boolean;
  40818. protected _interactionsEnabled: boolean;
  40819. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40820. private _beforeRenderObserver;
  40821. /**
  40822. * Creates a gizmo
  40823. * @param gizmoLayer The utility layer the gizmo will be added to
  40824. */
  40825. constructor(
  40826. /** The utility layer the gizmo will be added to */
  40827. gizmoLayer?: UtilityLayerRenderer);
  40828. private _tempVector;
  40829. /**
  40830. * @hidden
  40831. * Updates the gizmo to match the attached mesh's position/rotation
  40832. */
  40833. protected _update(): void;
  40834. /**
  40835. * Disposes of the gizmo
  40836. */
  40837. dispose(): void;
  40838. }
  40839. }
  40840. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40841. import { Observable } from "babylonjs/Misc/observable";
  40842. import { Nullable } from "babylonjs/types";
  40843. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40846. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40847. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40848. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40849. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40850. import { Scene } from "babylonjs/scene";
  40851. /**
  40852. * Single axis drag gizmo
  40853. */
  40854. export class AxisDragGizmo extends Gizmo {
  40855. /**
  40856. * Drag behavior responsible for the gizmos dragging interactions
  40857. */
  40858. dragBehavior: PointerDragBehavior;
  40859. private _pointerObserver;
  40860. /**
  40861. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40862. */
  40863. snapDistance: number;
  40864. /**
  40865. * Event that fires each time the gizmo snaps to a new location.
  40866. * * snapDistance is the the change in distance
  40867. */
  40868. onSnapObservable: Observable<{
  40869. snapDistance: number;
  40870. }>;
  40871. /** @hidden */
  40872. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40873. /** @hidden */
  40874. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40875. /**
  40876. * Creates an AxisDragGizmo
  40877. * @param gizmoLayer The utility layer the gizmo will be added to
  40878. * @param dragAxis The axis which the gizmo will be able to drag on
  40879. * @param color The color of the gizmo
  40880. */
  40881. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40882. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40883. /**
  40884. * Disposes of the gizmo
  40885. */
  40886. dispose(): void;
  40887. }
  40888. }
  40889. declare module "babylonjs/Debug/axesViewer" {
  40890. import { Vector3 } from "babylonjs/Maths/math";
  40891. import { Nullable } from "babylonjs/types";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40894. /**
  40895. * The Axes viewer will show 3 axes in a specific point in space
  40896. */
  40897. export class AxesViewer {
  40898. private _xAxis;
  40899. private _yAxis;
  40900. private _zAxis;
  40901. private _scaleLinesFactor;
  40902. private _instanced;
  40903. /**
  40904. * Gets the hosting scene
  40905. */
  40906. scene: Scene;
  40907. /**
  40908. * Gets or sets a number used to scale line length
  40909. */
  40910. scaleLines: number;
  40911. /** Gets the node hierarchy used to render x-axis */
  40912. readonly xAxis: TransformNode;
  40913. /** Gets the node hierarchy used to render y-axis */
  40914. readonly yAxis: TransformNode;
  40915. /** Gets the node hierarchy used to render z-axis */
  40916. readonly zAxis: TransformNode;
  40917. /**
  40918. * Creates a new AxesViewer
  40919. * @param scene defines the hosting scene
  40920. * @param scaleLines defines a number used to scale line length (1 by default)
  40921. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40922. * @param xAxis defines the node hierarchy used to render the x-axis
  40923. * @param yAxis defines the node hierarchy used to render the y-axis
  40924. * @param zAxis defines the node hierarchy used to render the z-axis
  40925. */
  40926. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40927. /**
  40928. * Force the viewer to update
  40929. * @param position defines the position of the viewer
  40930. * @param xaxis defines the x axis of the viewer
  40931. * @param yaxis defines the y axis of the viewer
  40932. * @param zaxis defines the z axis of the viewer
  40933. */
  40934. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40935. /**
  40936. * Creates an instance of this axes viewer.
  40937. * @returns a new axes viewer with instanced meshes
  40938. */
  40939. createInstance(): AxesViewer;
  40940. /** Releases resources */
  40941. dispose(): void;
  40942. private static _SetRenderingGroupId;
  40943. }
  40944. }
  40945. declare module "babylonjs/Debug/boneAxesViewer" {
  40946. import { Nullable } from "babylonjs/types";
  40947. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40948. import { Vector3 } from "babylonjs/Maths/math";
  40949. import { Mesh } from "babylonjs/Meshes/mesh";
  40950. import { Bone } from "babylonjs/Bones/bone";
  40951. import { Scene } from "babylonjs/scene";
  40952. /**
  40953. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40954. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40955. */
  40956. export class BoneAxesViewer extends AxesViewer {
  40957. /**
  40958. * Gets or sets the target mesh where to display the axes viewer
  40959. */
  40960. mesh: Nullable<Mesh>;
  40961. /**
  40962. * Gets or sets the target bone where to display the axes viewer
  40963. */
  40964. bone: Nullable<Bone>;
  40965. /** Gets current position */
  40966. pos: Vector3;
  40967. /** Gets direction of X axis */
  40968. xaxis: Vector3;
  40969. /** Gets direction of Y axis */
  40970. yaxis: Vector3;
  40971. /** Gets direction of Z axis */
  40972. zaxis: Vector3;
  40973. /**
  40974. * Creates a new BoneAxesViewer
  40975. * @param scene defines the hosting scene
  40976. * @param bone defines the target bone
  40977. * @param mesh defines the target mesh
  40978. * @param scaleLines defines a scaling factor for line length (1 by default)
  40979. */
  40980. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40981. /**
  40982. * Force the viewer to update
  40983. */
  40984. update(): void;
  40985. /** Releases resources */
  40986. dispose(): void;
  40987. }
  40988. }
  40989. declare module "babylonjs/Debug/debugLayer" {
  40990. import { Observable } from "babylonjs/Misc/observable";
  40991. import { Scene } from "babylonjs/scene";
  40992. /**
  40993. * Interface used to define scene explorer extensibility option
  40994. */
  40995. export interface IExplorerExtensibilityOption {
  40996. /**
  40997. * Define the option label
  40998. */
  40999. label: string;
  41000. /**
  41001. * Defines the action to execute on click
  41002. */
  41003. action: (entity: any) => void;
  41004. }
  41005. /**
  41006. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41007. */
  41008. export interface IExplorerExtensibilityGroup {
  41009. /**
  41010. * Defines a predicate to test if a given type mut be extended
  41011. */
  41012. predicate: (entity: any) => boolean;
  41013. /**
  41014. * Gets the list of options added to a type
  41015. */
  41016. entries: IExplorerExtensibilityOption[];
  41017. }
  41018. /**
  41019. * Interface used to define the options to use to create the Inspector
  41020. */
  41021. export interface IInspectorOptions {
  41022. /**
  41023. * Display in overlay mode (default: false)
  41024. */
  41025. overlay?: boolean;
  41026. /**
  41027. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41028. */
  41029. globalRoot?: HTMLElement;
  41030. /**
  41031. * Display the Scene explorer
  41032. */
  41033. showExplorer?: boolean;
  41034. /**
  41035. * Display the property inspector
  41036. */
  41037. showInspector?: boolean;
  41038. /**
  41039. * Display in embed mode (both panes on the right)
  41040. */
  41041. embedMode?: boolean;
  41042. /**
  41043. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41044. */
  41045. handleResize?: boolean;
  41046. /**
  41047. * Allow the panes to popup (default: true)
  41048. */
  41049. enablePopup?: boolean;
  41050. /**
  41051. * Allow the panes to be closed by users (default: true)
  41052. */
  41053. enableClose?: boolean;
  41054. /**
  41055. * Optional list of extensibility entries
  41056. */
  41057. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41058. }
  41059. module "babylonjs/scene" {
  41060. interface Scene {
  41061. /**
  41062. * @hidden
  41063. * Backing field
  41064. */
  41065. _debugLayer: DebugLayer;
  41066. /**
  41067. * Gets the debug layer (aka Inspector) associated with the scene
  41068. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41069. */
  41070. debugLayer: DebugLayer;
  41071. }
  41072. }
  41073. /**
  41074. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41075. * what is happening in your scene
  41076. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41077. */
  41078. export class DebugLayer {
  41079. /**
  41080. * Define the url to get the inspector script from.
  41081. * By default it uses the babylonjs CDN.
  41082. * @ignoreNaming
  41083. */
  41084. static InspectorURL: string;
  41085. private _scene;
  41086. private BJSINSPECTOR;
  41087. /**
  41088. * Observable triggered when a property is changed through the inspector.
  41089. */
  41090. onPropertyChangedObservable: Observable<{
  41091. object: any;
  41092. property: string;
  41093. value: any;
  41094. initialValue: any;
  41095. }>;
  41096. /**
  41097. * Instantiates a new debug layer.
  41098. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41099. * what is happening in your scene
  41100. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41101. * @param scene Defines the scene to inspect
  41102. */
  41103. constructor(scene: Scene);
  41104. /** Creates the inspector window. */
  41105. private _createInspector;
  41106. /** Get the inspector from bundle or global */
  41107. private _getGlobalInspector;
  41108. /**
  41109. * Get if the inspector is visible or not.
  41110. * @returns true if visible otherwise, false
  41111. */
  41112. isVisible(): boolean;
  41113. /**
  41114. * Hide the inspector and close its window.
  41115. */
  41116. hide(): void;
  41117. /**
  41118. * Launch the debugLayer.
  41119. * @param config Define the configuration of the inspector
  41120. */
  41121. show(config?: IInspectorOptions): void;
  41122. }
  41123. }
  41124. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41125. import { Nullable } from "babylonjs/types";
  41126. import { Scene } from "babylonjs/scene";
  41127. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41128. import { Mesh } from "babylonjs/Meshes/mesh";
  41129. /**
  41130. * Class containing static functions to help procedurally build meshes
  41131. */
  41132. export class BoxBuilder {
  41133. /**
  41134. * Creates a box mesh
  41135. * * The parameter `size` sets the size (float) of each box side (default 1)
  41136. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41137. * * 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)
  41138. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41142. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41143. * @param name defines the name of the mesh
  41144. * @param options defines the options used to create the mesh
  41145. * @param scene defines the hosting scene
  41146. * @returns the box mesh
  41147. */
  41148. static CreateBox(name: string, options: {
  41149. size?: number;
  41150. width?: number;
  41151. height?: number;
  41152. depth?: number;
  41153. faceUV?: Vector4[];
  41154. faceColors?: Color4[];
  41155. sideOrientation?: number;
  41156. frontUVs?: Vector4;
  41157. backUVs?: Vector4;
  41158. updatable?: boolean;
  41159. }, scene?: Nullable<Scene>): Mesh;
  41160. }
  41161. }
  41162. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41163. import { Vector4 } from "babylonjs/Maths/math";
  41164. import { Mesh } from "babylonjs/Meshes/mesh";
  41165. /**
  41166. * Class containing static functions to help procedurally build meshes
  41167. */
  41168. export class SphereBuilder {
  41169. /**
  41170. * Creates a sphere mesh
  41171. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41172. * * 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`)
  41173. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41174. * * 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
  41175. * * 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)
  41176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41179. * @param name defines the name of the mesh
  41180. * @param options defines the options used to create the mesh
  41181. * @param scene defines the hosting scene
  41182. * @returns the sphere mesh
  41183. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41184. */
  41185. static CreateSphere(name: string, options: {
  41186. segments?: number;
  41187. diameter?: number;
  41188. diameterX?: number;
  41189. diameterY?: number;
  41190. diameterZ?: number;
  41191. arc?: number;
  41192. slice?: number;
  41193. sideOrientation?: number;
  41194. frontUVs?: Vector4;
  41195. backUVs?: Vector4;
  41196. updatable?: boolean;
  41197. }, scene: any): Mesh;
  41198. }
  41199. }
  41200. declare module "babylonjs/Debug/physicsViewer" {
  41201. import { Nullable } from "babylonjs/types";
  41202. import { Scene } from "babylonjs/scene";
  41203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41204. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41205. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41206. /**
  41207. * Used to show the physics impostor around the specific mesh
  41208. */
  41209. export class PhysicsViewer {
  41210. /** @hidden */
  41211. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41212. /** @hidden */
  41213. protected _meshes: Array<Nullable<AbstractMesh>>;
  41214. /** @hidden */
  41215. protected _scene: Nullable<Scene>;
  41216. /** @hidden */
  41217. protected _numMeshes: number;
  41218. /** @hidden */
  41219. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41220. private _renderFunction;
  41221. private _utilityLayer;
  41222. private _debugBoxMesh;
  41223. private _debugSphereMesh;
  41224. private _debugMaterial;
  41225. /**
  41226. * Creates a new PhysicsViewer
  41227. * @param scene defines the hosting scene
  41228. */
  41229. constructor(scene: Scene);
  41230. /** @hidden */
  41231. protected _updateDebugMeshes(): void;
  41232. /**
  41233. * Renders a specified physic impostor
  41234. * @param impostor defines the impostor to render
  41235. * @returns the new debug mesh used to render the impostor
  41236. */
  41237. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41238. /**
  41239. * Hides a specified physic impostor
  41240. * @param impostor defines the impostor to hide
  41241. */
  41242. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41243. private _getDebugMaterial;
  41244. private _getDebugBoxMesh;
  41245. private _getDebugSphereMesh;
  41246. private _getDebugMesh;
  41247. /** Releases all resources */
  41248. dispose(): void;
  41249. }
  41250. }
  41251. declare module "babylonjs/Debug/rayHelper" {
  41252. import { Nullable } from "babylonjs/types";
  41253. import { Ray } from "babylonjs/Culling/ray";
  41254. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41255. import { Scene } from "babylonjs/scene";
  41256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41257. import "babylonjs/Meshes/Builders/linesBuilder";
  41258. /**
  41259. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41260. * in order to better appreciate the issue one might have.
  41261. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41262. */
  41263. export class RayHelper {
  41264. /**
  41265. * Defines the ray we are currently tryin to visualize.
  41266. */
  41267. ray: Nullable<Ray>;
  41268. private _renderPoints;
  41269. private _renderLine;
  41270. private _renderFunction;
  41271. private _scene;
  41272. private _updateToMeshFunction;
  41273. private _attachedToMesh;
  41274. private _meshSpaceDirection;
  41275. private _meshSpaceOrigin;
  41276. /**
  41277. * Helper function to create a colored helper in a scene in one line.
  41278. * @param ray Defines the ray we are currently tryin to visualize
  41279. * @param scene Defines the scene the ray is used in
  41280. * @param color Defines the color we want to see the ray in
  41281. * @returns The newly created ray helper.
  41282. */
  41283. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41284. /**
  41285. * Instantiate a new ray helper.
  41286. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41287. * in order to better appreciate the issue one might have.
  41288. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41289. * @param ray Defines the ray we are currently tryin to visualize
  41290. */
  41291. constructor(ray: Ray);
  41292. /**
  41293. * Shows the ray we are willing to debug.
  41294. * @param scene Defines the scene the ray needs to be rendered in
  41295. * @param color Defines the color the ray needs to be rendered in
  41296. */
  41297. show(scene: Scene, color?: Color3): void;
  41298. /**
  41299. * Hides the ray we are debugging.
  41300. */
  41301. hide(): void;
  41302. private _render;
  41303. /**
  41304. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41305. * @param mesh Defines the mesh we want the helper attached to
  41306. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41307. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41308. * @param length Defines the length of the ray
  41309. */
  41310. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41311. /**
  41312. * Detach the ray helper from the mesh it has previously been attached to.
  41313. */
  41314. detachFromMesh(): void;
  41315. private _updateToMesh;
  41316. /**
  41317. * Dispose the helper and release its associated resources.
  41318. */
  41319. dispose(): void;
  41320. }
  41321. }
  41322. declare module "babylonjs/Debug/skeletonViewer" {
  41323. import { Color3 } from "babylonjs/Maths/math";
  41324. import { Scene } from "babylonjs/scene";
  41325. import { Nullable } from "babylonjs/types";
  41326. import { Skeleton } from "babylonjs/Bones/skeleton";
  41327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41328. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41329. /**
  41330. * Class used to render a debug view of a given skeleton
  41331. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41332. */
  41333. export class SkeletonViewer {
  41334. /** defines the skeleton to render */
  41335. skeleton: Skeleton;
  41336. /** defines the mesh attached to the skeleton */
  41337. mesh: AbstractMesh;
  41338. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41339. autoUpdateBonesMatrices: boolean;
  41340. /** defines the rendering group id to use with the viewer */
  41341. renderingGroupId: number;
  41342. /** Gets or sets the color used to render the skeleton */
  41343. color: Color3;
  41344. private _scene;
  41345. private _debugLines;
  41346. private _debugMesh;
  41347. private _isEnabled;
  41348. private _renderFunction;
  41349. private _utilityLayer;
  41350. /**
  41351. * Returns the mesh used to render the bones
  41352. */
  41353. readonly debugMesh: Nullable<LinesMesh>;
  41354. /**
  41355. * Creates a new SkeletonViewer
  41356. * @param skeleton defines the skeleton to render
  41357. * @param mesh defines the mesh attached to the skeleton
  41358. * @param scene defines the hosting scene
  41359. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41360. * @param renderingGroupId defines the rendering group id to use with the viewer
  41361. */
  41362. constructor(
  41363. /** defines the skeleton to render */
  41364. skeleton: Skeleton,
  41365. /** defines the mesh attached to the skeleton */
  41366. mesh: AbstractMesh, scene: Scene,
  41367. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41368. autoUpdateBonesMatrices?: boolean,
  41369. /** defines the rendering group id to use with the viewer */
  41370. renderingGroupId?: number);
  41371. /** Gets or sets a boolean indicating if the viewer is enabled */
  41372. isEnabled: boolean;
  41373. private _getBonePosition;
  41374. private _getLinesForBonesWithLength;
  41375. private _getLinesForBonesNoLength;
  41376. /** Update the viewer to sync with current skeleton state */
  41377. update(): void;
  41378. /** Release associated resources */
  41379. dispose(): void;
  41380. }
  41381. }
  41382. declare module "babylonjs/Debug/index" {
  41383. export * from "babylonjs/Debug/axesViewer";
  41384. export * from "babylonjs/Debug/boneAxesViewer";
  41385. export * from "babylonjs/Debug/debugLayer";
  41386. export * from "babylonjs/Debug/physicsViewer";
  41387. export * from "babylonjs/Debug/rayHelper";
  41388. export * from "babylonjs/Debug/skeletonViewer";
  41389. }
  41390. declare module "babylonjs/Engines/nullEngine" {
  41391. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41392. import { Scene } from "babylonjs/scene";
  41393. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41394. import { Engine } from "babylonjs/Engines/engine";
  41395. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41396. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41398. import { Effect } from "babylonjs/Materials/effect";
  41399. /**
  41400. * Options to create the null engine
  41401. */
  41402. export class NullEngineOptions {
  41403. /**
  41404. * Render width (Default: 512)
  41405. */
  41406. renderWidth: number;
  41407. /**
  41408. * Render height (Default: 256)
  41409. */
  41410. renderHeight: number;
  41411. /**
  41412. * Texture size (Default: 512)
  41413. */
  41414. textureSize: number;
  41415. /**
  41416. * If delta time between frames should be constant
  41417. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41418. */
  41419. deterministicLockstep: boolean;
  41420. /**
  41421. * Maximum about of steps between frames (Default: 4)
  41422. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41423. */
  41424. lockstepMaxSteps: number;
  41425. }
  41426. /**
  41427. * The null engine class provides support for headless version of babylon.js.
  41428. * This can be used in server side scenario or for testing purposes
  41429. */
  41430. export class NullEngine extends Engine {
  41431. private _options;
  41432. /**
  41433. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41434. */
  41435. isDeterministicLockStep(): boolean;
  41436. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41437. getLockstepMaxSteps(): number;
  41438. /**
  41439. * Sets hardware scaling, used to save performance if needed
  41440. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41441. */
  41442. getHardwareScalingLevel(): number;
  41443. constructor(options?: NullEngineOptions);
  41444. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41445. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41446. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41447. getRenderWidth(useScreen?: boolean): number;
  41448. getRenderHeight(useScreen?: boolean): number;
  41449. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41450. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41451. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41452. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41453. bindSamplers(effect: Effect): void;
  41454. enableEffect(effect: Effect): void;
  41455. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41456. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41457. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41458. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41459. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41460. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41461. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41462. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41463. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41464. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41465. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41466. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41467. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41468. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41469. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41470. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41471. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41472. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41473. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41474. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41475. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41476. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41477. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41478. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41479. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41480. bindBuffers(vertexBuffers: {
  41481. [key: string]: VertexBuffer;
  41482. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41483. wipeCaches(bruteForce?: boolean): void;
  41484. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41485. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41486. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41487. /** @hidden */
  41488. _createTexture(): WebGLTexture;
  41489. /** @hidden */
  41490. _releaseTexture(texture: InternalTexture): void;
  41491. 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;
  41492. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41493. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41494. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41495. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41496. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41497. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41498. areAllEffectsReady(): boolean;
  41499. /**
  41500. * @hidden
  41501. * Get the current error code of the webGL context
  41502. * @returns the error code
  41503. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41504. */
  41505. getError(): number;
  41506. /** @hidden */
  41507. _getUnpackAlignement(): number;
  41508. /** @hidden */
  41509. _unpackFlipY(value: boolean): void;
  41510. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41511. /**
  41512. * Updates a dynamic vertex buffer.
  41513. * @param vertexBuffer the vertex buffer to update
  41514. * @param data the data used to update the vertex buffer
  41515. * @param byteOffset the byte offset of the data (optional)
  41516. * @param byteLength the byte length of the data (optional)
  41517. */
  41518. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41519. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41520. /** @hidden */
  41521. _bindTexture(channel: number, texture: InternalTexture): void;
  41522. /** @hidden */
  41523. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41524. releaseEffects(): void;
  41525. displayLoadingUI(): void;
  41526. hideLoadingUI(): void;
  41527. /** @hidden */
  41528. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41529. /** @hidden */
  41530. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41531. /** @hidden */
  41532. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41533. /** @hidden */
  41534. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41535. }
  41536. }
  41537. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41538. import { Nullable, int } from "babylonjs/types";
  41539. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41540. /** @hidden */
  41541. export class _OcclusionDataStorage {
  41542. /** @hidden */
  41543. occlusionInternalRetryCounter: number;
  41544. /** @hidden */
  41545. isOcclusionQueryInProgress: boolean;
  41546. /** @hidden */
  41547. isOccluded: boolean;
  41548. /** @hidden */
  41549. occlusionRetryCount: number;
  41550. /** @hidden */
  41551. occlusionType: number;
  41552. /** @hidden */
  41553. occlusionQueryAlgorithmType: number;
  41554. }
  41555. module "babylonjs/Engines/engine" {
  41556. interface Engine {
  41557. /**
  41558. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41559. * @return the new query
  41560. */
  41561. createQuery(): WebGLQuery;
  41562. /**
  41563. * Delete and release a webGL query
  41564. * @param query defines the query to delete
  41565. * @return the current engine
  41566. */
  41567. deleteQuery(query: WebGLQuery): Engine;
  41568. /**
  41569. * Check if a given query has resolved and got its value
  41570. * @param query defines the query to check
  41571. * @returns true if the query got its value
  41572. */
  41573. isQueryResultAvailable(query: WebGLQuery): boolean;
  41574. /**
  41575. * Gets the value of a given query
  41576. * @param query defines the query to check
  41577. * @returns the value of the query
  41578. */
  41579. getQueryResult(query: WebGLQuery): number;
  41580. /**
  41581. * Initiates an occlusion query
  41582. * @param algorithmType defines the algorithm to use
  41583. * @param query defines the query to use
  41584. * @returns the current engine
  41585. * @see http://doc.babylonjs.com/features/occlusionquery
  41586. */
  41587. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41588. /**
  41589. * Ends an occlusion query
  41590. * @see http://doc.babylonjs.com/features/occlusionquery
  41591. * @param algorithmType defines the algorithm to use
  41592. * @returns the current engine
  41593. */
  41594. endOcclusionQuery(algorithmType: number): Engine;
  41595. /**
  41596. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41597. * Please note that only one query can be issued at a time
  41598. * @returns a time token used to track the time span
  41599. */
  41600. startTimeQuery(): Nullable<_TimeToken>;
  41601. /**
  41602. * Ends a time query
  41603. * @param token defines the token used to measure the time span
  41604. * @returns the time spent (in ns)
  41605. */
  41606. endTimeQuery(token: _TimeToken): int;
  41607. /** @hidden */
  41608. _currentNonTimestampToken: Nullable<_TimeToken>;
  41609. /** @hidden */
  41610. _createTimeQuery(): WebGLQuery;
  41611. /** @hidden */
  41612. _deleteTimeQuery(query: WebGLQuery): void;
  41613. /** @hidden */
  41614. _getGlAlgorithmType(algorithmType: number): number;
  41615. /** @hidden */
  41616. _getTimeQueryResult(query: WebGLQuery): any;
  41617. /** @hidden */
  41618. _getTimeQueryAvailability(query: WebGLQuery): any;
  41619. }
  41620. }
  41621. module "babylonjs/Meshes/abstractMesh" {
  41622. interface AbstractMesh {
  41623. /**
  41624. * Backing filed
  41625. * @hidden
  41626. */
  41627. __occlusionDataStorage: _OcclusionDataStorage;
  41628. /**
  41629. * Access property
  41630. * @hidden
  41631. */
  41632. _occlusionDataStorage: _OcclusionDataStorage;
  41633. /**
  41634. * 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.
  41635. * The default value is -1 which means don't break the query and wait till the result
  41636. * @see http://doc.babylonjs.com/features/occlusionquery
  41637. */
  41638. occlusionRetryCount: number;
  41639. /**
  41640. * 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:
  41641. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41642. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41643. * * 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.
  41644. * @see http://doc.babylonjs.com/features/occlusionquery
  41645. */
  41646. occlusionType: number;
  41647. /**
  41648. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41649. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41650. * * 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.
  41651. * @see http://doc.babylonjs.com/features/occlusionquery
  41652. */
  41653. occlusionQueryAlgorithmType: number;
  41654. /**
  41655. * 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
  41656. * @see http://doc.babylonjs.com/features/occlusionquery
  41657. */
  41658. isOccluded: boolean;
  41659. /**
  41660. * Flag to check the progress status of the query
  41661. * @see http://doc.babylonjs.com/features/occlusionquery
  41662. */
  41663. isOcclusionQueryInProgress: boolean;
  41664. }
  41665. }
  41666. }
  41667. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41668. import { Nullable } from "babylonjs/types";
  41669. /** @hidden */
  41670. export var _forceTransformFeedbackToBundle: boolean;
  41671. module "babylonjs/Engines/engine" {
  41672. interface Engine {
  41673. /**
  41674. * Creates a webGL transform feedback object
  41675. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41676. * @returns the webGL transform feedback object
  41677. */
  41678. createTransformFeedback(): WebGLTransformFeedback;
  41679. /**
  41680. * Delete a webGL transform feedback object
  41681. * @param value defines the webGL transform feedback object to delete
  41682. */
  41683. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41684. /**
  41685. * Bind a webGL transform feedback object to the webgl context
  41686. * @param value defines the webGL transform feedback object to bind
  41687. */
  41688. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41689. /**
  41690. * Begins a transform feedback operation
  41691. * @param usePoints defines if points or triangles must be used
  41692. */
  41693. beginTransformFeedback(usePoints: boolean): void;
  41694. /**
  41695. * Ends a transform feedback operation
  41696. */
  41697. endTransformFeedback(): void;
  41698. /**
  41699. * Specify the varyings to use with transform feedback
  41700. * @param program defines the associated webGL program
  41701. * @param value defines the list of strings representing the varying names
  41702. */
  41703. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41704. /**
  41705. * Bind a webGL buffer for a transform feedback operation
  41706. * @param value defines the webGL buffer to bind
  41707. */
  41708. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41709. }
  41710. }
  41711. }
  41712. declare module "babylonjs/Engines/Extensions/index" {
  41713. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41714. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41715. }
  41716. declare module "babylonjs/Engines/index" {
  41717. export * from "babylonjs/Engines/constants";
  41718. export * from "babylonjs/Engines/engine";
  41719. export * from "babylonjs/Engines/engineStore";
  41720. export * from "babylonjs/Engines/nullEngine";
  41721. export * from "babylonjs/Engines/Extensions/index";
  41722. }
  41723. declare module "babylonjs/Events/clipboardEvents" {
  41724. /**
  41725. * Gather the list of clipboard event types as constants.
  41726. */
  41727. export class ClipboardEventTypes {
  41728. /**
  41729. * The clipboard event is fired when a copy command is active (pressed).
  41730. */
  41731. static readonly COPY: number;
  41732. /**
  41733. * The clipboard event is fired when a cut command is active (pressed).
  41734. */
  41735. static readonly CUT: number;
  41736. /**
  41737. * The clipboard event is fired when a paste command is active (pressed).
  41738. */
  41739. static readonly PASTE: number;
  41740. }
  41741. /**
  41742. * This class is used to store clipboard related info for the onClipboardObservable event.
  41743. */
  41744. export class ClipboardInfo {
  41745. /**
  41746. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41747. */
  41748. type: number;
  41749. /**
  41750. * Defines the related dom event
  41751. */
  41752. event: ClipboardEvent;
  41753. /**
  41754. *Creates an instance of ClipboardInfo.
  41755. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41756. * @param event Defines the related dom event
  41757. */
  41758. constructor(
  41759. /**
  41760. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41761. */
  41762. type: number,
  41763. /**
  41764. * Defines the related dom event
  41765. */
  41766. event: ClipboardEvent);
  41767. /**
  41768. * Get the clipboard event's type from the keycode.
  41769. * @param keyCode Defines the keyCode for the current keyboard event.
  41770. * @return {number}
  41771. */
  41772. static GetTypeFromCharacter(keyCode: number): number;
  41773. }
  41774. }
  41775. declare module "babylonjs/Events/index" {
  41776. export * from "babylonjs/Events/keyboardEvents";
  41777. export * from "babylonjs/Events/pointerEvents";
  41778. export * from "babylonjs/Events/clipboardEvents";
  41779. }
  41780. declare module "babylonjs/Loading/sceneLoader" {
  41781. import { Observable } from "babylonjs/Misc/observable";
  41782. import { Nullable } from "babylonjs/types";
  41783. import { Scene } from "babylonjs/scene";
  41784. import { Engine } from "babylonjs/Engines/engine";
  41785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41786. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41787. import { AssetContainer } from "babylonjs/assetContainer";
  41788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41789. import { Skeleton } from "babylonjs/Bones/skeleton";
  41790. /**
  41791. * Class used to represent data loading progression
  41792. */
  41793. export class SceneLoaderProgressEvent {
  41794. /** defines if data length to load can be evaluated */
  41795. readonly lengthComputable: boolean;
  41796. /** defines the loaded data length */
  41797. readonly loaded: number;
  41798. /** defines the data length to load */
  41799. readonly total: number;
  41800. /**
  41801. * Create a new progress event
  41802. * @param lengthComputable defines if data length to load can be evaluated
  41803. * @param loaded defines the loaded data length
  41804. * @param total defines the data length to load
  41805. */
  41806. constructor(
  41807. /** defines if data length to load can be evaluated */
  41808. lengthComputable: boolean,
  41809. /** defines the loaded data length */
  41810. loaded: number,
  41811. /** defines the data length to load */
  41812. total: number);
  41813. /**
  41814. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41815. * @param event defines the source event
  41816. * @returns a new SceneLoaderProgressEvent
  41817. */
  41818. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41819. }
  41820. /**
  41821. * Interface used by SceneLoader plugins to define supported file extensions
  41822. */
  41823. export interface ISceneLoaderPluginExtensions {
  41824. /**
  41825. * Defines the list of supported extensions
  41826. */
  41827. [extension: string]: {
  41828. isBinary: boolean;
  41829. };
  41830. }
  41831. /**
  41832. * Interface used by SceneLoader plugin factory
  41833. */
  41834. export interface ISceneLoaderPluginFactory {
  41835. /**
  41836. * Defines the name of the factory
  41837. */
  41838. name: string;
  41839. /**
  41840. * Function called to create a new plugin
  41841. * @return the new plugin
  41842. */
  41843. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41844. /**
  41845. * Boolean indicating if the plugin can direct load specific data
  41846. */
  41847. canDirectLoad?: (data: string) => boolean;
  41848. }
  41849. /**
  41850. * Interface used to define a SceneLoader plugin
  41851. */
  41852. export interface ISceneLoaderPlugin {
  41853. /**
  41854. * The friendly name of this plugin.
  41855. */
  41856. name: string;
  41857. /**
  41858. * The file extensions supported by this plugin.
  41859. */
  41860. extensions: string | ISceneLoaderPluginExtensions;
  41861. /**
  41862. * Import meshes into a scene.
  41863. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41864. * @param scene The scene to import into
  41865. * @param data The data to import
  41866. * @param rootUrl The root url for scene and resources
  41867. * @param meshes The meshes array to import into
  41868. * @param particleSystems The particle systems array to import into
  41869. * @param skeletons The skeletons array to import into
  41870. * @param onError The callback when import fails
  41871. * @returns True if successful or false otherwise
  41872. */
  41873. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41874. /**
  41875. * Load into a scene.
  41876. * @param scene The scene to load into
  41877. * @param data The data to import
  41878. * @param rootUrl The root url for scene and resources
  41879. * @param onError The callback when import fails
  41880. * @returns true if successful or false otherwise
  41881. */
  41882. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41883. /**
  41884. * The callback that returns true if the data can be directly loaded.
  41885. */
  41886. canDirectLoad?: (data: string) => boolean;
  41887. /**
  41888. * The callback that allows custom handling of the root url based on the response url.
  41889. */
  41890. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41891. /**
  41892. * Load into an asset container.
  41893. * @param scene The scene to load into
  41894. * @param data The data to import
  41895. * @param rootUrl The root url for scene and resources
  41896. * @param onError The callback when import fails
  41897. * @returns The loaded asset container
  41898. */
  41899. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41900. }
  41901. /**
  41902. * Interface used to define an async SceneLoader plugin
  41903. */
  41904. export interface ISceneLoaderPluginAsync {
  41905. /**
  41906. * The friendly name of this plugin.
  41907. */
  41908. name: string;
  41909. /**
  41910. * The file extensions supported by this plugin.
  41911. */
  41912. extensions: string | ISceneLoaderPluginExtensions;
  41913. /**
  41914. * Import meshes into a scene.
  41915. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41916. * @param scene The scene to import into
  41917. * @param data The data to import
  41918. * @param rootUrl The root url for scene and resources
  41919. * @param onProgress The callback when the load progresses
  41920. * @param fileName Defines the name of the file to load
  41921. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41922. */
  41923. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41924. meshes: AbstractMesh[];
  41925. particleSystems: IParticleSystem[];
  41926. skeletons: Skeleton[];
  41927. animationGroups: AnimationGroup[];
  41928. }>;
  41929. /**
  41930. * Load into a scene.
  41931. * @param scene The scene to load into
  41932. * @param data The data to import
  41933. * @param rootUrl The root url for scene and resources
  41934. * @param onProgress The callback when the load progresses
  41935. * @param fileName Defines the name of the file to load
  41936. * @returns Nothing
  41937. */
  41938. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41939. /**
  41940. * The callback that returns true if the data can be directly loaded.
  41941. */
  41942. canDirectLoad?: (data: string) => boolean;
  41943. /**
  41944. * The callback that allows custom handling of the root url based on the response url.
  41945. */
  41946. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41947. /**
  41948. * Load into an asset container.
  41949. * @param scene The scene to load into
  41950. * @param data The data to import
  41951. * @param rootUrl The root url for scene and resources
  41952. * @param onProgress The callback when the load progresses
  41953. * @param fileName Defines the name of the file to load
  41954. * @returns The loaded asset container
  41955. */
  41956. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41957. }
  41958. /**
  41959. * Class used to load scene from various file formats using registered plugins
  41960. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41961. */
  41962. export class SceneLoader {
  41963. /**
  41964. * No logging while loading
  41965. */
  41966. static readonly NO_LOGGING: number;
  41967. /**
  41968. * Minimal logging while loading
  41969. */
  41970. static readonly MINIMAL_LOGGING: number;
  41971. /**
  41972. * Summary logging while loading
  41973. */
  41974. static readonly SUMMARY_LOGGING: number;
  41975. /**
  41976. * Detailled logging while loading
  41977. */
  41978. static readonly DETAILED_LOGGING: number;
  41979. /**
  41980. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41981. */
  41982. static ForceFullSceneLoadingForIncremental: boolean;
  41983. /**
  41984. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41985. */
  41986. static ShowLoadingScreen: boolean;
  41987. /**
  41988. * Defines the current logging level (while loading the scene)
  41989. * @ignorenaming
  41990. */
  41991. static loggingLevel: number;
  41992. /**
  41993. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41994. */
  41995. static CleanBoneMatrixWeights: boolean;
  41996. /**
  41997. * Event raised when a plugin is used to load a scene
  41998. */
  41999. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42000. private static _registeredPlugins;
  42001. private static _getDefaultPlugin;
  42002. private static _getPluginForExtension;
  42003. private static _getPluginForDirectLoad;
  42004. private static _getPluginForFilename;
  42005. private static _getDirectLoad;
  42006. private static _loadData;
  42007. private static _getFileInfo;
  42008. /**
  42009. * Gets a plugin that can load the given extension
  42010. * @param extension defines the extension to load
  42011. * @returns a plugin or null if none works
  42012. */
  42013. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42014. /**
  42015. * Gets a boolean indicating that the given extension can be loaded
  42016. * @param extension defines the extension to load
  42017. * @returns true if the extension is supported
  42018. */
  42019. static IsPluginForExtensionAvailable(extension: string): boolean;
  42020. /**
  42021. * Adds a new plugin to the list of registered plugins
  42022. * @param plugin defines the plugin to add
  42023. */
  42024. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42025. /**
  42026. * Import meshes into a scene
  42027. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42028. * @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)
  42029. * @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)
  42030. * @param scene the instance of BABYLON.Scene to append to
  42031. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42032. * @param onProgress a callback with a progress event for each file being loaded
  42033. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42034. * @param pluginExtension the extension used to determine the plugin
  42035. * @returns The loaded plugin
  42036. */
  42037. 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>;
  42038. /**
  42039. * Import meshes into a scene
  42040. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42041. * @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)
  42042. * @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)
  42043. * @param scene the instance of BABYLON.Scene to append to
  42044. * @param onProgress a callback with a progress event for each file being loaded
  42045. * @param pluginExtension the extension used to determine the plugin
  42046. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42047. */
  42048. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42049. meshes: AbstractMesh[];
  42050. particleSystems: IParticleSystem[];
  42051. skeletons: Skeleton[];
  42052. animationGroups: AnimationGroup[];
  42053. }>;
  42054. /**
  42055. * Load a scene
  42056. * @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)
  42057. * @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)
  42058. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42059. * @param onSuccess a callback with the scene when import succeeds
  42060. * @param onProgress a callback with a progress event for each file being loaded
  42061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42062. * @param pluginExtension the extension used to determine the plugin
  42063. * @returns The loaded plugin
  42064. */
  42065. 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>;
  42066. /**
  42067. * Load a scene
  42068. * @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)
  42069. * @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)
  42070. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42071. * @param onProgress a callback with a progress event for each file being loaded
  42072. * @param pluginExtension the extension used to determine the plugin
  42073. * @returns The loaded scene
  42074. */
  42075. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42076. /**
  42077. * Append a scene
  42078. * @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)
  42079. * @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)
  42080. * @param scene is the instance of BABYLON.Scene to append to
  42081. * @param onSuccess a callback with the scene when import succeeds
  42082. * @param onProgress a callback with a progress event for each file being loaded
  42083. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42084. * @param pluginExtension the extension used to determine the plugin
  42085. * @returns The loaded plugin
  42086. */
  42087. 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>;
  42088. /**
  42089. * Append a scene
  42090. * @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)
  42091. * @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)
  42092. * @param scene is the instance of BABYLON.Scene to append to
  42093. * @param onProgress a callback with a progress event for each file being loaded
  42094. * @param pluginExtension the extension used to determine the plugin
  42095. * @returns The given scene
  42096. */
  42097. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42098. /**
  42099. * Load a scene into an asset container
  42100. * @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)
  42101. * @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)
  42102. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42103. * @param onSuccess a callback with the scene when import succeeds
  42104. * @param onProgress a callback with a progress event for each file being loaded
  42105. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42106. * @param pluginExtension the extension used to determine the plugin
  42107. * @returns The loaded plugin
  42108. */
  42109. 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>;
  42110. /**
  42111. * Load a scene into an asset container
  42112. * @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)
  42113. * @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)
  42114. * @param scene is the instance of Scene to append to
  42115. * @param onProgress a callback with a progress event for each file being loaded
  42116. * @param pluginExtension the extension used to determine the plugin
  42117. * @returns The loaded asset container
  42118. */
  42119. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42120. }
  42121. }
  42122. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42123. import { Scene } from "babylonjs/scene";
  42124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42125. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42126. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42127. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42128. /**
  42129. * Google Daydream controller
  42130. */
  42131. export class DaydreamController extends WebVRController {
  42132. /**
  42133. * Base Url for the controller model.
  42134. */
  42135. static MODEL_BASE_URL: string;
  42136. /**
  42137. * File name for the controller model.
  42138. */
  42139. static MODEL_FILENAME: string;
  42140. /**
  42141. * Gamepad Id prefix used to identify Daydream Controller.
  42142. */
  42143. static readonly GAMEPAD_ID_PREFIX: string;
  42144. /**
  42145. * Creates a new DaydreamController from a gamepad
  42146. * @param vrGamepad the gamepad that the controller should be created from
  42147. */
  42148. constructor(vrGamepad: any);
  42149. /**
  42150. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42151. * @param scene scene in which to add meshes
  42152. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42153. */
  42154. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42155. /**
  42156. * Called once for each button that changed state since the last frame
  42157. * @param buttonIdx Which button index changed
  42158. * @param state New state of the button
  42159. * @param changes Which properties on the state changed since last frame
  42160. */
  42161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42162. }
  42163. }
  42164. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42165. import { Scene } from "babylonjs/scene";
  42166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42167. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42168. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42169. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42170. /**
  42171. * Gear VR Controller
  42172. */
  42173. export class GearVRController extends WebVRController {
  42174. /**
  42175. * Base Url for the controller model.
  42176. */
  42177. static MODEL_BASE_URL: string;
  42178. /**
  42179. * File name for the controller model.
  42180. */
  42181. static MODEL_FILENAME: string;
  42182. /**
  42183. * Gamepad Id prefix used to identify this controller.
  42184. */
  42185. static readonly GAMEPAD_ID_PREFIX: string;
  42186. private readonly _buttonIndexToObservableNameMap;
  42187. /**
  42188. * Creates a new GearVRController from a gamepad
  42189. * @param vrGamepad the gamepad that the controller should be created from
  42190. */
  42191. constructor(vrGamepad: any);
  42192. /**
  42193. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42194. * @param scene scene in which to add meshes
  42195. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42196. */
  42197. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42198. /**
  42199. * Called once for each button that changed state since the last frame
  42200. * @param buttonIdx Which button index changed
  42201. * @param state New state of the button
  42202. * @param changes Which properties on the state changed since last frame
  42203. */
  42204. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42205. }
  42206. }
  42207. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42208. import { Scene } from "babylonjs/scene";
  42209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42210. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42211. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42212. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42213. /**
  42214. * Generic Controller
  42215. */
  42216. export class GenericController extends WebVRController {
  42217. /**
  42218. * Base Url for the controller model.
  42219. */
  42220. static readonly MODEL_BASE_URL: string;
  42221. /**
  42222. * File name for the controller model.
  42223. */
  42224. static readonly MODEL_FILENAME: string;
  42225. /**
  42226. * Creates a new GenericController from a gamepad
  42227. * @param vrGamepad the gamepad that the controller should be created from
  42228. */
  42229. constructor(vrGamepad: any);
  42230. /**
  42231. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42232. * @param scene scene in which to add meshes
  42233. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42234. */
  42235. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42236. /**
  42237. * Called once for each button that changed state since the last frame
  42238. * @param buttonIdx Which button index changed
  42239. * @param state New state of the button
  42240. * @param changes Which properties on the state changed since last frame
  42241. */
  42242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42243. }
  42244. }
  42245. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42246. import { Observable } from "babylonjs/Misc/observable";
  42247. import { Scene } from "babylonjs/scene";
  42248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42249. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42250. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42251. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42252. /**
  42253. * Oculus Touch Controller
  42254. */
  42255. export class OculusTouchController extends WebVRController {
  42256. /**
  42257. * Base Url for the controller model.
  42258. */
  42259. static MODEL_BASE_URL: string;
  42260. /**
  42261. * File name for the left controller model.
  42262. */
  42263. static MODEL_LEFT_FILENAME: string;
  42264. /**
  42265. * File name for the right controller model.
  42266. */
  42267. static MODEL_RIGHT_FILENAME: string;
  42268. /**
  42269. * Fired when the secondary trigger on this controller is modified
  42270. */
  42271. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42272. /**
  42273. * Fired when the thumb rest on this controller is modified
  42274. */
  42275. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42276. /**
  42277. * Creates a new OculusTouchController from a gamepad
  42278. * @param vrGamepad the gamepad that the controller should be created from
  42279. */
  42280. constructor(vrGamepad: any);
  42281. /**
  42282. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42283. * @param scene scene in which to add meshes
  42284. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42285. */
  42286. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42287. /**
  42288. * Fired when the A button on this controller is modified
  42289. */
  42290. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42291. /**
  42292. * Fired when the B button on this controller is modified
  42293. */
  42294. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42295. /**
  42296. * Fired when the X button on this controller is modified
  42297. */
  42298. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42299. /**
  42300. * Fired when the Y button on this controller is modified
  42301. */
  42302. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42303. /**
  42304. * Called once for each button that changed state since the last frame
  42305. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42306. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42307. * 2) secondary trigger (same)
  42308. * 3) A (right) X (left), touch, pressed = value
  42309. * 4) B / Y
  42310. * 5) thumb rest
  42311. * @param buttonIdx Which button index changed
  42312. * @param state New state of the button
  42313. * @param changes Which properties on the state changed since last frame
  42314. */
  42315. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42316. }
  42317. }
  42318. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42319. import { Scene } from "babylonjs/scene";
  42320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42321. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42322. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42323. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42324. import { Observable } from "babylonjs/Misc/observable";
  42325. /**
  42326. * Vive Controller
  42327. */
  42328. export class ViveController extends WebVRController {
  42329. /**
  42330. * Base Url for the controller model.
  42331. */
  42332. static MODEL_BASE_URL: string;
  42333. /**
  42334. * File name for the controller model.
  42335. */
  42336. static MODEL_FILENAME: string;
  42337. /**
  42338. * Creates a new ViveController from a gamepad
  42339. * @param vrGamepad the gamepad that the controller should be created from
  42340. */
  42341. constructor(vrGamepad: any);
  42342. /**
  42343. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42344. * @param scene scene in which to add meshes
  42345. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42346. */
  42347. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42348. /**
  42349. * Fired when the left button on this controller is modified
  42350. */
  42351. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42352. /**
  42353. * Fired when the right button on this controller is modified
  42354. */
  42355. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42356. /**
  42357. * Fired when the menu button on this controller is modified
  42358. */
  42359. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42360. /**
  42361. * Called once for each button that changed state since the last frame
  42362. * Vive mapping:
  42363. * 0: touchpad
  42364. * 1: trigger
  42365. * 2: left AND right buttons
  42366. * 3: menu button
  42367. * @param buttonIdx Which button index changed
  42368. * @param state New state of the button
  42369. * @param changes Which properties on the state changed since last frame
  42370. */
  42371. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42372. }
  42373. }
  42374. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42375. import { Observable } from "babylonjs/Misc/observable";
  42376. import { Scene } from "babylonjs/scene";
  42377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42378. import { Ray } from "babylonjs/Culling/ray";
  42379. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42380. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42381. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42382. /**
  42383. * Defines the WindowsMotionController object that the state of the windows motion controller
  42384. */
  42385. export class WindowsMotionController extends WebVRController {
  42386. /**
  42387. * The base url used to load the left and right controller models
  42388. */
  42389. static MODEL_BASE_URL: string;
  42390. /**
  42391. * The name of the left controller model file
  42392. */
  42393. static MODEL_LEFT_FILENAME: string;
  42394. /**
  42395. * The name of the right controller model file
  42396. */
  42397. static MODEL_RIGHT_FILENAME: string;
  42398. /**
  42399. * The controller name prefix for this controller type
  42400. */
  42401. static readonly GAMEPAD_ID_PREFIX: string;
  42402. /**
  42403. * The controller id pattern for this controller type
  42404. */
  42405. private static readonly GAMEPAD_ID_PATTERN;
  42406. private _loadedMeshInfo;
  42407. private readonly _mapping;
  42408. /**
  42409. * Fired when the trackpad on this controller is clicked
  42410. */
  42411. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42412. /**
  42413. * Fired when the trackpad on this controller is modified
  42414. */
  42415. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42416. /**
  42417. * The current x and y values of this controller's trackpad
  42418. */
  42419. trackpad: StickValues;
  42420. /**
  42421. * Creates a new WindowsMotionController from a gamepad
  42422. * @param vrGamepad the gamepad that the controller should be created from
  42423. */
  42424. constructor(vrGamepad: any);
  42425. /**
  42426. * Fired when the trigger on this controller is modified
  42427. */
  42428. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42429. /**
  42430. * Fired when the menu button on this controller is modified
  42431. */
  42432. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42433. /**
  42434. * Fired when the grip button on this controller is modified
  42435. */
  42436. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42437. /**
  42438. * Fired when the thumbstick button on this controller is modified
  42439. */
  42440. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42441. /**
  42442. * Fired when the touchpad button on this controller is modified
  42443. */
  42444. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42445. /**
  42446. * Fired when the touchpad values on this controller are modified
  42447. */
  42448. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42449. private _updateTrackpad;
  42450. /**
  42451. * Called once per frame by the engine.
  42452. */
  42453. update(): void;
  42454. /**
  42455. * Called once for each button that changed state since the last frame
  42456. * @param buttonIdx Which button index changed
  42457. * @param state New state of the button
  42458. * @param changes Which properties on the state changed since last frame
  42459. */
  42460. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42461. /**
  42462. * Moves the buttons on the controller mesh based on their current state
  42463. * @param buttonName the name of the button to move
  42464. * @param buttonValue the value of the button which determines the buttons new position
  42465. */
  42466. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42467. /**
  42468. * Moves the axis on the controller mesh based on its current state
  42469. * @param axis the index of the axis
  42470. * @param axisValue the value of the axis which determines the meshes new position
  42471. * @hidden
  42472. */
  42473. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42474. /**
  42475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42476. * @param scene scene in which to add meshes
  42477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42478. */
  42479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42480. /**
  42481. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42482. * can be transformed by button presses and axes values, based on this._mapping.
  42483. *
  42484. * @param scene scene in which the meshes exist
  42485. * @param meshes list of meshes that make up the controller model to process
  42486. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42487. */
  42488. private processModel;
  42489. private createMeshInfo;
  42490. /**
  42491. * Gets the ray of the controller in the direction the controller is pointing
  42492. * @param length the length the resulting ray should be
  42493. * @returns a ray in the direction the controller is pointing
  42494. */
  42495. getForwardRay(length?: number): Ray;
  42496. /**
  42497. * Disposes of the controller
  42498. */
  42499. dispose(): void;
  42500. }
  42501. }
  42502. declare module "babylonjs/Gamepads/Controllers/index" {
  42503. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42504. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42505. export * from "babylonjs/Gamepads/Controllers/genericController";
  42506. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42507. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42508. export * from "babylonjs/Gamepads/Controllers/viveController";
  42509. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42510. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42511. }
  42512. declare module "babylonjs/Gamepads/index" {
  42513. export * from "babylonjs/Gamepads/Controllers/index";
  42514. export * from "babylonjs/Gamepads/gamepad";
  42515. export * from "babylonjs/Gamepads/gamepadManager";
  42516. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42517. export * from "babylonjs/Gamepads/xboxGamepad";
  42518. }
  42519. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42520. import { Observable } from "babylonjs/Misc/observable";
  42521. import { Nullable } from "babylonjs/types";
  42522. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42524. import { Mesh } from "babylonjs/Meshes/mesh";
  42525. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42526. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42527. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42528. /**
  42529. * Single axis scale gizmo
  42530. */
  42531. export class AxisScaleGizmo extends Gizmo {
  42532. private _coloredMaterial;
  42533. /**
  42534. * Drag behavior responsible for the gizmos dragging interactions
  42535. */
  42536. dragBehavior: PointerDragBehavior;
  42537. private _pointerObserver;
  42538. /**
  42539. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42540. */
  42541. snapDistance: number;
  42542. /**
  42543. * Event that fires each time the gizmo snaps to a new location.
  42544. * * snapDistance is the the change in distance
  42545. */
  42546. onSnapObservable: Observable<{
  42547. snapDistance: number;
  42548. }>;
  42549. /**
  42550. * If the scaling operation should be done on all axis (default: false)
  42551. */
  42552. uniformScaling: boolean;
  42553. /**
  42554. * Creates an AxisScaleGizmo
  42555. * @param gizmoLayer The utility layer the gizmo will be added to
  42556. * @param dragAxis The axis which the gizmo will be able to scale on
  42557. * @param color The color of the gizmo
  42558. */
  42559. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42560. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42561. /**
  42562. * Disposes of the gizmo
  42563. */
  42564. dispose(): void;
  42565. /**
  42566. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42567. * @param mesh The mesh to replace the default mesh of the gizmo
  42568. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42569. */
  42570. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42571. }
  42572. }
  42573. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42574. import { Observable } from "babylonjs/Misc/observable";
  42575. import { Nullable } from "babylonjs/types";
  42576. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42578. import { Mesh } from "babylonjs/Meshes/mesh";
  42579. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42580. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42581. import "babylonjs/Meshes/Builders/boxBuilder";
  42582. /**
  42583. * Bounding box gizmo
  42584. */
  42585. export class BoundingBoxGizmo extends Gizmo {
  42586. private _lineBoundingBox;
  42587. private _rotateSpheresParent;
  42588. private _scaleBoxesParent;
  42589. private _boundingDimensions;
  42590. private _renderObserver;
  42591. private _pointerObserver;
  42592. private _scaleDragSpeed;
  42593. private _tmpQuaternion;
  42594. private _tmpVector;
  42595. private _tmpRotationMatrix;
  42596. /**
  42597. * 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)
  42598. */
  42599. ignoreChildren: boolean;
  42600. /**
  42601. * 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)
  42602. */
  42603. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42604. /**
  42605. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42606. */
  42607. rotationSphereSize: number;
  42608. /**
  42609. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42610. */
  42611. scaleBoxSize: number;
  42612. /**
  42613. * 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)
  42614. */
  42615. fixedDragMeshScreenSize: boolean;
  42616. /**
  42617. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42618. */
  42619. fixedDragMeshScreenSizeDistanceFactor: number;
  42620. /**
  42621. * Fired when a rotation sphere or scale box is dragged
  42622. */
  42623. onDragStartObservable: Observable<{}>;
  42624. /**
  42625. * Fired when a scale box is dragged
  42626. */
  42627. onScaleBoxDragObservable: Observable<{}>;
  42628. /**
  42629. * Fired when a scale box drag is ended
  42630. */
  42631. onScaleBoxDragEndObservable: Observable<{}>;
  42632. /**
  42633. * Fired when a rotation sphere is dragged
  42634. */
  42635. onRotationSphereDragObservable: Observable<{}>;
  42636. /**
  42637. * Fired when a rotation sphere drag is ended
  42638. */
  42639. onRotationSphereDragEndObservable: Observable<{}>;
  42640. /**
  42641. * 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)
  42642. */
  42643. scalePivot: Nullable<Vector3>;
  42644. private _anchorMesh;
  42645. private _existingMeshScale;
  42646. private _dragMesh;
  42647. private pointerDragBehavior;
  42648. /**
  42649. * Creates an BoundingBoxGizmo
  42650. * @param gizmoLayer The utility layer the gizmo will be added to
  42651. * @param color The color of the gizmo
  42652. */
  42653. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42654. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42655. private _selectNode;
  42656. /**
  42657. * Updates the bounding box information for the Gizmo
  42658. */
  42659. updateBoundingBox(): void;
  42660. private _updateRotationSpheres;
  42661. private _updateScaleBoxes;
  42662. /**
  42663. * Enables rotation on the specified axis and disables rotation on the others
  42664. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42665. */
  42666. setEnabledRotationAxis(axis: string): void;
  42667. /**
  42668. * Enables/disables scaling
  42669. * @param enable if scaling should be enabled
  42670. */
  42671. setEnabledScaling(enable: boolean): void;
  42672. private _updateDummy;
  42673. /**
  42674. * Enables a pointer drag behavior on the bounding box of the gizmo
  42675. */
  42676. enableDragBehavior(): void;
  42677. /**
  42678. * Disposes of the gizmo
  42679. */
  42680. dispose(): void;
  42681. /**
  42682. * 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)
  42683. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42684. * @returns the bounding box mesh with the passed in mesh as a child
  42685. */
  42686. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42687. /**
  42688. * CustomMeshes are not supported by this gizmo
  42689. * @param mesh The mesh to replace the default mesh of the gizmo
  42690. */
  42691. setCustomMesh(mesh: Mesh): void;
  42692. }
  42693. }
  42694. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42695. import { Observable } from "babylonjs/Misc/observable";
  42696. import { Nullable } from "babylonjs/types";
  42697. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42699. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42700. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42701. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42702. import "babylonjs/Meshes/Builders/linesBuilder";
  42703. /**
  42704. * Single plane rotation gizmo
  42705. */
  42706. export class PlaneRotationGizmo extends Gizmo {
  42707. /**
  42708. * Drag behavior responsible for the gizmos dragging interactions
  42709. */
  42710. dragBehavior: PointerDragBehavior;
  42711. private _pointerObserver;
  42712. /**
  42713. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42714. */
  42715. snapDistance: number;
  42716. /**
  42717. * Event that fires each time the gizmo snaps to a new location.
  42718. * * snapDistance is the the change in distance
  42719. */
  42720. onSnapObservable: Observable<{
  42721. snapDistance: number;
  42722. }>;
  42723. /**
  42724. * Creates a PlaneRotationGizmo
  42725. * @param gizmoLayer The utility layer the gizmo will be added to
  42726. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42727. * @param color The color of the gizmo
  42728. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42729. */
  42730. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42731. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42732. /**
  42733. * Disposes of the gizmo
  42734. */
  42735. dispose(): void;
  42736. }
  42737. }
  42738. declare module "babylonjs/Gizmos/rotationGizmo" {
  42739. import { Observable } from "babylonjs/Misc/observable";
  42740. import { Nullable } from "babylonjs/types";
  42741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42742. import { Mesh } from "babylonjs/Meshes/mesh";
  42743. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42744. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42745. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42746. /**
  42747. * Gizmo that enables rotating a mesh along 3 axis
  42748. */
  42749. export class RotationGizmo extends Gizmo {
  42750. /**
  42751. * Internal gizmo used for interactions on the x axis
  42752. */
  42753. xGizmo: PlaneRotationGizmo;
  42754. /**
  42755. * Internal gizmo used for interactions on the y axis
  42756. */
  42757. yGizmo: PlaneRotationGizmo;
  42758. /**
  42759. * Internal gizmo used for interactions on the z axis
  42760. */
  42761. zGizmo: PlaneRotationGizmo;
  42762. /** Fires an event when any of it's sub gizmos are dragged */
  42763. onDragStartObservable: Observable<{}>;
  42764. /** Fires an event when any of it's sub gizmos are released from dragging */
  42765. onDragEndObservable: Observable<{}>;
  42766. attachedMesh: Nullable<AbstractMesh>;
  42767. /**
  42768. * Creates a RotationGizmo
  42769. * @param gizmoLayer The utility layer the gizmo will be added to
  42770. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42771. */
  42772. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42773. updateGizmoRotationToMatchAttachedMesh: boolean;
  42774. /**
  42775. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42776. */
  42777. snapDistance: number;
  42778. /**
  42779. * Ratio for the scale of the gizmo (Default: 1)
  42780. */
  42781. scaleRatio: number;
  42782. /**
  42783. * Disposes of the gizmo
  42784. */
  42785. dispose(): void;
  42786. /**
  42787. * CustomMeshes are not supported by this gizmo
  42788. * @param mesh The mesh to replace the default mesh of the gizmo
  42789. */
  42790. setCustomMesh(mesh: Mesh): void;
  42791. }
  42792. }
  42793. declare module "babylonjs/Gizmos/positionGizmo" {
  42794. import { Observable } from "babylonjs/Misc/observable";
  42795. import { Nullable } from "babylonjs/types";
  42796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42797. import { Mesh } from "babylonjs/Meshes/mesh";
  42798. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42799. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42800. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42801. /**
  42802. * Gizmo that enables dragging a mesh along 3 axis
  42803. */
  42804. export class PositionGizmo extends Gizmo {
  42805. /**
  42806. * Internal gizmo used for interactions on the x axis
  42807. */
  42808. xGizmo: AxisDragGizmo;
  42809. /**
  42810. * Internal gizmo used for interactions on the y axis
  42811. */
  42812. yGizmo: AxisDragGizmo;
  42813. /**
  42814. * Internal gizmo used for interactions on the z axis
  42815. */
  42816. zGizmo: AxisDragGizmo;
  42817. /** Fires an event when any of it's sub gizmos are dragged */
  42818. onDragStartObservable: Observable<{}>;
  42819. /** Fires an event when any of it's sub gizmos are released from dragging */
  42820. onDragEndObservable: Observable<{}>;
  42821. attachedMesh: Nullable<AbstractMesh>;
  42822. /**
  42823. * Creates a PositionGizmo
  42824. * @param gizmoLayer The utility layer the gizmo will be added to
  42825. */
  42826. constructor(gizmoLayer?: UtilityLayerRenderer);
  42827. updateGizmoRotationToMatchAttachedMesh: boolean;
  42828. /**
  42829. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42830. */
  42831. snapDistance: number;
  42832. /**
  42833. * Ratio for the scale of the gizmo (Default: 1)
  42834. */
  42835. scaleRatio: number;
  42836. /**
  42837. * Disposes of the gizmo
  42838. */
  42839. dispose(): void;
  42840. /**
  42841. * CustomMeshes are not supported by this gizmo
  42842. * @param mesh The mesh to replace the default mesh of the gizmo
  42843. */
  42844. setCustomMesh(mesh: Mesh): void;
  42845. }
  42846. }
  42847. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42848. import { Scene } from "babylonjs/scene";
  42849. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42850. import { Mesh } from "babylonjs/Meshes/mesh";
  42851. /**
  42852. * Class containing static functions to help procedurally build meshes
  42853. */
  42854. export class PolyhedronBuilder {
  42855. /**
  42856. * Creates a polyhedron mesh
  42857. * * 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
  42858. * * The parameter `size` (positive float, default 1) sets the polygon size
  42859. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42860. * * 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`
  42861. * * 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
  42862. * * 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)`)
  42863. * * 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
  42864. * * 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
  42865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42868. * @param name defines the name of the mesh
  42869. * @param options defines the options used to create the mesh
  42870. * @param scene defines the hosting scene
  42871. * @returns the polyhedron mesh
  42872. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42873. */
  42874. static CreatePolyhedron(name: string, options: {
  42875. type?: number;
  42876. size?: number;
  42877. sizeX?: number;
  42878. sizeY?: number;
  42879. sizeZ?: number;
  42880. custom?: any;
  42881. faceUV?: Vector4[];
  42882. faceColors?: Color4[];
  42883. flat?: boolean;
  42884. updatable?: boolean;
  42885. sideOrientation?: number;
  42886. frontUVs?: Vector4;
  42887. backUVs?: Vector4;
  42888. }, scene: Scene): Mesh;
  42889. }
  42890. }
  42891. declare module "babylonjs/Gizmos/scaleGizmo" {
  42892. import { Observable } from "babylonjs/Misc/observable";
  42893. import { Nullable } from "babylonjs/types";
  42894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42895. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42896. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42898. /**
  42899. * Gizmo that enables scaling a mesh along 3 axis
  42900. */
  42901. export class ScaleGizmo extends Gizmo {
  42902. /**
  42903. * Internal gizmo used for interactions on the x axis
  42904. */
  42905. xGizmo: AxisScaleGizmo;
  42906. /**
  42907. * Internal gizmo used for interactions on the y axis
  42908. */
  42909. yGizmo: AxisScaleGizmo;
  42910. /**
  42911. * Internal gizmo used for interactions on the z axis
  42912. */
  42913. zGizmo: AxisScaleGizmo;
  42914. /**
  42915. * Internal gizmo used to scale all axis equally
  42916. */
  42917. uniformScaleGizmo: AxisScaleGizmo;
  42918. /** Fires an event when any of it's sub gizmos are dragged */
  42919. onDragStartObservable: Observable<{}>;
  42920. /** Fires an event when any of it's sub gizmos are released from dragging */
  42921. onDragEndObservable: Observable<{}>;
  42922. attachedMesh: Nullable<AbstractMesh>;
  42923. /**
  42924. * Creates a ScaleGizmo
  42925. * @param gizmoLayer The utility layer the gizmo will be added to
  42926. */
  42927. constructor(gizmoLayer?: UtilityLayerRenderer);
  42928. updateGizmoRotationToMatchAttachedMesh: boolean;
  42929. /**
  42930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42931. */
  42932. snapDistance: number;
  42933. /**
  42934. * Ratio for the scale of the gizmo (Default: 1)
  42935. */
  42936. scaleRatio: number;
  42937. /**
  42938. * Disposes of the gizmo
  42939. */
  42940. dispose(): void;
  42941. }
  42942. }
  42943. declare module "babylonjs/Gizmos/gizmoManager" {
  42944. import { Observable } from "babylonjs/Misc/observable";
  42945. import { Nullable } from "babylonjs/types";
  42946. import { Scene, IDisposable } from "babylonjs/scene";
  42947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42948. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42949. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42950. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42951. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42952. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42953. /**
  42954. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42955. */
  42956. export class GizmoManager implements IDisposable {
  42957. private scene;
  42958. /**
  42959. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42960. */
  42961. gizmos: {
  42962. positionGizmo: Nullable<PositionGizmo>;
  42963. rotationGizmo: Nullable<RotationGizmo>;
  42964. scaleGizmo: Nullable<ScaleGizmo>;
  42965. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42966. };
  42967. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42968. clearGizmoOnEmptyPointerEvent: boolean;
  42969. /** Fires an event when the manager is attached to a mesh */
  42970. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42971. private _gizmosEnabled;
  42972. private _pointerObserver;
  42973. private _attachedMesh;
  42974. private _boundingBoxColor;
  42975. private _defaultUtilityLayer;
  42976. private _defaultKeepDepthUtilityLayer;
  42977. /**
  42978. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42979. */
  42980. boundingBoxDragBehavior: SixDofDragBehavior;
  42981. /**
  42982. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42983. */
  42984. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42985. /**
  42986. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42987. */
  42988. usePointerToAttachGizmos: boolean;
  42989. /**
  42990. * Instatiates a gizmo manager
  42991. * @param scene the scene to overlay the gizmos on top of
  42992. */
  42993. constructor(scene: Scene);
  42994. /**
  42995. * Attaches a set of gizmos to the specified mesh
  42996. * @param mesh The mesh the gizmo's should be attached to
  42997. */
  42998. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42999. /**
  43000. * If the position gizmo is enabled
  43001. */
  43002. positionGizmoEnabled: boolean;
  43003. /**
  43004. * If the rotation gizmo is enabled
  43005. */
  43006. rotationGizmoEnabled: boolean;
  43007. /**
  43008. * If the scale gizmo is enabled
  43009. */
  43010. scaleGizmoEnabled: boolean;
  43011. /**
  43012. * If the boundingBox gizmo is enabled
  43013. */
  43014. boundingBoxGizmoEnabled: boolean;
  43015. /**
  43016. * Disposes of the gizmo manager
  43017. */
  43018. dispose(): void;
  43019. }
  43020. }
  43021. declare module "babylonjs/Gizmos/lightGizmo" {
  43022. import { Nullable } from "babylonjs/types";
  43023. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43024. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43025. import { Light } from "babylonjs/Lights/light";
  43026. /**
  43027. * Gizmo that enables viewing a light
  43028. */
  43029. export class LightGizmo extends Gizmo {
  43030. private _box;
  43031. /**
  43032. * Creates a LightGizmo
  43033. * @param gizmoLayer The utility layer the gizmo will be added to
  43034. */
  43035. constructor(gizmoLayer?: UtilityLayerRenderer);
  43036. private _light;
  43037. /**
  43038. * The light that the gizmo is attached to
  43039. */
  43040. light: Nullable<Light>;
  43041. /**
  43042. * @hidden
  43043. * Updates the gizmo to match the attached mesh's position/rotation
  43044. */
  43045. protected _update(): void;
  43046. }
  43047. }
  43048. declare module "babylonjs/Gizmos/index" {
  43049. export * from "babylonjs/Gizmos/axisDragGizmo";
  43050. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43051. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43052. export * from "babylonjs/Gizmos/gizmo";
  43053. export * from "babylonjs/Gizmos/gizmoManager";
  43054. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43055. export * from "babylonjs/Gizmos/positionGizmo";
  43056. export * from "babylonjs/Gizmos/rotationGizmo";
  43057. export * from "babylonjs/Gizmos/scaleGizmo";
  43058. export * from "babylonjs/Gizmos/lightGizmo";
  43059. }
  43060. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43061. /** @hidden */
  43062. export var backgroundFragmentDeclaration: {
  43063. name: string;
  43064. shader: string;
  43065. };
  43066. }
  43067. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43068. /** @hidden */
  43069. export var backgroundUboDeclaration: {
  43070. name: string;
  43071. shader: string;
  43072. };
  43073. }
  43074. declare module "babylonjs/Shaders/background.fragment" {
  43075. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43076. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43077. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43078. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43079. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43080. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43081. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43082. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43083. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43084. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43086. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43087. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43088. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43089. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43090. /** @hidden */
  43091. export var backgroundPixelShader: {
  43092. name: string;
  43093. shader: string;
  43094. };
  43095. }
  43096. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43097. /** @hidden */
  43098. export var backgroundVertexDeclaration: {
  43099. name: string;
  43100. shader: string;
  43101. };
  43102. }
  43103. declare module "babylonjs/Shaders/background.vertex" {
  43104. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43105. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43107. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43108. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43109. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43110. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43111. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43112. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43113. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43114. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43115. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43116. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43117. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43118. /** @hidden */
  43119. export var backgroundVertexShader: {
  43120. name: string;
  43121. shader: string;
  43122. };
  43123. }
  43124. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43125. import { Nullable, int, float } from "babylonjs/types";
  43126. import { Scene } from "babylonjs/scene";
  43127. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43130. import { Mesh } from "babylonjs/Meshes/mesh";
  43131. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43132. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43133. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43135. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43136. import "babylonjs/Shaders/background.fragment";
  43137. import "babylonjs/Shaders/background.vertex";
  43138. /**
  43139. * Background material used to create an efficient environement around your scene.
  43140. */
  43141. export class BackgroundMaterial extends PushMaterial {
  43142. /**
  43143. * Standard reflectance value at parallel view angle.
  43144. */
  43145. static StandardReflectance0: number;
  43146. /**
  43147. * Standard reflectance value at grazing angle.
  43148. */
  43149. static StandardReflectance90: number;
  43150. protected _primaryColor: Color3;
  43151. /**
  43152. * Key light Color (multiply against the environement texture)
  43153. */
  43154. primaryColor: Color3;
  43155. protected __perceptualColor: Nullable<Color3>;
  43156. /**
  43157. * Experimental Internal Use Only.
  43158. *
  43159. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43160. * This acts as a helper to set the primary color to a more "human friendly" value.
  43161. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43162. * output color as close as possible from the chosen value.
  43163. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43164. * part of lighting setup.)
  43165. */
  43166. _perceptualColor: Nullable<Color3>;
  43167. protected _primaryColorShadowLevel: float;
  43168. /**
  43169. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43170. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43171. */
  43172. primaryColorShadowLevel: float;
  43173. protected _primaryColorHighlightLevel: float;
  43174. /**
  43175. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43176. * The primary color is used at the level chosen to define what the white area would look.
  43177. */
  43178. primaryColorHighlightLevel: float;
  43179. protected _reflectionTexture: Nullable<BaseTexture>;
  43180. /**
  43181. * Reflection Texture used in the material.
  43182. * Should be author in a specific way for the best result (refer to the documentation).
  43183. */
  43184. reflectionTexture: Nullable<BaseTexture>;
  43185. protected _reflectionBlur: float;
  43186. /**
  43187. * Reflection Texture level of blur.
  43188. *
  43189. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43190. * texture twice.
  43191. */
  43192. reflectionBlur: float;
  43193. protected _diffuseTexture: Nullable<BaseTexture>;
  43194. /**
  43195. * Diffuse Texture used in the material.
  43196. * Should be author in a specific way for the best result (refer to the documentation).
  43197. */
  43198. diffuseTexture: Nullable<BaseTexture>;
  43199. protected _shadowLights: Nullable<IShadowLight[]>;
  43200. /**
  43201. * Specify the list of lights casting shadow on the material.
  43202. * All scene shadow lights will be included if null.
  43203. */
  43204. shadowLights: Nullable<IShadowLight[]>;
  43205. protected _shadowLevel: float;
  43206. /**
  43207. * Helps adjusting the shadow to a softer level if required.
  43208. * 0 means black shadows and 1 means no shadows.
  43209. */
  43210. shadowLevel: float;
  43211. protected _sceneCenter: Vector3;
  43212. /**
  43213. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43214. * It is usually zero but might be interesting to modify according to your setup.
  43215. */
  43216. sceneCenter: Vector3;
  43217. protected _opacityFresnel: boolean;
  43218. /**
  43219. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43220. * This helps ensuring a nice transition when the camera goes under the ground.
  43221. */
  43222. opacityFresnel: boolean;
  43223. protected _reflectionFresnel: boolean;
  43224. /**
  43225. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43226. * This helps adding a mirror texture on the ground.
  43227. */
  43228. reflectionFresnel: boolean;
  43229. protected _reflectionFalloffDistance: number;
  43230. /**
  43231. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43232. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43233. */
  43234. reflectionFalloffDistance: number;
  43235. protected _reflectionAmount: number;
  43236. /**
  43237. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43238. */
  43239. reflectionAmount: number;
  43240. protected _reflectionReflectance0: number;
  43241. /**
  43242. * This specifies the weight of the reflection at grazing angle.
  43243. */
  43244. reflectionReflectance0: number;
  43245. protected _reflectionReflectance90: number;
  43246. /**
  43247. * This specifies the weight of the reflection at a perpendicular point of view.
  43248. */
  43249. reflectionReflectance90: number;
  43250. /**
  43251. * Sets the reflection reflectance fresnel values according to the default standard
  43252. * empirically know to work well :-)
  43253. */
  43254. reflectionStandardFresnelWeight: number;
  43255. protected _useRGBColor: boolean;
  43256. /**
  43257. * Helps to directly use the maps channels instead of their level.
  43258. */
  43259. useRGBColor: boolean;
  43260. protected _enableNoise: boolean;
  43261. /**
  43262. * This helps reducing the banding effect that could occur on the background.
  43263. */
  43264. enableNoise: boolean;
  43265. /**
  43266. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43267. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43268. * Recommended to be keep at 1.0 except for special cases.
  43269. */
  43270. fovMultiplier: number;
  43271. private _fovMultiplier;
  43272. /**
  43273. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43274. */
  43275. useEquirectangularFOV: boolean;
  43276. private _maxSimultaneousLights;
  43277. /**
  43278. * Number of Simultaneous lights allowed on the material.
  43279. */
  43280. maxSimultaneousLights: int;
  43281. /**
  43282. * Default configuration related to image processing available in the Background Material.
  43283. */
  43284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43285. /**
  43286. * Keep track of the image processing observer to allow dispose and replace.
  43287. */
  43288. private _imageProcessingObserver;
  43289. /**
  43290. * Attaches a new image processing configuration to the PBR Material.
  43291. * @param configuration (if null the scene configuration will be use)
  43292. */
  43293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43294. /**
  43295. * Gets the image processing configuration used either in this material.
  43296. */
  43297. /**
  43298. * Sets the Default image processing configuration used either in the this material.
  43299. *
  43300. * If sets to null, the scene one is in use.
  43301. */
  43302. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43303. /**
  43304. * Gets wether the color curves effect is enabled.
  43305. */
  43306. /**
  43307. * Sets wether the color curves effect is enabled.
  43308. */
  43309. cameraColorCurvesEnabled: boolean;
  43310. /**
  43311. * Gets wether the color grading effect is enabled.
  43312. */
  43313. /**
  43314. * Gets wether the color grading effect is enabled.
  43315. */
  43316. cameraColorGradingEnabled: boolean;
  43317. /**
  43318. * Gets wether tonemapping is enabled or not.
  43319. */
  43320. /**
  43321. * Sets wether tonemapping is enabled or not
  43322. */
  43323. cameraToneMappingEnabled: boolean;
  43324. /**
  43325. * The camera exposure used on this material.
  43326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43327. * This corresponds to a photographic exposure.
  43328. */
  43329. /**
  43330. * The camera exposure used on this material.
  43331. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43332. * This corresponds to a photographic exposure.
  43333. */
  43334. cameraExposure: float;
  43335. /**
  43336. * Gets The camera contrast used on this material.
  43337. */
  43338. /**
  43339. * Sets The camera contrast used on this material.
  43340. */
  43341. cameraContrast: float;
  43342. /**
  43343. * Gets the Color Grading 2D Lookup Texture.
  43344. */
  43345. /**
  43346. * Sets the Color Grading 2D Lookup Texture.
  43347. */
  43348. cameraColorGradingTexture: Nullable<BaseTexture>;
  43349. /**
  43350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43352. * 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;
  43353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43354. */
  43355. /**
  43356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43358. * 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;
  43359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43360. */
  43361. cameraColorCurves: Nullable<ColorCurves>;
  43362. /**
  43363. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43364. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43365. */
  43366. switchToBGR: boolean;
  43367. private _renderTargets;
  43368. private _reflectionControls;
  43369. private _white;
  43370. private _primaryShadowColor;
  43371. private _primaryHighlightColor;
  43372. /**
  43373. * Instantiates a Background Material in the given scene
  43374. * @param name The friendly name of the material
  43375. * @param scene The scene to add the material to
  43376. */
  43377. constructor(name: string, scene: Scene);
  43378. /**
  43379. * Gets a boolean indicating that current material needs to register RTT
  43380. */
  43381. readonly hasRenderTargetTextures: boolean;
  43382. /**
  43383. * The entire material has been created in order to prevent overdraw.
  43384. * @returns false
  43385. */
  43386. needAlphaTesting(): boolean;
  43387. /**
  43388. * The entire material has been created in order to prevent overdraw.
  43389. * @returns true if blending is enable
  43390. */
  43391. needAlphaBlending(): boolean;
  43392. /**
  43393. * Checks wether the material is ready to be rendered for a given mesh.
  43394. * @param mesh The mesh to render
  43395. * @param subMesh The submesh to check against
  43396. * @param useInstances Specify wether or not the material is used with instances
  43397. * @returns true if all the dependencies are ready (Textures, Effects...)
  43398. */
  43399. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43400. /**
  43401. * Compute the primary color according to the chosen perceptual color.
  43402. */
  43403. private _computePrimaryColorFromPerceptualColor;
  43404. /**
  43405. * Compute the highlights and shadow colors according to their chosen levels.
  43406. */
  43407. private _computePrimaryColors;
  43408. /**
  43409. * Build the uniform buffer used in the material.
  43410. */
  43411. buildUniformLayout(): void;
  43412. /**
  43413. * Unbind the material.
  43414. */
  43415. unbind(): void;
  43416. /**
  43417. * Bind only the world matrix to the material.
  43418. * @param world The world matrix to bind.
  43419. */
  43420. bindOnlyWorldMatrix(world: Matrix): void;
  43421. /**
  43422. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43423. * @param world The world matrix to bind.
  43424. * @param subMesh The submesh to bind for.
  43425. */
  43426. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43427. /**
  43428. * Dispose the material.
  43429. * @param forceDisposeEffect Force disposal of the associated effect.
  43430. * @param forceDisposeTextures Force disposal of the associated textures.
  43431. */
  43432. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43433. /**
  43434. * Clones the material.
  43435. * @param name The cloned name.
  43436. * @returns The cloned material.
  43437. */
  43438. clone(name: string): BackgroundMaterial;
  43439. /**
  43440. * Serializes the current material to its JSON representation.
  43441. * @returns The JSON representation.
  43442. */
  43443. serialize(): any;
  43444. /**
  43445. * Gets the class name of the material
  43446. * @returns "BackgroundMaterial"
  43447. */
  43448. getClassName(): string;
  43449. /**
  43450. * Parse a JSON input to create back a background material.
  43451. * @param source The JSON data to parse
  43452. * @param scene The scene to create the parsed material in
  43453. * @param rootUrl The root url of the assets the material depends upon
  43454. * @returns the instantiated BackgroundMaterial.
  43455. */
  43456. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43457. }
  43458. }
  43459. declare module "babylonjs/Helpers/environmentHelper" {
  43460. import { Observable } from "babylonjs/Misc/observable";
  43461. import { Nullable } from "babylonjs/types";
  43462. import { Scene } from "babylonjs/scene";
  43463. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43465. import { Mesh } from "babylonjs/Meshes/mesh";
  43466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43467. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43468. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43469. import "babylonjs/Meshes/Builders/planeBuilder";
  43470. import "babylonjs/Meshes/Builders/boxBuilder";
  43471. /**
  43472. * Represents the different options available during the creation of
  43473. * a Environment helper.
  43474. *
  43475. * This can control the default ground, skybox and image processing setup of your scene.
  43476. */
  43477. export interface IEnvironmentHelperOptions {
  43478. /**
  43479. * Specifies wether or not to create a ground.
  43480. * True by default.
  43481. */
  43482. createGround: boolean;
  43483. /**
  43484. * Specifies the ground size.
  43485. * 15 by default.
  43486. */
  43487. groundSize: number;
  43488. /**
  43489. * The texture used on the ground for the main color.
  43490. * Comes from the BabylonJS CDN by default.
  43491. *
  43492. * Remarks: Can be either a texture or a url.
  43493. */
  43494. groundTexture: string | BaseTexture;
  43495. /**
  43496. * The color mixed in the ground texture by default.
  43497. * BabylonJS clearColor by default.
  43498. */
  43499. groundColor: Color3;
  43500. /**
  43501. * Specifies the ground opacity.
  43502. * 1 by default.
  43503. */
  43504. groundOpacity: number;
  43505. /**
  43506. * Enables the ground to receive shadows.
  43507. * True by default.
  43508. */
  43509. enableGroundShadow: boolean;
  43510. /**
  43511. * Helps preventing the shadow to be fully black on the ground.
  43512. * 0.5 by default.
  43513. */
  43514. groundShadowLevel: number;
  43515. /**
  43516. * Creates a mirror texture attach to the ground.
  43517. * false by default.
  43518. */
  43519. enableGroundMirror: boolean;
  43520. /**
  43521. * Specifies the ground mirror size ratio.
  43522. * 0.3 by default as the default kernel is 64.
  43523. */
  43524. groundMirrorSizeRatio: number;
  43525. /**
  43526. * Specifies the ground mirror blur kernel size.
  43527. * 64 by default.
  43528. */
  43529. groundMirrorBlurKernel: number;
  43530. /**
  43531. * Specifies the ground mirror visibility amount.
  43532. * 1 by default
  43533. */
  43534. groundMirrorAmount: number;
  43535. /**
  43536. * Specifies the ground mirror reflectance weight.
  43537. * This uses the standard weight of the background material to setup the fresnel effect
  43538. * of the mirror.
  43539. * 1 by default.
  43540. */
  43541. groundMirrorFresnelWeight: number;
  43542. /**
  43543. * Specifies the ground mirror Falloff distance.
  43544. * This can helps reducing the size of the reflection.
  43545. * 0 by Default.
  43546. */
  43547. groundMirrorFallOffDistance: number;
  43548. /**
  43549. * Specifies the ground mirror texture type.
  43550. * Unsigned Int by Default.
  43551. */
  43552. groundMirrorTextureType: number;
  43553. /**
  43554. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43555. * the shown objects.
  43556. */
  43557. groundYBias: number;
  43558. /**
  43559. * Specifies wether or not to create a skybox.
  43560. * True by default.
  43561. */
  43562. createSkybox: boolean;
  43563. /**
  43564. * Specifies the skybox size.
  43565. * 20 by default.
  43566. */
  43567. skyboxSize: number;
  43568. /**
  43569. * The texture used on the skybox for the main color.
  43570. * Comes from the BabylonJS CDN by default.
  43571. *
  43572. * Remarks: Can be either a texture or a url.
  43573. */
  43574. skyboxTexture: string | BaseTexture;
  43575. /**
  43576. * The color mixed in the skybox texture by default.
  43577. * BabylonJS clearColor by default.
  43578. */
  43579. skyboxColor: Color3;
  43580. /**
  43581. * The background rotation around the Y axis of the scene.
  43582. * This helps aligning the key lights of your scene with the background.
  43583. * 0 by default.
  43584. */
  43585. backgroundYRotation: number;
  43586. /**
  43587. * Compute automatically the size of the elements to best fit with the scene.
  43588. */
  43589. sizeAuto: boolean;
  43590. /**
  43591. * Default position of the rootMesh if autoSize is not true.
  43592. */
  43593. rootPosition: Vector3;
  43594. /**
  43595. * Sets up the image processing in the scene.
  43596. * true by default.
  43597. */
  43598. setupImageProcessing: boolean;
  43599. /**
  43600. * The texture used as your environment texture in the scene.
  43601. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43602. *
  43603. * Remarks: Can be either a texture or a url.
  43604. */
  43605. environmentTexture: string | BaseTexture;
  43606. /**
  43607. * The value of the exposure to apply to the scene.
  43608. * 0.6 by default if setupImageProcessing is true.
  43609. */
  43610. cameraExposure: number;
  43611. /**
  43612. * The value of the contrast to apply to the scene.
  43613. * 1.6 by default if setupImageProcessing is true.
  43614. */
  43615. cameraContrast: number;
  43616. /**
  43617. * Specifies wether or not tonemapping should be enabled in the scene.
  43618. * true by default if setupImageProcessing is true.
  43619. */
  43620. toneMappingEnabled: boolean;
  43621. }
  43622. /**
  43623. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43624. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43625. * It also helps with the default setup of your imageProcessing configuration.
  43626. */
  43627. export class EnvironmentHelper {
  43628. /**
  43629. * Default ground texture URL.
  43630. */
  43631. private static _groundTextureCDNUrl;
  43632. /**
  43633. * Default skybox texture URL.
  43634. */
  43635. private static _skyboxTextureCDNUrl;
  43636. /**
  43637. * Default environment texture URL.
  43638. */
  43639. private static _environmentTextureCDNUrl;
  43640. /**
  43641. * Creates the default options for the helper.
  43642. */
  43643. private static _getDefaultOptions;
  43644. private _rootMesh;
  43645. /**
  43646. * Gets the root mesh created by the helper.
  43647. */
  43648. readonly rootMesh: Mesh;
  43649. private _skybox;
  43650. /**
  43651. * Gets the skybox created by the helper.
  43652. */
  43653. readonly skybox: Nullable<Mesh>;
  43654. private _skyboxTexture;
  43655. /**
  43656. * Gets the skybox texture created by the helper.
  43657. */
  43658. readonly skyboxTexture: Nullable<BaseTexture>;
  43659. private _skyboxMaterial;
  43660. /**
  43661. * Gets the skybox material created by the helper.
  43662. */
  43663. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43664. private _ground;
  43665. /**
  43666. * Gets the ground mesh created by the helper.
  43667. */
  43668. readonly ground: Nullable<Mesh>;
  43669. private _groundTexture;
  43670. /**
  43671. * Gets the ground texture created by the helper.
  43672. */
  43673. readonly groundTexture: Nullable<BaseTexture>;
  43674. private _groundMirror;
  43675. /**
  43676. * Gets the ground mirror created by the helper.
  43677. */
  43678. readonly groundMirror: Nullable<MirrorTexture>;
  43679. /**
  43680. * Gets the ground mirror render list to helps pushing the meshes
  43681. * you wish in the ground reflection.
  43682. */
  43683. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43684. private _groundMaterial;
  43685. /**
  43686. * Gets the ground material created by the helper.
  43687. */
  43688. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43689. /**
  43690. * Stores the creation options.
  43691. */
  43692. private readonly _scene;
  43693. private _options;
  43694. /**
  43695. * This observable will be notified with any error during the creation of the environment,
  43696. * mainly texture creation errors.
  43697. */
  43698. onErrorObservable: Observable<{
  43699. message?: string;
  43700. exception?: any;
  43701. }>;
  43702. /**
  43703. * constructor
  43704. * @param options Defines the options we want to customize the helper
  43705. * @param scene The scene to add the material to
  43706. */
  43707. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43708. /**
  43709. * Updates the background according to the new options
  43710. * @param options
  43711. */
  43712. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43713. /**
  43714. * Sets the primary color of all the available elements.
  43715. * @param color the main color to affect to the ground and the background
  43716. */
  43717. setMainColor(color: Color3): void;
  43718. /**
  43719. * Setup the image processing according to the specified options.
  43720. */
  43721. private _setupImageProcessing;
  43722. /**
  43723. * Setup the environment texture according to the specified options.
  43724. */
  43725. private _setupEnvironmentTexture;
  43726. /**
  43727. * Setup the background according to the specified options.
  43728. */
  43729. private _setupBackground;
  43730. /**
  43731. * Get the scene sizes according to the setup.
  43732. */
  43733. private _getSceneSize;
  43734. /**
  43735. * Setup the ground according to the specified options.
  43736. */
  43737. private _setupGround;
  43738. /**
  43739. * Setup the ground material according to the specified options.
  43740. */
  43741. private _setupGroundMaterial;
  43742. /**
  43743. * Setup the ground diffuse texture according to the specified options.
  43744. */
  43745. private _setupGroundDiffuseTexture;
  43746. /**
  43747. * Setup the ground mirror texture according to the specified options.
  43748. */
  43749. private _setupGroundMirrorTexture;
  43750. /**
  43751. * Setup the ground to receive the mirror texture.
  43752. */
  43753. private _setupMirrorInGroundMaterial;
  43754. /**
  43755. * Setup the skybox according to the specified options.
  43756. */
  43757. private _setupSkybox;
  43758. /**
  43759. * Setup the skybox material according to the specified options.
  43760. */
  43761. private _setupSkyboxMaterial;
  43762. /**
  43763. * Setup the skybox reflection texture according to the specified options.
  43764. */
  43765. private _setupSkyboxReflectionTexture;
  43766. private _errorHandler;
  43767. /**
  43768. * Dispose all the elements created by the Helper.
  43769. */
  43770. dispose(): void;
  43771. }
  43772. }
  43773. declare module "babylonjs/Helpers/photoDome" {
  43774. import { Observable } from "babylonjs/Misc/observable";
  43775. import { Nullable } from "babylonjs/types";
  43776. import { Scene } from "babylonjs/scene";
  43777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43778. import { Mesh } from "babylonjs/Meshes/mesh";
  43779. import { Texture } from "babylonjs/Materials/Textures/texture";
  43780. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43781. import "babylonjs/Meshes/Builders/sphereBuilder";
  43782. /**
  43783. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43784. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43785. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43786. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43787. */
  43788. export class PhotoDome extends TransformNode {
  43789. private _useDirectMapping;
  43790. /**
  43791. * The texture being displayed on the sphere
  43792. */
  43793. protected _photoTexture: Texture;
  43794. /**
  43795. * Gets or sets the texture being displayed on the sphere
  43796. */
  43797. photoTexture: Texture;
  43798. /**
  43799. * Observable raised when an error occured while loading the 360 image
  43800. */
  43801. onLoadErrorObservable: Observable<string>;
  43802. /**
  43803. * The skybox material
  43804. */
  43805. protected _material: BackgroundMaterial;
  43806. /**
  43807. * The surface used for the skybox
  43808. */
  43809. protected _mesh: Mesh;
  43810. /**
  43811. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43812. * Also see the options.resolution property.
  43813. */
  43814. fovMultiplier: number;
  43815. /**
  43816. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43817. * @param name Element's name, child elements will append suffixes for their own names.
  43818. * @param urlsOfPhoto defines the url of the photo to display
  43819. * @param options defines an object containing optional or exposed sub element properties
  43820. * @param onError defines a callback called when an error occured while loading the texture
  43821. */
  43822. constructor(name: string, urlOfPhoto: string, options: {
  43823. resolution?: number;
  43824. size?: number;
  43825. useDirectMapping?: boolean;
  43826. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43827. /**
  43828. * Releases resources associated with this node.
  43829. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43830. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43831. */
  43832. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43833. }
  43834. }
  43835. declare module "babylonjs/Misc/textureTools" {
  43836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43837. import { Texture } from "babylonjs/Materials/Textures/texture";
  43838. import { Scene } from "babylonjs/scene";
  43839. /**
  43840. * Class used to host texture specific utilities
  43841. */
  43842. export class TextureTools {
  43843. /**
  43844. * Uses the GPU to create a copy texture rescaled at a given size
  43845. * @param texture Texture to copy from
  43846. * @param width defines the desired width
  43847. * @param height defines the desired height
  43848. * @param useBilinearMode defines if bilinear mode has to be used
  43849. * @return the generated texture
  43850. */
  43851. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43852. /**
  43853. * Gets an environment BRDF texture for a given scene
  43854. * @param scene defines the hosting scene
  43855. * @returns the environment BRDF texture
  43856. */
  43857. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43858. private static _environmentBRDFBase64Texture;
  43859. }
  43860. }
  43861. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43862. /** @hidden */
  43863. export var pbrFragmentDeclaration: {
  43864. name: string;
  43865. shader: string;
  43866. };
  43867. }
  43868. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43869. /** @hidden */
  43870. export var pbrUboDeclaration: {
  43871. name: string;
  43872. shader: string;
  43873. };
  43874. }
  43875. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43876. /** @hidden */
  43877. export var pbrFunctions: {
  43878. name: string;
  43879. shader: string;
  43880. };
  43881. }
  43882. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43883. /** @hidden */
  43884. export var harmonicsFunctions: {
  43885. name: string;
  43886. shader: string;
  43887. };
  43888. }
  43889. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43890. /** @hidden */
  43891. export var pbrLightFunctions: {
  43892. name: string;
  43893. shader: string;
  43894. };
  43895. }
  43896. declare module "babylonjs/Shaders/pbr.fragment" {
  43897. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  43898. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43899. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43900. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43901. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43902. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43904. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43905. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43906. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  43907. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43908. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  43909. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  43910. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43911. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43912. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43913. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43914. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  43915. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  43916. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43917. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  43918. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43919. /** @hidden */
  43920. export var pbrPixelShader: {
  43921. name: string;
  43922. shader: string;
  43923. };
  43924. }
  43925. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  43926. /** @hidden */
  43927. export var pbrVertexDeclaration: {
  43928. name: string;
  43929. shader: string;
  43930. };
  43931. }
  43932. declare module "babylonjs/Shaders/pbr.vertex" {
  43933. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  43934. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43935. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43937. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43938. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43939. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  43940. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43941. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43942. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43943. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  43945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  43946. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43947. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  43948. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43949. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43950. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  43951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43952. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43953. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43954. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  43955. /** @hidden */
  43956. export var pbrVertexShader: {
  43957. name: string;
  43958. shader: string;
  43959. };
  43960. }
  43961. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  43962. import { IAnimatable } from "babylonjs/Misc/tools";
  43963. import { Nullable } from "babylonjs/types";
  43964. import { Scene } from "babylonjs/scene";
  43965. import { Matrix, Color3 } from "babylonjs/Maths/math";
  43966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43968. import { Mesh } from "babylonjs/Meshes/mesh";
  43969. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43970. import { Material } from "babylonjs/Materials/material";
  43971. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43973. import "babylonjs/Shaders/pbr.fragment";
  43974. import "babylonjs/Shaders/pbr.vertex";
  43975. /**
  43976. * The Physically based material base class of BJS.
  43977. *
  43978. * This offers the main features of a standard PBR material.
  43979. * For more information, please refer to the documentation :
  43980. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43981. */
  43982. export abstract class PBRBaseMaterial extends PushMaterial {
  43983. /**
  43984. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43985. */
  43986. static readonly PBRMATERIAL_OPAQUE: number;
  43987. /**
  43988. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43989. */
  43990. static readonly PBRMATERIAL_ALPHATEST: number;
  43991. /**
  43992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43993. */
  43994. static readonly PBRMATERIAL_ALPHABLEND: number;
  43995. /**
  43996. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43997. * They are also discarded below the alpha cutoff threshold to improve performances.
  43998. */
  43999. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44000. /**
  44001. * Defines the default value of how much AO map is occluding the analytical lights
  44002. * (point spot...).
  44003. */
  44004. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44005. /**
  44006. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44007. */
  44008. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44009. /**
  44010. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44011. * to enhance interoperability with other engines.
  44012. */
  44013. static readonly LIGHTFALLOFF_GLTF: number;
  44014. /**
  44015. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44016. * to enhance interoperability with other materials.
  44017. */
  44018. static readonly LIGHTFALLOFF_STANDARD: number;
  44019. /**
  44020. * Intensity of the direct lights e.g. the four lights available in your scene.
  44021. * This impacts both the direct diffuse and specular highlights.
  44022. */
  44023. protected _directIntensity: number;
  44024. /**
  44025. * Intensity of the emissive part of the material.
  44026. * This helps controlling the emissive effect without modifying the emissive color.
  44027. */
  44028. protected _emissiveIntensity: number;
  44029. /**
  44030. * Intensity of the environment e.g. how much the environment will light the object
  44031. * either through harmonics for rough material or through the refelction for shiny ones.
  44032. */
  44033. protected _environmentIntensity: number;
  44034. /**
  44035. * This is a special control allowing the reduction of the specular highlights coming from the
  44036. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44037. */
  44038. protected _specularIntensity: number;
  44039. /**
  44040. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44041. */
  44042. private _lightingInfos;
  44043. /**
  44044. * Debug Control allowing disabling the bump map on this material.
  44045. */
  44046. protected _disableBumpMap: boolean;
  44047. /**
  44048. * AKA Diffuse Texture in standard nomenclature.
  44049. */
  44050. protected _albedoTexture: BaseTexture;
  44051. /**
  44052. * AKA Occlusion Texture in other nomenclature.
  44053. */
  44054. protected _ambientTexture: BaseTexture;
  44055. /**
  44056. * AKA Occlusion Texture Intensity in other nomenclature.
  44057. */
  44058. protected _ambientTextureStrength: number;
  44059. /**
  44060. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44061. * 1 means it completely occludes it
  44062. * 0 mean it has no impact
  44063. */
  44064. protected _ambientTextureImpactOnAnalyticalLights: number;
  44065. /**
  44066. * Stores the alpha values in a texture.
  44067. */
  44068. protected _opacityTexture: BaseTexture;
  44069. /**
  44070. * Stores the reflection values in a texture.
  44071. */
  44072. protected _reflectionTexture: BaseTexture;
  44073. /**
  44074. * Stores the refraction values in a texture.
  44075. */
  44076. protected _refractionTexture: BaseTexture;
  44077. /**
  44078. * Stores the emissive values in a texture.
  44079. */
  44080. protected _emissiveTexture: BaseTexture;
  44081. /**
  44082. * AKA Specular texture in other nomenclature.
  44083. */
  44084. protected _reflectivityTexture: BaseTexture;
  44085. /**
  44086. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44087. */
  44088. protected _metallicTexture: BaseTexture;
  44089. /**
  44090. * Specifies the metallic scalar of the metallic/roughness workflow.
  44091. * Can also be used to scale the metalness values of the metallic texture.
  44092. */
  44093. protected _metallic: Nullable<number>;
  44094. /**
  44095. * Specifies the roughness scalar of the metallic/roughness workflow.
  44096. * Can also be used to scale the roughness values of the metallic texture.
  44097. */
  44098. protected _roughness: Nullable<number>;
  44099. /**
  44100. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44101. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44102. */
  44103. protected _microSurfaceTexture: BaseTexture;
  44104. /**
  44105. * Stores surface normal data used to displace a mesh in a texture.
  44106. */
  44107. protected _bumpTexture: BaseTexture;
  44108. /**
  44109. * Stores the pre-calculated light information of a mesh in a texture.
  44110. */
  44111. protected _lightmapTexture: BaseTexture;
  44112. /**
  44113. * The color of a material in ambient lighting.
  44114. */
  44115. protected _ambientColor: Color3;
  44116. /**
  44117. * AKA Diffuse Color in other nomenclature.
  44118. */
  44119. protected _albedoColor: Color3;
  44120. /**
  44121. * AKA Specular Color in other nomenclature.
  44122. */
  44123. protected _reflectivityColor: Color3;
  44124. /**
  44125. * The color applied when light is reflected from a material.
  44126. */
  44127. protected _reflectionColor: Color3;
  44128. /**
  44129. * The color applied when light is emitted from a material.
  44130. */
  44131. protected _emissiveColor: Color3;
  44132. /**
  44133. * AKA Glossiness in other nomenclature.
  44134. */
  44135. protected _microSurface: number;
  44136. /**
  44137. * source material index of refraction (IOR)' / 'destination material IOR.
  44138. */
  44139. protected _indexOfRefraction: number;
  44140. /**
  44141. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44142. */
  44143. protected _invertRefractionY: boolean;
  44144. /**
  44145. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44146. * Materials half opaque for instance using refraction could benefit from this control.
  44147. */
  44148. protected _linkRefractionWithTransparency: boolean;
  44149. /**
  44150. * Specifies that the material will use the light map as a show map.
  44151. */
  44152. protected _useLightmapAsShadowmap: boolean;
  44153. /**
  44154. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44155. * makes the reflect vector face the model (under horizon).
  44156. */
  44157. protected _useHorizonOcclusion: boolean;
  44158. /**
  44159. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44160. * too much the area relying on ambient texture to define their ambient occlusion.
  44161. */
  44162. protected _useRadianceOcclusion: boolean;
  44163. /**
  44164. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44165. */
  44166. protected _useAlphaFromAlbedoTexture: boolean;
  44167. /**
  44168. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44169. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44170. */
  44171. protected _useSpecularOverAlpha: boolean;
  44172. /**
  44173. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44174. */
  44175. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44176. /**
  44177. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44178. */
  44179. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44180. /**
  44181. * Specifies if the metallic texture contains the roughness information in its green channel.
  44182. */
  44183. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44184. /**
  44185. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44186. */
  44187. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44188. /**
  44189. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44190. */
  44191. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44192. /**
  44193. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44194. */
  44195. protected _useAmbientInGrayScale: boolean;
  44196. /**
  44197. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44198. * The material will try to infer what glossiness each pixel should be.
  44199. */
  44200. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44201. /**
  44202. * Defines the falloff type used in this material.
  44203. * It by default is Physical.
  44204. */
  44205. protected _lightFalloff: number;
  44206. /**
  44207. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44208. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44209. */
  44210. protected _useRadianceOverAlpha: boolean;
  44211. /**
  44212. * Allows using an object space normal map (instead of tangent space).
  44213. */
  44214. protected _useObjectSpaceNormalMap: boolean;
  44215. /**
  44216. * Allows using the bump map in parallax mode.
  44217. */
  44218. protected _useParallax: boolean;
  44219. /**
  44220. * Allows using the bump map in parallax occlusion mode.
  44221. */
  44222. protected _useParallaxOcclusion: boolean;
  44223. /**
  44224. * Controls the scale bias of the parallax mode.
  44225. */
  44226. protected _parallaxScaleBias: number;
  44227. /**
  44228. * If sets to true, disables all the lights affecting the material.
  44229. */
  44230. protected _disableLighting: boolean;
  44231. /**
  44232. * Number of Simultaneous lights allowed on the material.
  44233. */
  44234. protected _maxSimultaneousLights: number;
  44235. /**
  44236. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44237. */
  44238. protected _invertNormalMapX: boolean;
  44239. /**
  44240. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44241. */
  44242. protected _invertNormalMapY: boolean;
  44243. /**
  44244. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44245. */
  44246. protected _twoSidedLighting: boolean;
  44247. /**
  44248. * Defines the alpha limits in alpha test mode.
  44249. */
  44250. protected _alphaCutOff: number;
  44251. /**
  44252. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44253. */
  44254. protected _forceAlphaTest: boolean;
  44255. /**
  44256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44257. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44258. */
  44259. protected _useAlphaFresnel: boolean;
  44260. /**
  44261. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44262. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44263. */
  44264. protected _useLinearAlphaFresnel: boolean;
  44265. /**
  44266. * The transparency mode of the material.
  44267. */
  44268. protected _transparencyMode: Nullable<number>;
  44269. /**
  44270. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44271. * from cos thetav and roughness:
  44272. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44273. */
  44274. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44275. /**
  44276. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44277. */
  44278. protected _forceIrradianceInFragment: boolean;
  44279. /**
  44280. * Force normal to face away from face.
  44281. */
  44282. protected _forceNormalForward: boolean;
  44283. /**
  44284. * Enables specular anti aliasing in the PBR shader.
  44285. * It will both interacts on the Geometry for analytical and IBL lighting.
  44286. * It also prefilter the roughness map based on the bump values.
  44287. */
  44288. protected _enableSpecularAntiAliasing: boolean;
  44289. /**
  44290. * Default configuration related to image processing available in the PBR Material.
  44291. */
  44292. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44293. /**
  44294. * Keep track of the image processing observer to allow dispose and replace.
  44295. */
  44296. private _imageProcessingObserver;
  44297. /**
  44298. * Attaches a new image processing configuration to the PBR Material.
  44299. * @param configuration
  44300. */
  44301. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44302. /**
  44303. * Stores the available render targets.
  44304. */
  44305. private _renderTargets;
  44306. /**
  44307. * Sets the global ambient color for the material used in lighting calculations.
  44308. */
  44309. private _globalAmbientColor;
  44310. /**
  44311. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44312. */
  44313. private _useLogarithmicDepth;
  44314. /**
  44315. * If set to true, no lighting calculations will be applied.
  44316. */
  44317. private _unlit;
  44318. /**
  44319. * Instantiates a new PBRMaterial instance.
  44320. *
  44321. * @param name The material name
  44322. * @param scene The scene the material will be use in.
  44323. */
  44324. constructor(name: string, scene: Scene);
  44325. /**
  44326. * Gets a boolean indicating that current material needs to register RTT
  44327. */
  44328. readonly hasRenderTargetTextures: boolean;
  44329. /**
  44330. * Gets the name of the material class.
  44331. */
  44332. getClassName(): string;
  44333. /**
  44334. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44335. */
  44336. /**
  44337. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44338. */
  44339. useLogarithmicDepth: boolean;
  44340. /**
  44341. * Gets the current transparency mode.
  44342. */
  44343. /**
  44344. * Sets the transparency mode of the material.
  44345. *
  44346. * | Value | Type | Description |
  44347. * | ----- | ----------------------------------- | ----------- |
  44348. * | 0 | OPAQUE | |
  44349. * | 1 | ALPHATEST | |
  44350. * | 2 | ALPHABLEND | |
  44351. * | 3 | ALPHATESTANDBLEND | |
  44352. *
  44353. */
  44354. transparencyMode: Nullable<number>;
  44355. /**
  44356. * Returns true if alpha blending should be disabled.
  44357. */
  44358. private readonly _disableAlphaBlending;
  44359. /**
  44360. * Specifies whether or not this material should be rendered in alpha blend mode.
  44361. */
  44362. needAlphaBlending(): boolean;
  44363. /**
  44364. * Specifies if the mesh will require alpha blending.
  44365. * @param mesh - BJS mesh.
  44366. */
  44367. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44368. /**
  44369. * Specifies whether or not this material should be rendered in alpha test mode.
  44370. */
  44371. needAlphaTesting(): boolean;
  44372. /**
  44373. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44374. */
  44375. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44376. /**
  44377. * Gets the texture used for the alpha test.
  44378. */
  44379. getAlphaTestTexture(): BaseTexture;
  44380. /**
  44381. * Specifies that the submesh is ready to be used.
  44382. * @param mesh - BJS mesh.
  44383. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44384. * @param useInstances - Specifies that instances should be used.
  44385. * @returns - boolean indicating that the submesh is ready or not.
  44386. */
  44387. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44388. /**
  44389. * Specifies if the material uses metallic roughness workflow.
  44390. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44391. */
  44392. isMetallicWorkflow(): boolean;
  44393. private _prepareEffect;
  44394. private _prepareDefines;
  44395. /**
  44396. * Force shader compilation
  44397. */
  44398. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44399. clipPlane: boolean;
  44400. }>): void;
  44401. /**
  44402. * Initializes the uniform buffer layout for the shader.
  44403. */
  44404. buildUniformLayout(): void;
  44405. /**
  44406. * Unbinds the textures.
  44407. */
  44408. unbind(): void;
  44409. /**
  44410. * Binds the submesh data.
  44411. * @param world - The world matrix.
  44412. * @param mesh - The BJS mesh.
  44413. * @param subMesh - A submesh of the BJS mesh.
  44414. */
  44415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44416. /**
  44417. * Returns the animatable textures.
  44418. * @returns - Array of animatable textures.
  44419. */
  44420. getAnimatables(): IAnimatable[];
  44421. /**
  44422. * Returns the texture used for reflections.
  44423. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44424. */
  44425. private _getReflectionTexture;
  44426. /**
  44427. * Returns the texture used for refraction or null if none is used.
  44428. * @returns - Refection texture if present. If no refraction texture and refraction
  44429. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44430. */
  44431. private _getRefractionTexture;
  44432. /**
  44433. * Disposes the resources of the material.
  44434. * @param forceDisposeEffect - Forces the disposal of effects.
  44435. * @param forceDisposeTextures - Forces the disposal of all textures.
  44436. */
  44437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44438. }
  44439. }
  44440. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44441. import { Nullable } from "babylonjs/types";
  44442. import { Scene } from "babylonjs/scene";
  44443. import { Color3 } from "babylonjs/Maths/math";
  44444. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44445. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44446. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44447. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44448. /**
  44449. * The Physically based material of BJS.
  44450. *
  44451. * This offers the main features of a standard PBR material.
  44452. * For more information, please refer to the documentation :
  44453. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44454. */
  44455. export class PBRMaterial extends PBRBaseMaterial {
  44456. /**
  44457. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44458. */
  44459. static readonly PBRMATERIAL_OPAQUE: number;
  44460. /**
  44461. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44462. */
  44463. static readonly PBRMATERIAL_ALPHATEST: number;
  44464. /**
  44465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44466. */
  44467. static readonly PBRMATERIAL_ALPHABLEND: number;
  44468. /**
  44469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44470. * They are also discarded below the alpha cutoff threshold to improve performances.
  44471. */
  44472. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44473. /**
  44474. * Defines the default value of how much AO map is occluding the analytical lights
  44475. * (point spot...).
  44476. */
  44477. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44478. /**
  44479. * Intensity of the direct lights e.g. the four lights available in your scene.
  44480. * This impacts both the direct diffuse and specular highlights.
  44481. */
  44482. directIntensity: number;
  44483. /**
  44484. * Intensity of the emissive part of the material.
  44485. * This helps controlling the emissive effect without modifying the emissive color.
  44486. */
  44487. emissiveIntensity: number;
  44488. /**
  44489. * Intensity of the environment e.g. how much the environment will light the object
  44490. * either through harmonics for rough material or through the refelction for shiny ones.
  44491. */
  44492. environmentIntensity: number;
  44493. /**
  44494. * This is a special control allowing the reduction of the specular highlights coming from the
  44495. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44496. */
  44497. specularIntensity: number;
  44498. /**
  44499. * Debug Control allowing disabling the bump map on this material.
  44500. */
  44501. disableBumpMap: boolean;
  44502. /**
  44503. * AKA Diffuse Texture in standard nomenclature.
  44504. */
  44505. albedoTexture: BaseTexture;
  44506. /**
  44507. * AKA Occlusion Texture in other nomenclature.
  44508. */
  44509. ambientTexture: BaseTexture;
  44510. /**
  44511. * AKA Occlusion Texture Intensity in other nomenclature.
  44512. */
  44513. ambientTextureStrength: number;
  44514. /**
  44515. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44516. * 1 means it completely occludes it
  44517. * 0 mean it has no impact
  44518. */
  44519. ambientTextureImpactOnAnalyticalLights: number;
  44520. /**
  44521. * Stores the alpha values in a texture.
  44522. */
  44523. opacityTexture: BaseTexture;
  44524. /**
  44525. * Stores the reflection values in a texture.
  44526. */
  44527. reflectionTexture: Nullable<BaseTexture>;
  44528. /**
  44529. * Stores the emissive values in a texture.
  44530. */
  44531. emissiveTexture: BaseTexture;
  44532. /**
  44533. * AKA Specular texture in other nomenclature.
  44534. */
  44535. reflectivityTexture: BaseTexture;
  44536. /**
  44537. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44538. */
  44539. metallicTexture: BaseTexture;
  44540. /**
  44541. * Specifies the metallic scalar of the metallic/roughness workflow.
  44542. * Can also be used to scale the metalness values of the metallic texture.
  44543. */
  44544. metallic: Nullable<number>;
  44545. /**
  44546. * Specifies the roughness scalar of the metallic/roughness workflow.
  44547. * Can also be used to scale the roughness values of the metallic texture.
  44548. */
  44549. roughness: Nullable<number>;
  44550. /**
  44551. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44552. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44553. */
  44554. microSurfaceTexture: BaseTexture;
  44555. /**
  44556. * Stores surface normal data used to displace a mesh in a texture.
  44557. */
  44558. bumpTexture: BaseTexture;
  44559. /**
  44560. * Stores the pre-calculated light information of a mesh in a texture.
  44561. */
  44562. lightmapTexture: BaseTexture;
  44563. /**
  44564. * Stores the refracted light information in a texture.
  44565. */
  44566. refractionTexture: BaseTexture;
  44567. /**
  44568. * The color of a material in ambient lighting.
  44569. */
  44570. ambientColor: Color3;
  44571. /**
  44572. * AKA Diffuse Color in other nomenclature.
  44573. */
  44574. albedoColor: Color3;
  44575. /**
  44576. * AKA Specular Color in other nomenclature.
  44577. */
  44578. reflectivityColor: Color3;
  44579. /**
  44580. * The color reflected from the material.
  44581. */
  44582. reflectionColor: Color3;
  44583. /**
  44584. * The color emitted from the material.
  44585. */
  44586. emissiveColor: Color3;
  44587. /**
  44588. * AKA Glossiness in other nomenclature.
  44589. */
  44590. microSurface: number;
  44591. /**
  44592. * source material index of refraction (IOR)' / 'destination material IOR.
  44593. */
  44594. indexOfRefraction: number;
  44595. /**
  44596. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44597. */
  44598. invertRefractionY: boolean;
  44599. /**
  44600. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44601. * Materials half opaque for instance using refraction could benefit from this control.
  44602. */
  44603. linkRefractionWithTransparency: boolean;
  44604. /**
  44605. * If true, the light map contains occlusion information instead of lighting info.
  44606. */
  44607. useLightmapAsShadowmap: boolean;
  44608. /**
  44609. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44610. */
  44611. useAlphaFromAlbedoTexture: boolean;
  44612. /**
  44613. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44614. */
  44615. forceAlphaTest: boolean;
  44616. /**
  44617. * Defines the alpha limits in alpha test mode.
  44618. */
  44619. alphaCutOff: number;
  44620. /**
  44621. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44622. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44623. */
  44624. useSpecularOverAlpha: boolean;
  44625. /**
  44626. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44627. */
  44628. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44629. /**
  44630. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44631. */
  44632. useRoughnessFromMetallicTextureAlpha: boolean;
  44633. /**
  44634. * Specifies if the metallic texture contains the roughness information in its green channel.
  44635. */
  44636. useRoughnessFromMetallicTextureGreen: boolean;
  44637. /**
  44638. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44639. */
  44640. useMetallnessFromMetallicTextureBlue: boolean;
  44641. /**
  44642. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44643. */
  44644. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44645. /**
  44646. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44647. */
  44648. useAmbientInGrayScale: boolean;
  44649. /**
  44650. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44651. * The material will try to infer what glossiness each pixel should be.
  44652. */
  44653. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44654. /**
  44655. * BJS is using an harcoded light falloff based on a manually sets up range.
  44656. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44657. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44658. */
  44659. /**
  44660. * BJS is using an harcoded light falloff based on a manually sets up range.
  44661. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44662. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44663. */
  44664. usePhysicalLightFalloff: boolean;
  44665. /**
  44666. * In order to support the falloff compatibility with gltf, a special mode has been added
  44667. * to reproduce the gltf light falloff.
  44668. */
  44669. /**
  44670. * In order to support the falloff compatibility with gltf, a special mode has been added
  44671. * to reproduce the gltf light falloff.
  44672. */
  44673. useGLTFLightFalloff: boolean;
  44674. /**
  44675. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44676. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44677. */
  44678. useRadianceOverAlpha: boolean;
  44679. /**
  44680. * Allows using an object space normal map (instead of tangent space).
  44681. */
  44682. useObjectSpaceNormalMap: boolean;
  44683. /**
  44684. * Allows using the bump map in parallax mode.
  44685. */
  44686. useParallax: boolean;
  44687. /**
  44688. * Allows using the bump map in parallax occlusion mode.
  44689. */
  44690. useParallaxOcclusion: boolean;
  44691. /**
  44692. * Controls the scale bias of the parallax mode.
  44693. */
  44694. parallaxScaleBias: number;
  44695. /**
  44696. * If sets to true, disables all the lights affecting the material.
  44697. */
  44698. disableLighting: boolean;
  44699. /**
  44700. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44701. */
  44702. forceIrradianceInFragment: boolean;
  44703. /**
  44704. * Number of Simultaneous lights allowed on the material.
  44705. */
  44706. maxSimultaneousLights: number;
  44707. /**
  44708. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44709. */
  44710. invertNormalMapX: boolean;
  44711. /**
  44712. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44713. */
  44714. invertNormalMapY: boolean;
  44715. /**
  44716. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44717. */
  44718. twoSidedLighting: boolean;
  44719. /**
  44720. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44721. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44722. */
  44723. useAlphaFresnel: boolean;
  44724. /**
  44725. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44726. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44727. */
  44728. useLinearAlphaFresnel: boolean;
  44729. /**
  44730. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44731. * And/Or occlude the blended part.
  44732. */
  44733. environmentBRDFTexture: Nullable<BaseTexture>;
  44734. /**
  44735. * Force normal to face away from face.
  44736. */
  44737. forceNormalForward: boolean;
  44738. /**
  44739. * Enables specular anti aliasing in the PBR shader.
  44740. * It will both interacts on the Geometry for analytical and IBL lighting.
  44741. * It also prefilter the roughness map based on the bump values.
  44742. */
  44743. enableSpecularAntiAliasing: boolean;
  44744. /**
  44745. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44746. * makes the reflect vector face the model (under horizon).
  44747. */
  44748. useHorizonOcclusion: boolean;
  44749. /**
  44750. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44751. * too much the area relying on ambient texture to define their ambient occlusion.
  44752. */
  44753. useRadianceOcclusion: boolean;
  44754. /**
  44755. * If set to true, no lighting calculations will be applied.
  44756. */
  44757. unlit: boolean;
  44758. /**
  44759. * Gets the image processing configuration used either in this material.
  44760. */
  44761. /**
  44762. * Sets the Default image processing configuration used either in the this material.
  44763. *
  44764. * If sets to null, the scene one is in use.
  44765. */
  44766. imageProcessingConfiguration: ImageProcessingConfiguration;
  44767. /**
  44768. * Gets wether the color curves effect is enabled.
  44769. */
  44770. /**
  44771. * Sets wether the color curves effect is enabled.
  44772. */
  44773. cameraColorCurvesEnabled: boolean;
  44774. /**
  44775. * Gets wether the color grading effect is enabled.
  44776. */
  44777. /**
  44778. * Gets wether the color grading effect is enabled.
  44779. */
  44780. cameraColorGradingEnabled: boolean;
  44781. /**
  44782. * Gets wether tonemapping is enabled or not.
  44783. */
  44784. /**
  44785. * Sets wether tonemapping is enabled or not
  44786. */
  44787. cameraToneMappingEnabled: boolean;
  44788. /**
  44789. * The camera exposure used on this material.
  44790. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44791. * This corresponds to a photographic exposure.
  44792. */
  44793. /**
  44794. * The camera exposure used on this material.
  44795. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44796. * This corresponds to a photographic exposure.
  44797. */
  44798. cameraExposure: number;
  44799. /**
  44800. * Gets The camera contrast used on this material.
  44801. */
  44802. /**
  44803. * Sets The camera contrast used on this material.
  44804. */
  44805. cameraContrast: number;
  44806. /**
  44807. * Gets the Color Grading 2D Lookup Texture.
  44808. */
  44809. /**
  44810. * Sets the Color Grading 2D Lookup Texture.
  44811. */
  44812. cameraColorGradingTexture: Nullable<BaseTexture>;
  44813. /**
  44814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44816. * 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;
  44817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44818. */
  44819. /**
  44820. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44821. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44822. * 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;
  44823. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44824. */
  44825. cameraColorCurves: Nullable<ColorCurves>;
  44826. /**
  44827. * Instantiates a new PBRMaterial instance.
  44828. *
  44829. * @param name The material name
  44830. * @param scene The scene the material will be use in.
  44831. */
  44832. constructor(name: string, scene: Scene);
  44833. /**
  44834. * Returns the name of this material class.
  44835. */
  44836. getClassName(): string;
  44837. /**
  44838. * Returns an array of the actively used textures.
  44839. * @returns - Array of BaseTextures
  44840. */
  44841. getActiveTextures(): BaseTexture[];
  44842. /**
  44843. * Checks to see if a texture is used in the material.
  44844. * @param texture - Base texture to use.
  44845. * @returns - Boolean specifying if a texture is used in the material.
  44846. */
  44847. hasTexture(texture: BaseTexture): boolean;
  44848. /**
  44849. * Makes a duplicate of the current material.
  44850. * @param name - name to use for the new material.
  44851. */
  44852. clone(name: string): PBRMaterial;
  44853. /**
  44854. * Serializes this PBR Material.
  44855. * @returns - An object with the serialized material.
  44856. */
  44857. serialize(): any;
  44858. /**
  44859. * Parses a PBR Material from a serialized object.
  44860. * @param source - Serialized object.
  44861. * @param scene - BJS scene instance.
  44862. * @param rootUrl - url for the scene object
  44863. * @returns - PBRMaterial
  44864. */
  44865. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44866. }
  44867. }
  44868. declare module "babylonjs/Helpers/sceneHelpers" {
  44869. import { Nullable } from "babylonjs/types";
  44870. import { Mesh } from "babylonjs/Meshes/mesh";
  44871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44872. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44873. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44874. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44875. import "babylonjs/Meshes/Builders/boxBuilder";
  44876. /** @hidden */
  44877. export var _forceSceneHelpersToBundle: boolean;
  44878. module "babylonjs/scene" {
  44879. interface Scene {
  44880. /**
  44881. * Creates a default light for the scene.
  44882. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44883. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44884. */
  44885. createDefaultLight(replace?: boolean): void;
  44886. /**
  44887. * Creates a default camera for the scene.
  44888. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44889. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44890. * @param replace has default false, when true replaces the active camera in the scene
  44891. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44892. */
  44893. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44894. /**
  44895. * Creates a default camera and a default light.
  44896. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44897. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44898. * @param replace has the default false, when true replaces the active camera/light in the scene
  44899. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  44900. */
  44901. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44902. /**
  44903. * Creates a new sky box
  44904. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  44905. * @param environmentTexture defines the texture to use as environment texture
  44906. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  44907. * @param scale defines the overall scale of the skybox
  44908. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  44909. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  44910. * @returns a new mesh holding the sky box
  44911. */
  44912. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  44913. /**
  44914. * Creates a new environment
  44915. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  44916. * @param options defines the options you can use to configure the environment
  44917. * @returns the new EnvironmentHelper
  44918. */
  44919. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  44920. /**
  44921. * Creates a new VREXperienceHelper
  44922. * @see http://doc.babylonjs.com/how_to/webvr_helper
  44923. * @param webVROptions defines the options used to create the new VREXperienceHelper
  44924. * @returns a new VREXperienceHelper
  44925. */
  44926. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  44927. /**
  44928. * Creates a new XREXperienceHelper
  44929. * @see http://doc.babylonjs.com/how_to/webxr
  44930. * @returns a promise for a new XREXperienceHelper
  44931. */
  44932. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  44933. }
  44934. }
  44935. }
  44936. declare module "babylonjs/Helpers/videoDome" {
  44937. import { Scene } from "babylonjs/scene";
  44938. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44939. import { Mesh } from "babylonjs/Meshes/mesh";
  44940. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  44941. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44942. import "babylonjs/Meshes/Builders/sphereBuilder";
  44943. /**
  44944. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  44945. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  44946. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  44947. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44948. */
  44949. export class VideoDome extends TransformNode {
  44950. private _useDirectMapping;
  44951. /**
  44952. * The video texture being displayed on the sphere
  44953. */
  44954. protected _videoTexture: VideoTexture;
  44955. /**
  44956. * Gets the video texture being displayed on the sphere
  44957. */
  44958. readonly videoTexture: VideoTexture;
  44959. /**
  44960. * The skybox material
  44961. */
  44962. protected _material: BackgroundMaterial;
  44963. /**
  44964. * The surface used for the skybox
  44965. */
  44966. protected _mesh: Mesh;
  44967. /**
  44968. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44969. * Also see the options.resolution property.
  44970. */
  44971. fovMultiplier: number;
  44972. /**
  44973. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  44974. * @param name Element's name, child elements will append suffixes for their own names.
  44975. * @param urlsOrVideo defines the url(s) or the video element to use
  44976. * @param options An object containing optional or exposed sub element properties
  44977. */
  44978. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  44979. resolution?: number;
  44980. clickToPlay?: boolean;
  44981. autoPlay?: boolean;
  44982. loop?: boolean;
  44983. size?: number;
  44984. poster?: string;
  44985. useDirectMapping?: boolean;
  44986. }, scene: Scene);
  44987. /**
  44988. * Releases resources associated with this node.
  44989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44991. */
  44992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44993. }
  44994. }
  44995. declare module "babylonjs/Helpers/index" {
  44996. export * from "babylonjs/Helpers/environmentHelper";
  44997. export * from "babylonjs/Helpers/photoDome";
  44998. export * from "babylonjs/Helpers/sceneHelpers";
  44999. export * from "babylonjs/Helpers/videoDome";
  45000. }
  45001. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45002. import { PerfCounter } from "babylonjs/Misc/tools";
  45003. import { IDisposable } from "babylonjs/scene";
  45004. import { Engine } from "babylonjs/Engines/engine";
  45005. /**
  45006. * This class can be used to get instrumentation data from a Babylon engine
  45007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45008. */
  45009. export class EngineInstrumentation implements IDisposable {
  45010. /**
  45011. * Define the instrumented engine.
  45012. */
  45013. engine: Engine;
  45014. private _captureGPUFrameTime;
  45015. private _gpuFrameTimeToken;
  45016. private _gpuFrameTime;
  45017. private _captureShaderCompilationTime;
  45018. private _shaderCompilationTime;
  45019. private _onBeginFrameObserver;
  45020. private _onEndFrameObserver;
  45021. private _onBeforeShaderCompilationObserver;
  45022. private _onAfterShaderCompilationObserver;
  45023. /**
  45024. * Gets the perf counter used for GPU frame time
  45025. */
  45026. readonly gpuFrameTimeCounter: PerfCounter;
  45027. /**
  45028. * Gets the GPU frame time capture status
  45029. */
  45030. /**
  45031. * Enable or disable the GPU frame time capture
  45032. */
  45033. captureGPUFrameTime: boolean;
  45034. /**
  45035. * Gets the perf counter used for shader compilation time
  45036. */
  45037. readonly shaderCompilationTimeCounter: PerfCounter;
  45038. /**
  45039. * Gets the shader compilation time capture status
  45040. */
  45041. /**
  45042. * Enable or disable the shader compilation time capture
  45043. */
  45044. captureShaderCompilationTime: boolean;
  45045. /**
  45046. * Instantiates a new engine instrumentation.
  45047. * This class can be used to get instrumentation data from a Babylon engine
  45048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45049. * @param engine Defines the engine to instrument
  45050. */
  45051. constructor(
  45052. /**
  45053. * Define the instrumented engine.
  45054. */
  45055. engine: Engine);
  45056. /**
  45057. * Dispose and release associated resources.
  45058. */
  45059. dispose(): void;
  45060. }
  45061. }
  45062. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45063. import { PerfCounter } from "babylonjs/Misc/tools";
  45064. import { Scene, IDisposable } from "babylonjs/scene";
  45065. /**
  45066. * This class can be used to get instrumentation data from a Babylon engine
  45067. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45068. */
  45069. export class SceneInstrumentation implements IDisposable {
  45070. /**
  45071. * Defines the scene to instrument
  45072. */
  45073. scene: Scene;
  45074. private _captureActiveMeshesEvaluationTime;
  45075. private _activeMeshesEvaluationTime;
  45076. private _captureRenderTargetsRenderTime;
  45077. private _renderTargetsRenderTime;
  45078. private _captureFrameTime;
  45079. private _frameTime;
  45080. private _captureRenderTime;
  45081. private _renderTime;
  45082. private _captureInterFrameTime;
  45083. private _interFrameTime;
  45084. private _captureParticlesRenderTime;
  45085. private _particlesRenderTime;
  45086. private _captureSpritesRenderTime;
  45087. private _spritesRenderTime;
  45088. private _capturePhysicsTime;
  45089. private _physicsTime;
  45090. private _captureAnimationsTime;
  45091. private _animationsTime;
  45092. private _captureCameraRenderTime;
  45093. private _cameraRenderTime;
  45094. private _onBeforeActiveMeshesEvaluationObserver;
  45095. private _onAfterActiveMeshesEvaluationObserver;
  45096. private _onBeforeRenderTargetsRenderObserver;
  45097. private _onAfterRenderTargetsRenderObserver;
  45098. private _onAfterRenderObserver;
  45099. private _onBeforeDrawPhaseObserver;
  45100. private _onAfterDrawPhaseObserver;
  45101. private _onBeforeAnimationsObserver;
  45102. private _onBeforeParticlesRenderingObserver;
  45103. private _onAfterParticlesRenderingObserver;
  45104. private _onBeforeSpritesRenderingObserver;
  45105. private _onAfterSpritesRenderingObserver;
  45106. private _onBeforePhysicsObserver;
  45107. private _onAfterPhysicsObserver;
  45108. private _onAfterAnimationsObserver;
  45109. private _onBeforeCameraRenderObserver;
  45110. private _onAfterCameraRenderObserver;
  45111. /**
  45112. * Gets the perf counter used for active meshes evaluation time
  45113. */
  45114. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45115. /**
  45116. * Gets the active meshes evaluation time capture status
  45117. */
  45118. /**
  45119. * Enable or disable the active meshes evaluation time capture
  45120. */
  45121. captureActiveMeshesEvaluationTime: boolean;
  45122. /**
  45123. * Gets the perf counter used for render targets render time
  45124. */
  45125. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45126. /**
  45127. * Gets the render targets render time capture status
  45128. */
  45129. /**
  45130. * Enable or disable the render targets render time capture
  45131. */
  45132. captureRenderTargetsRenderTime: boolean;
  45133. /**
  45134. * Gets the perf counter used for particles render time
  45135. */
  45136. readonly particlesRenderTimeCounter: PerfCounter;
  45137. /**
  45138. * Gets the particles render time capture status
  45139. */
  45140. /**
  45141. * Enable or disable the particles render time capture
  45142. */
  45143. captureParticlesRenderTime: boolean;
  45144. /**
  45145. * Gets the perf counter used for sprites render time
  45146. */
  45147. readonly spritesRenderTimeCounter: PerfCounter;
  45148. /**
  45149. * Gets the sprites render time capture status
  45150. */
  45151. /**
  45152. * Enable or disable the sprites render time capture
  45153. */
  45154. captureSpritesRenderTime: boolean;
  45155. /**
  45156. * Gets the perf counter used for physics time
  45157. */
  45158. readonly physicsTimeCounter: PerfCounter;
  45159. /**
  45160. * Gets the physics time capture status
  45161. */
  45162. /**
  45163. * Enable or disable the physics time capture
  45164. */
  45165. capturePhysicsTime: boolean;
  45166. /**
  45167. * Gets the perf counter used for animations time
  45168. */
  45169. readonly animationsTimeCounter: PerfCounter;
  45170. /**
  45171. * Gets the animations time capture status
  45172. */
  45173. /**
  45174. * Enable or disable the animations time capture
  45175. */
  45176. captureAnimationsTime: boolean;
  45177. /**
  45178. * Gets the perf counter used for frame time capture
  45179. */
  45180. readonly frameTimeCounter: PerfCounter;
  45181. /**
  45182. * Gets the frame time capture status
  45183. */
  45184. /**
  45185. * Enable or disable the frame time capture
  45186. */
  45187. captureFrameTime: boolean;
  45188. /**
  45189. * Gets the perf counter used for inter-frames time capture
  45190. */
  45191. readonly interFrameTimeCounter: PerfCounter;
  45192. /**
  45193. * Gets the inter-frames time capture status
  45194. */
  45195. /**
  45196. * Enable or disable the inter-frames time capture
  45197. */
  45198. captureInterFrameTime: boolean;
  45199. /**
  45200. * Gets the perf counter used for render time capture
  45201. */
  45202. readonly renderTimeCounter: PerfCounter;
  45203. /**
  45204. * Gets the render time capture status
  45205. */
  45206. /**
  45207. * Enable or disable the render time capture
  45208. */
  45209. captureRenderTime: boolean;
  45210. /**
  45211. * Gets the perf counter used for camera render time capture
  45212. */
  45213. readonly cameraRenderTimeCounter: PerfCounter;
  45214. /**
  45215. * Gets the camera render time capture status
  45216. */
  45217. /**
  45218. * Enable or disable the camera render time capture
  45219. */
  45220. captureCameraRenderTime: boolean;
  45221. /**
  45222. * Gets the perf counter used for draw calls
  45223. */
  45224. readonly drawCallsCounter: PerfCounter;
  45225. /**
  45226. * Gets the perf counter used for texture collisions
  45227. */
  45228. readonly textureCollisionsCounter: PerfCounter;
  45229. /**
  45230. * Instantiates a new scene instrumentation.
  45231. * This class can be used to get instrumentation data from a Babylon engine
  45232. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45233. * @param scene Defines the scene to instrument
  45234. */
  45235. constructor(
  45236. /**
  45237. * Defines the scene to instrument
  45238. */
  45239. scene: Scene);
  45240. /**
  45241. * Dispose and release associated resources.
  45242. */
  45243. dispose(): void;
  45244. }
  45245. }
  45246. declare module "babylonjs/Instrumentation/index" {
  45247. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45248. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45249. export * from "babylonjs/Instrumentation/timeToken";
  45250. }
  45251. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45252. /** @hidden */
  45253. export var glowMapGenerationPixelShader: {
  45254. name: string;
  45255. shader: string;
  45256. };
  45257. }
  45258. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45259. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45260. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45261. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45262. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45264. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45265. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45266. /** @hidden */
  45267. export var glowMapGenerationVertexShader: {
  45268. name: string;
  45269. shader: string;
  45270. };
  45271. }
  45272. declare module "babylonjs/Layers/effectLayer" {
  45273. import { Observable } from "babylonjs/Misc/observable";
  45274. import { Nullable } from "babylonjs/types";
  45275. import { Camera } from "babylonjs/Cameras/camera";
  45276. import { Scene } from "babylonjs/scene";
  45277. import { Color4, ISize } from "babylonjs/Maths/math";
  45278. import { Engine } from "babylonjs/Engines/engine";
  45279. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45281. import { Mesh } from "babylonjs/Meshes/mesh";
  45282. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45284. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45285. import { Effect } from "babylonjs/Materials/effect";
  45286. import { Material } from "babylonjs/Materials/material";
  45287. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45288. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45289. /**
  45290. * Effect layer options. This helps customizing the behaviour
  45291. * of the effect layer.
  45292. */
  45293. export interface IEffectLayerOptions {
  45294. /**
  45295. * Multiplication factor apply to the canvas size to compute the render target size
  45296. * used to generated the objects (the smaller the faster).
  45297. */
  45298. mainTextureRatio: number;
  45299. /**
  45300. * Enforces a fixed size texture to ensure effect stability across devices.
  45301. */
  45302. mainTextureFixedSize?: number;
  45303. /**
  45304. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45305. */
  45306. alphaBlendingMode: number;
  45307. /**
  45308. * The camera attached to the layer.
  45309. */
  45310. camera: Nullable<Camera>;
  45311. /**
  45312. * The rendering group to draw the layer in.
  45313. */
  45314. renderingGroupId: number;
  45315. }
  45316. /**
  45317. * The effect layer Helps adding post process effect blended with the main pass.
  45318. *
  45319. * This can be for instance use to generate glow or higlight effects on the scene.
  45320. *
  45321. * The effect layer class can not be used directly and is intented to inherited from to be
  45322. * customized per effects.
  45323. */
  45324. export abstract class EffectLayer {
  45325. private _vertexBuffers;
  45326. private _indexBuffer;
  45327. private _cachedDefines;
  45328. private _effectLayerMapGenerationEffect;
  45329. private _effectLayerOptions;
  45330. private _mergeEffect;
  45331. protected _scene: Scene;
  45332. protected _engine: Engine;
  45333. protected _maxSize: number;
  45334. protected _mainTextureDesiredSize: ISize;
  45335. protected _mainTexture: RenderTargetTexture;
  45336. protected _shouldRender: boolean;
  45337. protected _postProcesses: PostProcess[];
  45338. protected _textures: BaseTexture[];
  45339. protected _emissiveTextureAndColor: {
  45340. texture: Nullable<BaseTexture>;
  45341. color: Color4;
  45342. };
  45343. /**
  45344. * The name of the layer
  45345. */
  45346. name: string;
  45347. /**
  45348. * The clear color of the texture used to generate the glow map.
  45349. */
  45350. neutralColor: Color4;
  45351. /**
  45352. * Specifies wether the highlight layer is enabled or not.
  45353. */
  45354. isEnabled: boolean;
  45355. /**
  45356. * Gets the camera attached to the layer.
  45357. */
  45358. readonly camera: Nullable<Camera>;
  45359. /**
  45360. * Gets the rendering group id the layer should render in.
  45361. */
  45362. readonly renderingGroupId: number;
  45363. /**
  45364. * An event triggered when the effect layer has been disposed.
  45365. */
  45366. onDisposeObservable: Observable<EffectLayer>;
  45367. /**
  45368. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45369. */
  45370. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45371. /**
  45372. * An event triggered when the generated texture is being merged in the scene.
  45373. */
  45374. onBeforeComposeObservable: Observable<EffectLayer>;
  45375. /**
  45376. * An event triggered when the generated texture has been merged in the scene.
  45377. */
  45378. onAfterComposeObservable: Observable<EffectLayer>;
  45379. /**
  45380. * An event triggered when the efffect layer changes its size.
  45381. */
  45382. onSizeChangedObservable: Observable<EffectLayer>;
  45383. /** @hidden */
  45384. static _SceneComponentInitialization: (scene: Scene) => void;
  45385. /**
  45386. * Instantiates a new effect Layer and references it in the scene.
  45387. * @param name The name of the layer
  45388. * @param scene The scene to use the layer in
  45389. */
  45390. constructor(
  45391. /** The Friendly of the effect in the scene */
  45392. name: string, scene: Scene);
  45393. /**
  45394. * Get the effect name of the layer.
  45395. * @return The effect name
  45396. */
  45397. abstract getEffectName(): string;
  45398. /**
  45399. * Checks for the readiness of the element composing the layer.
  45400. * @param subMesh the mesh to check for
  45401. * @param useInstances specify wether or not to use instances to render the mesh
  45402. * @return true if ready otherwise, false
  45403. */
  45404. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45405. /**
  45406. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45407. * @returns true if the effect requires stencil during the main canvas render pass.
  45408. */
  45409. abstract needStencil(): boolean;
  45410. /**
  45411. * Create the merge effect. This is the shader use to blit the information back
  45412. * to the main canvas at the end of the scene rendering.
  45413. * @returns The effect containing the shader used to merge the effect on the main canvas
  45414. */
  45415. protected abstract _createMergeEffect(): Effect;
  45416. /**
  45417. * Creates the render target textures and post processes used in the effect layer.
  45418. */
  45419. protected abstract _createTextureAndPostProcesses(): void;
  45420. /**
  45421. * Implementation specific of rendering the generating effect on the main canvas.
  45422. * @param effect The effect used to render through
  45423. */
  45424. protected abstract _internalRender(effect: Effect): void;
  45425. /**
  45426. * Sets the required values for both the emissive texture and and the main color.
  45427. */
  45428. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45429. /**
  45430. * Free any resources and references associated to a mesh.
  45431. * Internal use
  45432. * @param mesh The mesh to free.
  45433. */
  45434. abstract _disposeMesh(mesh: Mesh): void;
  45435. /**
  45436. * Serializes this layer (Glow or Highlight for example)
  45437. * @returns a serialized layer object
  45438. */
  45439. abstract serialize?(): any;
  45440. /**
  45441. * Initializes the effect layer with the required options.
  45442. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45443. */
  45444. protected _init(options: Partial<IEffectLayerOptions>): void;
  45445. /**
  45446. * Generates the index buffer of the full screen quad blending to the main canvas.
  45447. */
  45448. private _generateIndexBuffer;
  45449. /**
  45450. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45451. */
  45452. private _genrateVertexBuffer;
  45453. /**
  45454. * Sets the main texture desired size which is the closest power of two
  45455. * of the engine canvas size.
  45456. */
  45457. private _setMainTextureSize;
  45458. /**
  45459. * Creates the main texture for the effect layer.
  45460. */
  45461. protected _createMainTexture(): void;
  45462. /**
  45463. * Adds specific effects defines.
  45464. * @param defines The defines to add specifics to.
  45465. */
  45466. protected _addCustomEffectDefines(defines: string[]): void;
  45467. /**
  45468. * Checks for the readiness of the element composing the layer.
  45469. * @param subMesh the mesh to check for
  45470. * @param useInstances specify wether or not to use instances to render the mesh
  45471. * @param emissiveTexture the associated emissive texture used to generate the glow
  45472. * @return true if ready otherwise, false
  45473. */
  45474. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45475. /**
  45476. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45477. */
  45478. render(): void;
  45479. /**
  45480. * Determine if a given mesh will be used in the current effect.
  45481. * @param mesh mesh to test
  45482. * @returns true if the mesh will be used
  45483. */
  45484. hasMesh(mesh: AbstractMesh): boolean;
  45485. /**
  45486. * Returns true if the layer contains information to display, otherwise false.
  45487. * @returns true if the glow layer should be rendered
  45488. */
  45489. shouldRender(): boolean;
  45490. /**
  45491. * Returns true if the mesh should render, otherwise false.
  45492. * @param mesh The mesh to render
  45493. * @returns true if it should render otherwise false
  45494. */
  45495. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45496. /**
  45497. * Returns true if the mesh can be rendered, otherwise false.
  45498. * @param mesh The mesh to render
  45499. * @param material The material used on the mesh
  45500. * @returns true if it can be rendered otherwise false
  45501. */
  45502. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45503. /**
  45504. * Returns true if the mesh should render, otherwise false.
  45505. * @param mesh The mesh to render
  45506. * @returns true if it should render otherwise false
  45507. */
  45508. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45509. /**
  45510. * Renders the submesh passed in parameter to the generation map.
  45511. */
  45512. protected _renderSubMesh(subMesh: SubMesh): void;
  45513. /**
  45514. * Rebuild the required buffers.
  45515. * @hidden Internal use only.
  45516. */
  45517. _rebuild(): void;
  45518. /**
  45519. * Dispose only the render target textures and post process.
  45520. */
  45521. private _disposeTextureAndPostProcesses;
  45522. /**
  45523. * Dispose the highlight layer and free resources.
  45524. */
  45525. dispose(): void;
  45526. /**
  45527. * Gets the class name of the effect layer
  45528. * @returns the string with the class name of the effect layer
  45529. */
  45530. getClassName(): string;
  45531. /**
  45532. * Creates an effect layer from parsed effect layer data
  45533. * @param parsedEffectLayer defines effect layer data
  45534. * @param scene defines the current scene
  45535. * @param rootUrl defines the root URL containing the effect layer information
  45536. * @returns a parsed effect Layer
  45537. */
  45538. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45539. }
  45540. }
  45541. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45542. import { Scene } from "babylonjs/scene";
  45543. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45544. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45545. import { AbstractScene } from "babylonjs/abstractScene";
  45546. module "babylonjs/abstractScene" {
  45547. interface AbstractScene {
  45548. /**
  45549. * The list of effect layers (highlights/glow) added to the scene
  45550. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45551. * @see http://doc.babylonjs.com/how_to/glow_layer
  45552. */
  45553. effectLayers: Array<EffectLayer>;
  45554. /**
  45555. * Removes the given effect layer from this scene.
  45556. * @param toRemove defines the effect layer to remove
  45557. * @returns the index of the removed effect layer
  45558. */
  45559. removeEffectLayer(toRemove: EffectLayer): number;
  45560. /**
  45561. * Adds the given effect layer to this scene
  45562. * @param newEffectLayer defines the effect layer to add
  45563. */
  45564. addEffectLayer(newEffectLayer: EffectLayer): void;
  45565. }
  45566. }
  45567. /**
  45568. * Defines the layer scene component responsible to manage any effect layers
  45569. * in a given scene.
  45570. */
  45571. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45572. /**
  45573. * The component name helpfull to identify the component in the list of scene components.
  45574. */
  45575. readonly name: string;
  45576. /**
  45577. * The scene the component belongs to.
  45578. */
  45579. scene: Scene;
  45580. private _engine;
  45581. private _renderEffects;
  45582. private _needStencil;
  45583. private _previousStencilState;
  45584. /**
  45585. * Creates a new instance of the component for the given scene
  45586. * @param scene Defines the scene to register the component in
  45587. */
  45588. constructor(scene: Scene);
  45589. /**
  45590. * Registers the component in a given scene
  45591. */
  45592. register(): void;
  45593. /**
  45594. * Rebuilds the elements related to this component in case of
  45595. * context lost for instance.
  45596. */
  45597. rebuild(): void;
  45598. /**
  45599. * Serializes the component data to the specified json object
  45600. * @param serializationObject The object to serialize to
  45601. */
  45602. serialize(serializationObject: any): void;
  45603. /**
  45604. * Adds all the element from the container to the scene
  45605. * @param container the container holding the elements
  45606. */
  45607. addFromContainer(container: AbstractScene): void;
  45608. /**
  45609. * Removes all the elements in the container from the scene
  45610. * @param container contains the elements to remove
  45611. */
  45612. removeFromContainer(container: AbstractScene): void;
  45613. /**
  45614. * Disposes the component and the associated ressources.
  45615. */
  45616. dispose(): void;
  45617. private _isReadyForMesh;
  45618. private _renderMainTexture;
  45619. private _setStencil;
  45620. private _setStencilBack;
  45621. private _draw;
  45622. private _drawCamera;
  45623. private _drawRenderingGroup;
  45624. }
  45625. }
  45626. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45627. /** @hidden */
  45628. export var glowMapMergePixelShader: {
  45629. name: string;
  45630. shader: string;
  45631. };
  45632. }
  45633. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45634. /** @hidden */
  45635. export var glowMapMergeVertexShader: {
  45636. name: string;
  45637. shader: string;
  45638. };
  45639. }
  45640. declare module "babylonjs/Layers/glowLayer" {
  45641. import { Nullable } from "babylonjs/types";
  45642. import { Camera } from "babylonjs/Cameras/camera";
  45643. import { Scene } from "babylonjs/scene";
  45644. import { Color4 } from "babylonjs/Maths/math";
  45645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45647. import { Mesh } from "babylonjs/Meshes/mesh";
  45648. import { Texture } from "babylonjs/Materials/Textures/texture";
  45649. import { Effect } from "babylonjs/Materials/effect";
  45650. import { Material } from "babylonjs/Materials/material";
  45651. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45652. import "babylonjs/Shaders/glowMapMerge.fragment";
  45653. import "babylonjs/Shaders/glowMapMerge.vertex";
  45654. module "babylonjs/abstractScene" {
  45655. interface AbstractScene {
  45656. /**
  45657. * Return a the first highlight layer of the scene with a given name.
  45658. * @param name The name of the highlight layer to look for.
  45659. * @return The highlight layer if found otherwise null.
  45660. */
  45661. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45662. }
  45663. }
  45664. /**
  45665. * Glow layer options. This helps customizing the behaviour
  45666. * of the glow layer.
  45667. */
  45668. export interface IGlowLayerOptions {
  45669. /**
  45670. * Multiplication factor apply to the canvas size to compute the render target size
  45671. * used to generated the glowing objects (the smaller the faster).
  45672. */
  45673. mainTextureRatio: number;
  45674. /**
  45675. * Enforces a fixed size texture to ensure resize independant blur.
  45676. */
  45677. mainTextureFixedSize?: number;
  45678. /**
  45679. * How big is the kernel of the blur texture.
  45680. */
  45681. blurKernelSize: number;
  45682. /**
  45683. * The camera attached to the layer.
  45684. */
  45685. camera: Nullable<Camera>;
  45686. /**
  45687. * Enable MSAA by chosing the number of samples.
  45688. */
  45689. mainTextureSamples?: number;
  45690. /**
  45691. * The rendering group to draw the layer in.
  45692. */
  45693. renderingGroupId: number;
  45694. }
  45695. /**
  45696. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45697. *
  45698. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45699. * glowy meshes to your scene.
  45700. *
  45701. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45702. */
  45703. export class GlowLayer extends EffectLayer {
  45704. /**
  45705. * Effect Name of the layer.
  45706. */
  45707. static readonly EffectName: string;
  45708. /**
  45709. * The default blur kernel size used for the glow.
  45710. */
  45711. static DefaultBlurKernelSize: number;
  45712. /**
  45713. * The default texture size ratio used for the glow.
  45714. */
  45715. static DefaultTextureRatio: number;
  45716. /**
  45717. * Sets the kernel size of the blur.
  45718. */
  45719. /**
  45720. * Gets the kernel size of the blur.
  45721. */
  45722. blurKernelSize: number;
  45723. /**
  45724. * Sets the glow intensity.
  45725. */
  45726. /**
  45727. * Gets the glow intensity.
  45728. */
  45729. intensity: number;
  45730. private _options;
  45731. private _intensity;
  45732. private _horizontalBlurPostprocess1;
  45733. private _verticalBlurPostprocess1;
  45734. private _horizontalBlurPostprocess2;
  45735. private _verticalBlurPostprocess2;
  45736. private _blurTexture1;
  45737. private _blurTexture2;
  45738. private _postProcesses1;
  45739. private _postProcesses2;
  45740. private _includedOnlyMeshes;
  45741. private _excludedMeshes;
  45742. /**
  45743. * Callback used to let the user override the color selection on a per mesh basis
  45744. */
  45745. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45746. /**
  45747. * Callback used to let the user override the texture selection on a per mesh basis
  45748. */
  45749. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45750. /**
  45751. * Instantiates a new glow Layer and references it to the scene.
  45752. * @param name The name of the layer
  45753. * @param scene The scene to use the layer in
  45754. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45755. */
  45756. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45757. /**
  45758. * Get the effect name of the layer.
  45759. * @return The effect name
  45760. */
  45761. getEffectName(): string;
  45762. /**
  45763. * Create the merge effect. This is the shader use to blit the information back
  45764. * to the main canvas at the end of the scene rendering.
  45765. */
  45766. protected _createMergeEffect(): Effect;
  45767. /**
  45768. * Creates the render target textures and post processes used in the glow layer.
  45769. */
  45770. protected _createTextureAndPostProcesses(): void;
  45771. /**
  45772. * Checks for the readiness of the element composing the layer.
  45773. * @param subMesh the mesh to check for
  45774. * @param useInstances specify wether or not to use instances to render the mesh
  45775. * @param emissiveTexture the associated emissive texture used to generate the glow
  45776. * @return true if ready otherwise, false
  45777. */
  45778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45779. /**
  45780. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45781. */
  45782. needStencil(): boolean;
  45783. /**
  45784. * Returns true if the mesh can be rendered, otherwise false.
  45785. * @param mesh The mesh to render
  45786. * @param material The material used on the mesh
  45787. * @returns true if it can be rendered otherwise false
  45788. */
  45789. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45790. /**
  45791. * Implementation specific of rendering the generating effect on the main canvas.
  45792. * @param effect The effect used to render through
  45793. */
  45794. protected _internalRender(effect: Effect): void;
  45795. /**
  45796. * Sets the required values for both the emissive texture and and the main color.
  45797. */
  45798. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45799. /**
  45800. * Returns true if the mesh should render, otherwise false.
  45801. * @param mesh The mesh to render
  45802. * @returns true if it should render otherwise false
  45803. */
  45804. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45805. /**
  45806. * Adds specific effects defines.
  45807. * @param defines The defines to add specifics to.
  45808. */
  45809. protected _addCustomEffectDefines(defines: string[]): void;
  45810. /**
  45811. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45812. * @param mesh The mesh to exclude from the glow layer
  45813. */
  45814. addExcludedMesh(mesh: Mesh): void;
  45815. /**
  45816. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45817. * @param mesh The mesh to remove
  45818. */
  45819. removeExcludedMesh(mesh: Mesh): void;
  45820. /**
  45821. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45822. * @param mesh The mesh to include in the glow layer
  45823. */
  45824. addIncludedOnlyMesh(mesh: Mesh): void;
  45825. /**
  45826. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45827. * @param mesh The mesh to remove
  45828. */
  45829. removeIncludedOnlyMesh(mesh: Mesh): void;
  45830. /**
  45831. * Determine if a given mesh will be used in the glow layer
  45832. * @param mesh The mesh to test
  45833. * @returns true if the mesh will be highlighted by the current glow layer
  45834. */
  45835. hasMesh(mesh: AbstractMesh): boolean;
  45836. /**
  45837. * Free any resources and references associated to a mesh.
  45838. * Internal use
  45839. * @param mesh The mesh to free.
  45840. * @hidden
  45841. */
  45842. _disposeMesh(mesh: Mesh): void;
  45843. /**
  45844. * Gets the class name of the effect layer
  45845. * @returns the string with the class name of the effect layer
  45846. */
  45847. getClassName(): string;
  45848. /**
  45849. * Serializes this glow layer
  45850. * @returns a serialized glow layer object
  45851. */
  45852. serialize(): any;
  45853. /**
  45854. * Creates a Glow Layer from parsed glow layer data
  45855. * @param parsedGlowLayer defines glow layer data
  45856. * @param scene defines the current scene
  45857. * @param rootUrl defines the root URL containing the glow layer information
  45858. * @returns a parsed Glow Layer
  45859. */
  45860. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45861. }
  45862. }
  45863. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45864. /** @hidden */
  45865. export var glowBlurPostProcessPixelShader: {
  45866. name: string;
  45867. shader: string;
  45868. };
  45869. }
  45870. declare module "babylonjs/Layers/highlightLayer" {
  45871. import { Observable } from "babylonjs/Misc/observable";
  45872. import { Nullable } from "babylonjs/types";
  45873. import { Camera } from "babylonjs/Cameras/camera";
  45874. import { Scene } from "babylonjs/scene";
  45875. import { Color3, Color4 } from "babylonjs/Maths/math";
  45876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45878. import { Mesh } from "babylonjs/Meshes/mesh";
  45879. import { Effect } from "babylonjs/Materials/effect";
  45880. import { Material } from "babylonjs/Materials/material";
  45881. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45882. import "babylonjs/Shaders/glowMapMerge.fragment";
  45883. import "babylonjs/Shaders/glowMapMerge.vertex";
  45884. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  45885. module "babylonjs/abstractScene" {
  45886. interface AbstractScene {
  45887. /**
  45888. * Return a the first highlight layer of the scene with a given name.
  45889. * @param name The name of the highlight layer to look for.
  45890. * @return The highlight layer if found otherwise null.
  45891. */
  45892. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45893. }
  45894. }
  45895. /**
  45896. * Highlight layer options. This helps customizing the behaviour
  45897. * of the highlight layer.
  45898. */
  45899. export interface IHighlightLayerOptions {
  45900. /**
  45901. * Multiplication factor apply to the canvas size to compute the render target size
  45902. * used to generated the glowing objects (the smaller the faster).
  45903. */
  45904. mainTextureRatio: number;
  45905. /**
  45906. * Enforces a fixed size texture to ensure resize independant blur.
  45907. */
  45908. mainTextureFixedSize?: number;
  45909. /**
  45910. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45911. * of the picture to blur (the smaller the faster).
  45912. */
  45913. blurTextureSizeRatio: number;
  45914. /**
  45915. * How big in texel of the blur texture is the vertical blur.
  45916. */
  45917. blurVerticalSize: number;
  45918. /**
  45919. * How big in texel of the blur texture is the horizontal blur.
  45920. */
  45921. blurHorizontalSize: number;
  45922. /**
  45923. * Alpha blending mode used to apply the blur. Default is combine.
  45924. */
  45925. alphaBlendingMode: number;
  45926. /**
  45927. * The camera attached to the layer.
  45928. */
  45929. camera: Nullable<Camera>;
  45930. /**
  45931. * Should we display highlight as a solid stroke?
  45932. */
  45933. isStroke?: boolean;
  45934. /**
  45935. * The rendering group to draw the layer in.
  45936. */
  45937. renderingGroupId: number;
  45938. }
  45939. /**
  45940. * The highlight layer Helps adding a glow effect around a mesh.
  45941. *
  45942. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45943. * glowy meshes to your scene.
  45944. *
  45945. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  45946. */
  45947. export class HighlightLayer extends EffectLayer {
  45948. name: string;
  45949. /**
  45950. * Effect Name of the highlight layer.
  45951. */
  45952. static readonly EffectName: string;
  45953. /**
  45954. * The neutral color used during the preparation of the glow effect.
  45955. * This is black by default as the blend operation is a blend operation.
  45956. */
  45957. static NeutralColor: Color4;
  45958. /**
  45959. * Stencil value used for glowing meshes.
  45960. */
  45961. static GlowingMeshStencilReference: number;
  45962. /**
  45963. * Stencil value used for the other meshes in the scene.
  45964. */
  45965. static NormalMeshStencilReference: number;
  45966. /**
  45967. * Specifies whether or not the inner glow is ACTIVE in the layer.
  45968. */
  45969. innerGlow: boolean;
  45970. /**
  45971. * Specifies whether or not the outer glow is ACTIVE in the layer.
  45972. */
  45973. outerGlow: boolean;
  45974. /**
  45975. * Specifies the horizontal size of the blur.
  45976. */
  45977. /**
  45978. * Gets the horizontal size of the blur.
  45979. */
  45980. blurHorizontalSize: number;
  45981. /**
  45982. * Specifies the vertical size of the blur.
  45983. */
  45984. /**
  45985. * Gets the vertical size of the blur.
  45986. */
  45987. blurVerticalSize: number;
  45988. /**
  45989. * An event triggered when the highlight layer is being blurred.
  45990. */
  45991. onBeforeBlurObservable: Observable<HighlightLayer>;
  45992. /**
  45993. * An event triggered when the highlight layer has been blurred.
  45994. */
  45995. onAfterBlurObservable: Observable<HighlightLayer>;
  45996. private _instanceGlowingMeshStencilReference;
  45997. private _options;
  45998. private _downSamplePostprocess;
  45999. private _horizontalBlurPostprocess;
  46000. private _verticalBlurPostprocess;
  46001. private _blurTexture;
  46002. private _meshes;
  46003. private _excludedMeshes;
  46004. /**
  46005. * Instantiates a new highlight Layer and references it to the scene..
  46006. * @param name The name of the layer
  46007. * @param scene The scene to use the layer in
  46008. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46009. */
  46010. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46011. /**
  46012. * Get the effect name of the layer.
  46013. * @return The effect name
  46014. */
  46015. getEffectName(): string;
  46016. /**
  46017. * Create the merge effect. This is the shader use to blit the information back
  46018. * to the main canvas at the end of the scene rendering.
  46019. */
  46020. protected _createMergeEffect(): Effect;
  46021. /**
  46022. * Creates the render target textures and post processes used in the highlight layer.
  46023. */
  46024. protected _createTextureAndPostProcesses(): void;
  46025. /**
  46026. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46027. */
  46028. needStencil(): boolean;
  46029. /**
  46030. * Checks for the readiness of the element composing the layer.
  46031. * @param subMesh the mesh to check for
  46032. * @param useInstances specify wether or not to use instances to render the mesh
  46033. * @param emissiveTexture the associated emissive texture used to generate the glow
  46034. * @return true if ready otherwise, false
  46035. */
  46036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46037. /**
  46038. * Implementation specific of rendering the generating effect on the main canvas.
  46039. * @param effect The effect used to render through
  46040. */
  46041. protected _internalRender(effect: Effect): void;
  46042. /**
  46043. * Returns true if the layer contains information to display, otherwise false.
  46044. */
  46045. shouldRender(): boolean;
  46046. /**
  46047. * Returns true if the mesh should render, otherwise false.
  46048. * @param mesh The mesh to render
  46049. * @returns true if it should render otherwise false
  46050. */
  46051. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46052. /**
  46053. * Sets the required values for both the emissive texture and and the main color.
  46054. */
  46055. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46056. /**
  46057. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46058. * @param mesh The mesh to exclude from the highlight layer
  46059. */
  46060. addExcludedMesh(mesh: Mesh): void;
  46061. /**
  46062. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46063. * @param mesh The mesh to highlight
  46064. */
  46065. removeExcludedMesh(mesh: Mesh): void;
  46066. /**
  46067. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46068. * @param mesh mesh to test
  46069. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46070. */
  46071. hasMesh(mesh: AbstractMesh): boolean;
  46072. /**
  46073. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46074. * @param mesh The mesh to highlight
  46075. * @param color The color of the highlight
  46076. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46077. */
  46078. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46079. /**
  46080. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46081. * @param mesh The mesh to highlight
  46082. */
  46083. removeMesh(mesh: Mesh): void;
  46084. /**
  46085. * Force the stencil to the normal expected value for none glowing parts
  46086. */
  46087. private _defaultStencilReference;
  46088. /**
  46089. * Free any resources and references associated to a mesh.
  46090. * Internal use
  46091. * @param mesh The mesh to free.
  46092. * @hidden
  46093. */
  46094. _disposeMesh(mesh: Mesh): void;
  46095. /**
  46096. * Dispose the highlight layer and free resources.
  46097. */
  46098. dispose(): void;
  46099. /**
  46100. * Gets the class name of the effect layer
  46101. * @returns the string with the class name of the effect layer
  46102. */
  46103. getClassName(): string;
  46104. /**
  46105. * Serializes this Highlight layer
  46106. * @returns a serialized Highlight layer object
  46107. */
  46108. serialize(): any;
  46109. /**
  46110. * Creates a Highlight layer from parsed Highlight layer data
  46111. * @param parsedHightlightLayer defines the Highlight layer data
  46112. * @param scene defines the current scene
  46113. * @param rootUrl defines the root URL containing the Highlight layer information
  46114. * @returns a parsed Highlight layer
  46115. */
  46116. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46117. }
  46118. }
  46119. declare module "babylonjs/Layers/index" {
  46120. export * from "babylonjs/Layers/effectLayer";
  46121. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46122. export * from "babylonjs/Layers/glowLayer";
  46123. export * from "babylonjs/Layers/highlightLayer";
  46124. export * from "babylonjs/Layers/layer";
  46125. export * from "babylonjs/Layers/layerSceneComponent";
  46126. }
  46127. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46128. /** @hidden */
  46129. export var lensFlarePixelShader: {
  46130. name: string;
  46131. shader: string;
  46132. };
  46133. }
  46134. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46135. /** @hidden */
  46136. export var lensFlareVertexShader: {
  46137. name: string;
  46138. shader: string;
  46139. };
  46140. }
  46141. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46142. import { Scene } from "babylonjs/scene";
  46143. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46145. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46146. import "babylonjs/Shaders/lensFlare.fragment";
  46147. import "babylonjs/Shaders/lensFlare.vertex";
  46148. /**
  46149. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46150. * It is usually composed of several `lensFlare`.
  46151. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46152. */
  46153. export class LensFlareSystem {
  46154. /**
  46155. * Define the name of the lens flare system
  46156. */
  46157. name: string;
  46158. /**
  46159. * List of lens flares used in this system.
  46160. */
  46161. lensFlares: LensFlare[];
  46162. /**
  46163. * Define a limit from the border the lens flare can be visible.
  46164. */
  46165. borderLimit: number;
  46166. /**
  46167. * Define a viewport border we do not want to see the lens flare in.
  46168. */
  46169. viewportBorder: number;
  46170. /**
  46171. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46172. */
  46173. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46174. /**
  46175. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46176. */
  46177. layerMask: number;
  46178. /**
  46179. * Define the id of the lens flare system in the scene.
  46180. * (equal to name by default)
  46181. */
  46182. id: string;
  46183. private _scene;
  46184. private _emitter;
  46185. private _vertexBuffers;
  46186. private _indexBuffer;
  46187. private _effect;
  46188. private _positionX;
  46189. private _positionY;
  46190. private _isEnabled;
  46191. /** @hidden */
  46192. static _SceneComponentInitialization: (scene: Scene) => void;
  46193. /**
  46194. * Instantiates a lens flare system.
  46195. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46196. * It is usually composed of several `lensFlare`.
  46197. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46198. * @param name Define the name of the lens flare system in the scene
  46199. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46200. * @param scene Define the scene the lens flare system belongs to
  46201. */
  46202. constructor(
  46203. /**
  46204. * Define the name of the lens flare system
  46205. */
  46206. name: string, emitter: any, scene: Scene);
  46207. /**
  46208. * Define if the lens flare system is enabled.
  46209. */
  46210. isEnabled: boolean;
  46211. /**
  46212. * Get the scene the effects belongs to.
  46213. * @returns the scene holding the lens flare system
  46214. */
  46215. getScene(): Scene;
  46216. /**
  46217. * Get the emitter of the lens flare system.
  46218. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46219. * @returns the emitter of the lens flare system
  46220. */
  46221. getEmitter(): any;
  46222. /**
  46223. * Set the emitter of the lens flare system.
  46224. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46225. * @param newEmitter Define the new emitter of the system
  46226. */
  46227. setEmitter(newEmitter: any): void;
  46228. /**
  46229. * Get the lens flare system emitter position.
  46230. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46231. * @returns the position
  46232. */
  46233. getEmitterPosition(): Vector3;
  46234. /**
  46235. * @hidden
  46236. */
  46237. computeEffectivePosition(globalViewport: Viewport): boolean;
  46238. /** @hidden */
  46239. _isVisible(): boolean;
  46240. /**
  46241. * @hidden
  46242. */
  46243. render(): boolean;
  46244. /**
  46245. * Dispose and release the lens flare with its associated resources.
  46246. */
  46247. dispose(): void;
  46248. /**
  46249. * Parse a lens flare system from a JSON repressentation
  46250. * @param parsedLensFlareSystem Define the JSON to parse
  46251. * @param scene Define the scene the parsed system should be instantiated in
  46252. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46253. * @returns the parsed system
  46254. */
  46255. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46256. /**
  46257. * Serialize the current Lens Flare System into a JSON representation.
  46258. * @returns the serialized JSON
  46259. */
  46260. serialize(): any;
  46261. }
  46262. }
  46263. declare module "babylonjs/LensFlares/lensFlare" {
  46264. import { Nullable } from "babylonjs/types";
  46265. import { Color3 } from "babylonjs/Maths/math";
  46266. import { Texture } from "babylonjs/Materials/Textures/texture";
  46267. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46268. /**
  46269. * This represents one of the lens effect in a `lensFlareSystem`.
  46270. * It controls one of the indiviual texture used in the effect.
  46271. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46272. */
  46273. export class LensFlare {
  46274. /**
  46275. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46276. */
  46277. size: number;
  46278. /**
  46279. * 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.
  46280. */
  46281. position: number;
  46282. /**
  46283. * Define the lens color.
  46284. */
  46285. color: Color3;
  46286. /**
  46287. * Define the lens texture.
  46288. */
  46289. texture: Nullable<Texture>;
  46290. /**
  46291. * Define the alpha mode to render this particular lens.
  46292. */
  46293. alphaMode: number;
  46294. private _system;
  46295. /**
  46296. * Creates a new Lens Flare.
  46297. * This represents one of the lens effect in a `lensFlareSystem`.
  46298. * It controls one of the indiviual texture used in the effect.
  46299. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46300. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46301. * @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.
  46302. * @param color Define the lens color
  46303. * @param imgUrl Define the lens texture url
  46304. * @param system Define the `lensFlareSystem` this flare is part of
  46305. * @returns The newly created Lens Flare
  46306. */
  46307. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46308. /**
  46309. * Instantiates a new Lens Flare.
  46310. * This represents one of the lens effect in a `lensFlareSystem`.
  46311. * It controls one of the indiviual texture used in the effect.
  46312. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46313. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46314. * @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.
  46315. * @param color Define the lens color
  46316. * @param imgUrl Define the lens texture url
  46317. * @param system Define the `lensFlareSystem` this flare is part of
  46318. */
  46319. constructor(
  46320. /**
  46321. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46322. */
  46323. size: number,
  46324. /**
  46325. * 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.
  46326. */
  46327. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46328. /**
  46329. * Dispose and release the lens flare with its associated resources.
  46330. */
  46331. dispose(): void;
  46332. }
  46333. }
  46334. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46335. import { Nullable } from "babylonjs/types";
  46336. import { Scene } from "babylonjs/scene";
  46337. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46338. import { AbstractScene } from "babylonjs/abstractScene";
  46339. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46340. module "babylonjs/abstractScene" {
  46341. interface AbstractScene {
  46342. /**
  46343. * The list of lens flare system added to the scene
  46344. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46345. */
  46346. lensFlareSystems: Array<LensFlareSystem>;
  46347. /**
  46348. * Removes the given lens flare system from this scene.
  46349. * @param toRemove The lens flare system to remove
  46350. * @returns The index of the removed lens flare system
  46351. */
  46352. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46353. /**
  46354. * Adds the given lens flare system to this scene
  46355. * @param newLensFlareSystem The lens flare system to add
  46356. */
  46357. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46358. /**
  46359. * Gets a lens flare system using its name
  46360. * @param name defines the name to look for
  46361. * @returns the lens flare system or null if not found
  46362. */
  46363. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46364. /**
  46365. * Gets a lens flare system using its id
  46366. * @param id defines the id to look for
  46367. * @returns the lens flare system or null if not found
  46368. */
  46369. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46370. }
  46371. }
  46372. /**
  46373. * Defines the lens flare scene component responsible to manage any lens flares
  46374. * in a given scene.
  46375. */
  46376. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46377. /**
  46378. * The component name helpfull to identify the component in the list of scene components.
  46379. */
  46380. readonly name: string;
  46381. /**
  46382. * The scene the component belongs to.
  46383. */
  46384. scene: Scene;
  46385. /**
  46386. * Creates a new instance of the component for the given scene
  46387. * @param scene Defines the scene to register the component in
  46388. */
  46389. constructor(scene: Scene);
  46390. /**
  46391. * Registers the component in a given scene
  46392. */
  46393. register(): void;
  46394. /**
  46395. * Rebuilds the elements related to this component in case of
  46396. * context lost for instance.
  46397. */
  46398. rebuild(): void;
  46399. /**
  46400. * Adds all the element from the container to the scene
  46401. * @param container the container holding the elements
  46402. */
  46403. addFromContainer(container: AbstractScene): void;
  46404. /**
  46405. * Removes all the elements in the container from the scene
  46406. * @param container contains the elements to remove
  46407. */
  46408. removeFromContainer(container: AbstractScene): void;
  46409. /**
  46410. * Serializes the component data to the specified json object
  46411. * @param serializationObject The object to serialize to
  46412. */
  46413. serialize(serializationObject: any): void;
  46414. /**
  46415. * Disposes the component and the associated ressources.
  46416. */
  46417. dispose(): void;
  46418. private _draw;
  46419. }
  46420. }
  46421. declare module "babylonjs/LensFlares/index" {
  46422. export * from "babylonjs/LensFlares/lensFlare";
  46423. export * from "babylonjs/LensFlares/lensFlareSystem";
  46424. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46425. }
  46426. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46427. import { Scene } from "babylonjs/scene";
  46428. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46429. import { AbstractScene } from "babylonjs/abstractScene";
  46430. /**
  46431. * Defines the shadow generator component responsible to manage any shadow generators
  46432. * in a given scene.
  46433. */
  46434. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46435. /**
  46436. * The component name helpfull to identify the component in the list of scene components.
  46437. */
  46438. readonly name: string;
  46439. /**
  46440. * The scene the component belongs to.
  46441. */
  46442. scene: Scene;
  46443. /**
  46444. * Creates a new instance of the component for the given scene
  46445. * @param scene Defines the scene to register the component in
  46446. */
  46447. constructor(scene: Scene);
  46448. /**
  46449. * Registers the component in a given scene
  46450. */
  46451. register(): void;
  46452. /**
  46453. * Rebuilds the elements related to this component in case of
  46454. * context lost for instance.
  46455. */
  46456. rebuild(): void;
  46457. /**
  46458. * Serializes the component data to the specified json object
  46459. * @param serializationObject The object to serialize to
  46460. */
  46461. serialize(serializationObject: any): void;
  46462. /**
  46463. * Adds all the element from the container to the scene
  46464. * @param container the container holding the elements
  46465. */
  46466. addFromContainer(container: AbstractScene): void;
  46467. /**
  46468. * Removes all the elements in the container from the scene
  46469. * @param container contains the elements to remove
  46470. */
  46471. removeFromContainer(container: AbstractScene): void;
  46472. /**
  46473. * Rebuilds the elements related to this component in case of
  46474. * context lost for instance.
  46475. */
  46476. dispose(): void;
  46477. private _gatherRenderTargets;
  46478. }
  46479. }
  46480. declare module "babylonjs/Lights/Shadows/index" {
  46481. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46482. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46483. }
  46484. declare module "babylonjs/Lights/directionalLight" {
  46485. import { Camera } from "babylonjs/Cameras/camera";
  46486. import { Scene } from "babylonjs/scene";
  46487. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46489. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46490. import { Effect } from "babylonjs/Materials/effect";
  46491. /**
  46492. * A directional light is defined by a direction (what a surprise!).
  46493. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46494. * 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.
  46495. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46496. */
  46497. export class DirectionalLight extends ShadowLight {
  46498. private _shadowFrustumSize;
  46499. /**
  46500. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46501. */
  46502. /**
  46503. * Specifies a fix frustum size for the shadow generation.
  46504. */
  46505. shadowFrustumSize: number;
  46506. private _shadowOrthoScale;
  46507. /**
  46508. * Gets the shadow projection scale against the optimal computed one.
  46509. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46510. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46511. */
  46512. /**
  46513. * Sets the shadow projection scale against the optimal computed one.
  46514. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46515. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46516. */
  46517. shadowOrthoScale: number;
  46518. /**
  46519. * Automatically compute the projection matrix to best fit (including all the casters)
  46520. * on each frame.
  46521. */
  46522. autoUpdateExtends: boolean;
  46523. private _orthoLeft;
  46524. private _orthoRight;
  46525. private _orthoTop;
  46526. private _orthoBottom;
  46527. /**
  46528. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46529. * The directional light is emitted from everywhere in the given direction.
  46530. * It can cast shadows.
  46531. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46532. * @param name The friendly name of the light
  46533. * @param direction The direction of the light
  46534. * @param scene The scene the light belongs to
  46535. */
  46536. constructor(name: string, direction: Vector3, scene: Scene);
  46537. /**
  46538. * Returns the string "DirectionalLight".
  46539. * @return The class name
  46540. */
  46541. getClassName(): string;
  46542. /**
  46543. * Returns the integer 1.
  46544. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46545. */
  46546. getTypeID(): number;
  46547. /**
  46548. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46549. * Returns the DirectionalLight Shadow projection matrix.
  46550. */
  46551. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46552. /**
  46553. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46554. * Returns the DirectionalLight Shadow projection matrix.
  46555. */
  46556. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46557. /**
  46558. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46559. * Returns the DirectionalLight Shadow projection matrix.
  46560. */
  46561. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46562. protected _buildUniformLayout(): void;
  46563. /**
  46564. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46565. * @param effect The effect to update
  46566. * @param lightIndex The index of the light in the effect to update
  46567. * @returns The directional light
  46568. */
  46569. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46570. /**
  46571. * Gets the minZ used for shadow according to both the scene and the light.
  46572. *
  46573. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46574. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46575. * @param activeCamera The camera we are returning the min for
  46576. * @returns the depth min z
  46577. */
  46578. getDepthMinZ(activeCamera: Camera): number;
  46579. /**
  46580. * Gets the maxZ used for shadow according to both the scene and the light.
  46581. *
  46582. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46583. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46584. * @param activeCamera The camera we are returning the max for
  46585. * @returns the depth max z
  46586. */
  46587. getDepthMaxZ(activeCamera: Camera): number;
  46588. /**
  46589. * Prepares the list of defines specific to the light type.
  46590. * @param defines the list of defines
  46591. * @param lightIndex defines the index of the light for the effect
  46592. */
  46593. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46594. }
  46595. }
  46596. declare module "babylonjs/Lights/pointLight" {
  46597. import { Scene } from "babylonjs/scene";
  46598. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46600. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46601. import { Effect } from "babylonjs/Materials/effect";
  46602. /**
  46603. * A point light is a light defined by an unique point in world space.
  46604. * The light is emitted in every direction from this point.
  46605. * A good example of a point light is a standard light bulb.
  46606. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46607. */
  46608. export class PointLight extends ShadowLight {
  46609. private _shadowAngle;
  46610. /**
  46611. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46612. * This specifies what angle the shadow will use to be created.
  46613. *
  46614. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46615. */
  46616. /**
  46617. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46618. * This specifies what angle the shadow will use to be created.
  46619. *
  46620. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46621. */
  46622. shadowAngle: number;
  46623. /**
  46624. * Gets the direction if it has been set.
  46625. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46626. */
  46627. /**
  46628. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46629. */
  46630. direction: Vector3;
  46631. /**
  46632. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46633. * A PointLight emits the light in every direction.
  46634. * It can cast shadows.
  46635. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46636. * ```javascript
  46637. * var pointLight = new PointLight("pl", camera.position, scene);
  46638. * ```
  46639. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46640. * @param name The light friendly name
  46641. * @param position The position of the point light in the scene
  46642. * @param scene The scene the lights belongs to
  46643. */
  46644. constructor(name: string, position: Vector3, scene: Scene);
  46645. /**
  46646. * Returns the string "PointLight"
  46647. * @returns the class name
  46648. */
  46649. getClassName(): string;
  46650. /**
  46651. * Returns the integer 0.
  46652. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46653. */
  46654. getTypeID(): number;
  46655. /**
  46656. * Specifies wether or not the shadowmap should be a cube texture.
  46657. * @returns true if the shadowmap needs to be a cube texture.
  46658. */
  46659. needCube(): boolean;
  46660. /**
  46661. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46662. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46663. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46664. */
  46665. getShadowDirection(faceIndex?: number): Vector3;
  46666. /**
  46667. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46668. * - fov = PI / 2
  46669. * - aspect ratio : 1.0
  46670. * - z-near and far equal to the active camera minZ and maxZ.
  46671. * Returns the PointLight.
  46672. */
  46673. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46674. protected _buildUniformLayout(): void;
  46675. /**
  46676. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46677. * @param effect The effect to update
  46678. * @param lightIndex The index of the light in the effect to update
  46679. * @returns The point light
  46680. */
  46681. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46682. /**
  46683. * Prepares the list of defines specific to the light type.
  46684. * @param defines the list of defines
  46685. * @param lightIndex defines the index of the light for the effect
  46686. */
  46687. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46688. }
  46689. }
  46690. declare module "babylonjs/Lights/spotLight" {
  46691. import { Nullable } from "babylonjs/types";
  46692. import { Scene } from "babylonjs/scene";
  46693. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46695. import { Effect } from "babylonjs/Materials/effect";
  46696. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46697. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46698. /**
  46699. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46700. * These values define a cone of light starting from the position, emitting toward the direction.
  46701. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46702. * and the exponent defines the speed of the decay of the light with distance (reach).
  46703. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46704. */
  46705. export class SpotLight extends ShadowLight {
  46706. private _angle;
  46707. private _innerAngle;
  46708. private _cosHalfAngle;
  46709. private _lightAngleScale;
  46710. private _lightAngleOffset;
  46711. /**
  46712. * Gets the cone angle of the spot light in Radians.
  46713. */
  46714. /**
  46715. * Sets the cone angle of the spot light in Radians.
  46716. */
  46717. angle: number;
  46718. /**
  46719. * Only used in gltf falloff mode, this defines the angle where
  46720. * the directional falloff will start before cutting at angle which could be seen
  46721. * as outer angle.
  46722. */
  46723. /**
  46724. * Only used in gltf falloff mode, this defines the angle where
  46725. * the directional falloff will start before cutting at angle which could be seen
  46726. * as outer angle.
  46727. */
  46728. innerAngle: number;
  46729. private _shadowAngleScale;
  46730. /**
  46731. * Allows scaling the angle of the light for shadow generation only.
  46732. */
  46733. /**
  46734. * Allows scaling the angle of the light for shadow generation only.
  46735. */
  46736. shadowAngleScale: number;
  46737. /**
  46738. * The light decay speed with the distance from the emission spot.
  46739. */
  46740. exponent: number;
  46741. private _projectionTextureMatrix;
  46742. /**
  46743. * Allows reading the projecton texture
  46744. */
  46745. readonly projectionTextureMatrix: Matrix;
  46746. protected _projectionTextureLightNear: number;
  46747. /**
  46748. * Gets the near clip of the Spotlight for texture projection.
  46749. */
  46750. /**
  46751. * Sets the near clip of the Spotlight for texture projection.
  46752. */
  46753. projectionTextureLightNear: number;
  46754. protected _projectionTextureLightFar: number;
  46755. /**
  46756. * Gets the far clip of the Spotlight for texture projection.
  46757. */
  46758. /**
  46759. * Sets the far clip of the Spotlight for texture projection.
  46760. */
  46761. projectionTextureLightFar: number;
  46762. protected _projectionTextureUpDirection: Vector3;
  46763. /**
  46764. * Gets the Up vector of the Spotlight for texture projection.
  46765. */
  46766. /**
  46767. * Sets the Up vector of the Spotlight for texture projection.
  46768. */
  46769. projectionTextureUpDirection: Vector3;
  46770. private _projectionTexture;
  46771. /**
  46772. * Gets the projection texture of the light.
  46773. */
  46774. /**
  46775. * Sets the projection texture of the light.
  46776. */
  46777. projectionTexture: Nullable<BaseTexture>;
  46778. private _projectionTextureViewLightDirty;
  46779. private _projectionTextureProjectionLightDirty;
  46780. private _projectionTextureDirty;
  46781. private _projectionTextureViewTargetVector;
  46782. private _projectionTextureViewLightMatrix;
  46783. private _projectionTextureProjectionLightMatrix;
  46784. private _projectionTextureScalingMatrix;
  46785. /**
  46786. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46787. * It can cast shadows.
  46788. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46789. * @param name The light friendly name
  46790. * @param position The position of the spot light in the scene
  46791. * @param direction The direction of the light in the scene
  46792. * @param angle The cone angle of the light in Radians
  46793. * @param exponent The light decay speed with the distance from the emission spot
  46794. * @param scene The scene the lights belongs to
  46795. */
  46796. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46797. /**
  46798. * Returns the string "SpotLight".
  46799. * @returns the class name
  46800. */
  46801. getClassName(): string;
  46802. /**
  46803. * Returns the integer 2.
  46804. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46805. */
  46806. getTypeID(): number;
  46807. /**
  46808. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46809. */
  46810. protected _setDirection(value: Vector3): void;
  46811. /**
  46812. * Overrides the position setter to recompute the projection texture view light Matrix.
  46813. */
  46814. protected _setPosition(value: Vector3): void;
  46815. /**
  46816. * 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.
  46817. * Returns the SpotLight.
  46818. */
  46819. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46820. protected _computeProjectionTextureViewLightMatrix(): void;
  46821. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46822. /**
  46823. * Main function for light texture projection matrix computing.
  46824. */
  46825. protected _computeProjectionTextureMatrix(): void;
  46826. protected _buildUniformLayout(): void;
  46827. private _computeAngleValues;
  46828. /**
  46829. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46830. * @param effect The effect to update
  46831. * @param lightIndex The index of the light in the effect to update
  46832. * @returns The spot light
  46833. */
  46834. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46835. /**
  46836. * Disposes the light and the associated resources.
  46837. */
  46838. dispose(): void;
  46839. /**
  46840. * Prepares the list of defines specific to the light type.
  46841. * @param defines the list of defines
  46842. * @param lightIndex defines the index of the light for the effect
  46843. */
  46844. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46845. }
  46846. }
  46847. declare module "babylonjs/Lights/index" {
  46848. export * from "babylonjs/Lights/light";
  46849. export * from "babylonjs/Lights/shadowLight";
  46850. export * from "babylonjs/Lights/Shadows/index";
  46851. export * from "babylonjs/Lights/directionalLight";
  46852. export * from "babylonjs/Lights/hemisphericLight";
  46853. export * from "babylonjs/Lights/pointLight";
  46854. export * from "babylonjs/Lights/spotLight";
  46855. }
  46856. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46857. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46858. /**
  46859. * Header information of HDR texture files.
  46860. */
  46861. export interface HDRInfo {
  46862. /**
  46863. * The height of the texture in pixels.
  46864. */
  46865. height: number;
  46866. /**
  46867. * The width of the texture in pixels.
  46868. */
  46869. width: number;
  46870. /**
  46871. * The index of the beginning of the data in the binary file.
  46872. */
  46873. dataPosition: number;
  46874. }
  46875. /**
  46876. * This groups tools to convert HDR texture to native colors array.
  46877. */
  46878. export class HDRTools {
  46879. private static Ldexp;
  46880. private static Rgbe2float;
  46881. private static readStringLine;
  46882. /**
  46883. * Reads header information from an RGBE texture stored in a native array.
  46884. * More information on this format are available here:
  46885. * https://en.wikipedia.org/wiki/RGBE_image_format
  46886. *
  46887. * @param uint8array The binary file stored in native array.
  46888. * @return The header information.
  46889. */
  46890. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46891. /**
  46892. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46893. * This RGBE texture needs to store the information as a panorama.
  46894. *
  46895. * More information on this format are available here:
  46896. * https://en.wikipedia.org/wiki/RGBE_image_format
  46897. *
  46898. * @param buffer The binary file stored in an array buffer.
  46899. * @param size The expected size of the extracted cubemap.
  46900. * @return The Cube Map information.
  46901. */
  46902. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46903. /**
  46904. * Returns the pixels data extracted from an RGBE texture.
  46905. * This pixels will be stored left to right up to down in the R G B order in one array.
  46906. *
  46907. * More information on this format are available here:
  46908. * https://en.wikipedia.org/wiki/RGBE_image_format
  46909. *
  46910. * @param uint8array The binary file stored in an array buffer.
  46911. * @param hdrInfo The header information of the file.
  46912. * @return The pixels data in RGB right to left up to down order.
  46913. */
  46914. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46915. private static RGBE_ReadPixels_RLE;
  46916. }
  46917. }
  46918. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46919. import { Nullable } from "babylonjs/types";
  46920. import { Scene } from "babylonjs/scene";
  46921. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46923. /**
  46924. * This represents a texture coming from an HDR input.
  46925. *
  46926. * The only supported format is currently panorama picture stored in RGBE format.
  46927. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46928. */
  46929. export class HDRCubeTexture extends BaseTexture {
  46930. private static _facesMapping;
  46931. private _generateHarmonics;
  46932. private _noMipmap;
  46933. private _textureMatrix;
  46934. private _size;
  46935. private _onLoad;
  46936. private _onError;
  46937. /**
  46938. * The texture URL.
  46939. */
  46940. url: string;
  46941. /**
  46942. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46943. */
  46944. coordinatesMode: number;
  46945. protected _isBlocking: boolean;
  46946. /**
  46947. * Sets wether or not the texture is blocking during loading.
  46948. */
  46949. /**
  46950. * Gets wether or not the texture is blocking during loading.
  46951. */
  46952. isBlocking: boolean;
  46953. protected _rotationY: number;
  46954. /**
  46955. * Sets texture matrix rotation angle around Y axis in radians.
  46956. */
  46957. /**
  46958. * Gets texture matrix rotation angle around Y axis radians.
  46959. */
  46960. rotationY: number;
  46961. /**
  46962. * Gets or sets the center of the bounding box associated with the cube texture
  46963. * It must define where the camera used to render the texture was set
  46964. */
  46965. boundingBoxPosition: Vector3;
  46966. private _boundingBoxSize;
  46967. /**
  46968. * Gets or sets the size of the bounding box associated with the cube texture
  46969. * When defined, the cubemap will switch to local mode
  46970. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46971. * @example https://www.babylonjs-playground.com/#RNASML
  46972. */
  46973. boundingBoxSize: Vector3;
  46974. /**
  46975. * Instantiates an HDRTexture from the following parameters.
  46976. *
  46977. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46978. * @param scene The scene the texture will be used in
  46979. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46980. * @param noMipmap Forces to not generate the mipmap if true
  46981. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46982. * @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)
  46983. * @param reserved Reserved flag for internal use.
  46984. */
  46985. 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>);
  46986. /**
  46987. * Get the current class name of the texture useful for serialization or dynamic coding.
  46988. * @returns "HDRCubeTexture"
  46989. */
  46990. getClassName(): string;
  46991. /**
  46992. * Occurs when the file is raw .hdr file.
  46993. */
  46994. private loadTexture;
  46995. clone(): HDRCubeTexture;
  46996. delayLoad(): void;
  46997. /**
  46998. * Get the texture reflection matrix used to rotate/transform the reflection.
  46999. * @returns the reflection matrix
  47000. */
  47001. getReflectionTextureMatrix(): Matrix;
  47002. /**
  47003. * Set the texture reflection matrix used to rotate/transform the reflection.
  47004. * @param value Define the reflection matrix to set
  47005. */
  47006. setReflectionTextureMatrix(value: Matrix): void;
  47007. /**
  47008. * Parses a JSON representation of an HDR Texture in order to create the texture
  47009. * @param parsedTexture Define the JSON representation
  47010. * @param scene Define the scene the texture should be created in
  47011. * @param rootUrl Define the root url in case we need to load relative dependencies
  47012. * @returns the newly created texture after parsing
  47013. */
  47014. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47015. serialize(): any;
  47016. }
  47017. }
  47018. declare module "babylonjs/Physics/physicsEngine" {
  47019. import { Nullable } from "babylonjs/types";
  47020. import { Vector3 } from "babylonjs/Maths/math";
  47021. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47022. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47023. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47024. /**
  47025. * Class used to control physics engine
  47026. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47027. */
  47028. export class PhysicsEngine implements IPhysicsEngine {
  47029. private _physicsPlugin;
  47030. /**
  47031. * Global value used to control the smallest number supported by the simulation
  47032. */
  47033. static Epsilon: number;
  47034. private _impostors;
  47035. private _joints;
  47036. /**
  47037. * Gets the gravity vector used by the simulation
  47038. */
  47039. gravity: Vector3;
  47040. /**
  47041. * Factory used to create the default physics plugin.
  47042. * @returns The default physics plugin
  47043. */
  47044. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47045. /**
  47046. * Creates a new Physics Engine
  47047. * @param gravity defines the gravity vector used by the simulation
  47048. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47049. */
  47050. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47051. /**
  47052. * Sets the gravity vector used by the simulation
  47053. * @param gravity defines the gravity vector to use
  47054. */
  47055. setGravity(gravity: Vector3): void;
  47056. /**
  47057. * Set the time step of the physics engine.
  47058. * Default is 1/60.
  47059. * To slow it down, enter 1/600 for example.
  47060. * To speed it up, 1/30
  47061. * @param newTimeStep defines the new timestep to apply to this world.
  47062. */
  47063. setTimeStep(newTimeStep?: number): void;
  47064. /**
  47065. * Get the time step of the physics engine.
  47066. * @returns the current time step
  47067. */
  47068. getTimeStep(): number;
  47069. /**
  47070. * Release all resources
  47071. */
  47072. dispose(): void;
  47073. /**
  47074. * Gets the name of the current physics plugin
  47075. * @returns the name of the plugin
  47076. */
  47077. getPhysicsPluginName(): string;
  47078. /**
  47079. * Adding a new impostor for the impostor tracking.
  47080. * This will be done by the impostor itself.
  47081. * @param impostor the impostor to add
  47082. */
  47083. addImpostor(impostor: PhysicsImpostor): void;
  47084. /**
  47085. * Remove an impostor from the engine.
  47086. * This impostor and its mesh will not longer be updated by the physics engine.
  47087. * @param impostor the impostor to remove
  47088. */
  47089. removeImpostor(impostor: PhysicsImpostor): void;
  47090. /**
  47091. * Add a joint to the physics engine
  47092. * @param mainImpostor defines the main impostor to which the joint is added.
  47093. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47094. * @param joint defines the joint that will connect both impostors.
  47095. */
  47096. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47097. /**
  47098. * Removes a joint from the simulation
  47099. * @param mainImpostor defines the impostor used with the joint
  47100. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47101. * @param joint defines the joint to remove
  47102. */
  47103. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47104. /**
  47105. * Called by the scene. No need to call it.
  47106. * @param delta defines the timespam between frames
  47107. */
  47108. _step(delta: number): void;
  47109. /**
  47110. * Gets the current plugin used to run the simulation
  47111. * @returns current plugin
  47112. */
  47113. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47114. /**
  47115. * Gets the list of physic impostors
  47116. * @returns an array of PhysicsImpostor
  47117. */
  47118. getImpostors(): Array<PhysicsImpostor>;
  47119. /**
  47120. * Gets the impostor for a physics enabled object
  47121. * @param object defines the object impersonated by the impostor
  47122. * @returns the PhysicsImpostor or null if not found
  47123. */
  47124. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47125. /**
  47126. * Gets the impostor for a physics body object
  47127. * @param body defines physics body used by the impostor
  47128. * @returns the PhysicsImpostor or null if not found
  47129. */
  47130. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47131. }
  47132. }
  47133. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47134. import { Nullable } from "babylonjs/types";
  47135. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47137. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47138. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47139. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47140. /** @hidden */
  47141. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47142. private _useDeltaForWorldStep;
  47143. world: any;
  47144. name: string;
  47145. private _physicsMaterials;
  47146. private _fixedTimeStep;
  47147. BJSCANNON: any;
  47148. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47149. setGravity(gravity: Vector3): void;
  47150. setTimeStep(timeStep: number): void;
  47151. getTimeStep(): number;
  47152. executeStep(delta: number): void;
  47153. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47154. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47155. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47156. private _processChildMeshes;
  47157. removePhysicsBody(impostor: PhysicsImpostor): void;
  47158. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47159. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47160. private _addMaterial;
  47161. private _checkWithEpsilon;
  47162. private _createShape;
  47163. private _createHeightmap;
  47164. private _minus90X;
  47165. private _plus90X;
  47166. private _tmpPosition;
  47167. private _tmpDeltaPosition;
  47168. private _tmpUnityRotation;
  47169. private _updatePhysicsBodyTransformation;
  47170. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47171. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47172. isSupported(): boolean;
  47173. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47174. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47175. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47176. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47177. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47178. getBodyMass(impostor: PhysicsImpostor): number;
  47179. getBodyFriction(impostor: PhysicsImpostor): number;
  47180. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47181. getBodyRestitution(impostor: PhysicsImpostor): number;
  47182. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47183. sleepBody(impostor: PhysicsImpostor): void;
  47184. wakeUpBody(impostor: PhysicsImpostor): void;
  47185. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47186. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47187. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47188. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47189. getRadius(impostor: PhysicsImpostor): number;
  47190. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47191. dispose(): void;
  47192. private _extendNamespace;
  47193. }
  47194. }
  47195. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47196. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47197. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47198. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47200. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47201. import { Nullable } from "babylonjs/types";
  47202. /** @hidden */
  47203. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47204. world: any;
  47205. name: string;
  47206. BJSOIMO: any;
  47207. constructor(iterations?: number, oimoInjection?: any);
  47208. setGravity(gravity: Vector3): void;
  47209. setTimeStep(timeStep: number): void;
  47210. getTimeStep(): number;
  47211. private _tmpImpostorsArray;
  47212. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47213. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47214. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47215. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47216. private _tmpPositionVector;
  47217. removePhysicsBody(impostor: PhysicsImpostor): void;
  47218. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47219. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47220. isSupported(): boolean;
  47221. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47222. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47223. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47224. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47226. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47227. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47228. getBodyMass(impostor: PhysicsImpostor): number;
  47229. getBodyFriction(impostor: PhysicsImpostor): number;
  47230. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47231. getBodyRestitution(impostor: PhysicsImpostor): number;
  47232. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47233. sleepBody(impostor: PhysicsImpostor): void;
  47234. wakeUpBody(impostor: PhysicsImpostor): void;
  47235. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47236. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47237. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47238. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47239. getRadius(impostor: PhysicsImpostor): number;
  47240. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47241. dispose(): void;
  47242. }
  47243. }
  47244. declare module "babylonjs/Probes/reflectionProbe" {
  47245. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47246. import { Vector3 } from "babylonjs/Maths/math";
  47247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47248. import { Nullable } from "babylonjs/types";
  47249. import { Scene } from "babylonjs/scene";
  47250. module "babylonjs/abstractScene" {
  47251. interface AbstractScene {
  47252. /**
  47253. * The list of reflection probes added to the scene
  47254. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47255. */
  47256. reflectionProbes: Array<ReflectionProbe>;
  47257. /**
  47258. * Removes the given reflection probe from this scene.
  47259. * @param toRemove The reflection probe to remove
  47260. * @returns The index of the removed reflection probe
  47261. */
  47262. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47263. /**
  47264. * Adds the given reflection probe to this scene.
  47265. * @param newReflectionProbe The reflection probe to add
  47266. */
  47267. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47268. }
  47269. }
  47270. /**
  47271. * Class used to generate realtime reflection / refraction cube textures
  47272. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47273. */
  47274. export class ReflectionProbe {
  47275. /** defines the name of the probe */
  47276. name: string;
  47277. private _scene;
  47278. private _renderTargetTexture;
  47279. private _projectionMatrix;
  47280. private _viewMatrix;
  47281. private _target;
  47282. private _add;
  47283. private _attachedMesh;
  47284. private _invertYAxis;
  47285. /** Gets or sets probe position (center of the cube map) */
  47286. position: Vector3;
  47287. /**
  47288. * Creates a new reflection probe
  47289. * @param name defines the name of the probe
  47290. * @param size defines the texture resolution (for each face)
  47291. * @param scene defines the hosting scene
  47292. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47293. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47294. */
  47295. constructor(
  47296. /** defines the name of the probe */
  47297. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47298. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47299. samples: number;
  47300. /** Gets or sets the refresh rate to use (on every frame by default) */
  47301. refreshRate: number;
  47302. /**
  47303. * Gets the hosting scene
  47304. * @returns a Scene
  47305. */
  47306. getScene(): Scene;
  47307. /** Gets the internal CubeTexture used to render to */
  47308. readonly cubeTexture: RenderTargetTexture;
  47309. /** Gets the list of meshes to render */
  47310. readonly renderList: Nullable<AbstractMesh[]>;
  47311. /**
  47312. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47313. * @param mesh defines the mesh to attach to
  47314. */
  47315. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47316. /**
  47317. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47318. * @param renderingGroupId The rendering group id corresponding to its index
  47319. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47320. */
  47321. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47322. /**
  47323. * Clean all associated resources
  47324. */
  47325. dispose(): void;
  47326. /**
  47327. * Converts the reflection probe information to a readable string for debug purpose.
  47328. * @param fullDetails Supports for multiple levels of logging within scene loading
  47329. * @returns the human readable reflection probe info
  47330. */
  47331. toString(fullDetails?: boolean): string;
  47332. /**
  47333. * Get the class name of the relfection probe.
  47334. * @returns "ReflectionProbe"
  47335. */
  47336. getClassName(): string;
  47337. /**
  47338. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47339. * @returns The JSON representation of the texture
  47340. */
  47341. serialize(): any;
  47342. /**
  47343. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47344. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47345. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47346. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47347. * @returns The parsed reflection probe if successful
  47348. */
  47349. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47350. }
  47351. }
  47352. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47353. /** @hidden */
  47354. export var _BabylonLoaderRegistered: boolean;
  47355. }
  47356. declare module "babylonjs/Loading/Plugins/index" {
  47357. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47358. }
  47359. declare module "babylonjs/Loading/index" {
  47360. export * from "babylonjs/Loading/loadingScreen";
  47361. export * from "babylonjs/Loading/Plugins/index";
  47362. export * from "babylonjs/Loading/sceneLoader";
  47363. export * from "babylonjs/Loading/sceneLoaderFlags";
  47364. }
  47365. declare module "babylonjs/Materials/Background/index" {
  47366. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47367. }
  47368. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47369. import { Scene } from "babylonjs/scene";
  47370. import { Color3 } from "babylonjs/Maths/math";
  47371. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47373. /**
  47374. * The Physically based simple base material of BJS.
  47375. *
  47376. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47377. * It is used as the base class for both the specGloss and metalRough conventions.
  47378. */
  47379. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47380. /**
  47381. * Number of Simultaneous lights allowed on the material.
  47382. */
  47383. maxSimultaneousLights: number;
  47384. /**
  47385. * If sets to true, disables all the lights affecting the material.
  47386. */
  47387. disableLighting: boolean;
  47388. /**
  47389. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47390. */
  47391. environmentTexture: BaseTexture;
  47392. /**
  47393. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47394. */
  47395. invertNormalMapX: boolean;
  47396. /**
  47397. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47398. */
  47399. invertNormalMapY: boolean;
  47400. /**
  47401. * Normal map used in the model.
  47402. */
  47403. normalTexture: BaseTexture;
  47404. /**
  47405. * Emissivie color used to self-illuminate the model.
  47406. */
  47407. emissiveColor: Color3;
  47408. /**
  47409. * Emissivie texture used to self-illuminate the model.
  47410. */
  47411. emissiveTexture: BaseTexture;
  47412. /**
  47413. * Occlusion Channel Strenght.
  47414. */
  47415. occlusionStrength: number;
  47416. /**
  47417. * Occlusion Texture of the material (adding extra occlusion effects).
  47418. */
  47419. occlusionTexture: BaseTexture;
  47420. /**
  47421. * Defines the alpha limits in alpha test mode.
  47422. */
  47423. alphaCutOff: number;
  47424. /**
  47425. * Gets the current double sided mode.
  47426. */
  47427. /**
  47428. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47429. */
  47430. doubleSided: boolean;
  47431. /**
  47432. * Stores the pre-calculated light information of a mesh in a texture.
  47433. */
  47434. lightmapTexture: BaseTexture;
  47435. /**
  47436. * If true, the light map contains occlusion information instead of lighting info.
  47437. */
  47438. useLightmapAsShadowmap: boolean;
  47439. /**
  47440. * Return the active textures of the material.
  47441. */
  47442. getActiveTextures(): BaseTexture[];
  47443. hasTexture(texture: BaseTexture): boolean;
  47444. /**
  47445. * Instantiates a new PBRMaterial instance.
  47446. *
  47447. * @param name The material name
  47448. * @param scene The scene the material will be use in.
  47449. */
  47450. constructor(name: string, scene: Scene);
  47451. getClassName(): string;
  47452. }
  47453. }
  47454. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47455. import { Scene } from "babylonjs/scene";
  47456. import { Color3 } from "babylonjs/Maths/math";
  47457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47458. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47459. /**
  47460. * The PBR material of BJS following the metal roughness convention.
  47461. *
  47462. * This fits to the PBR convention in the GLTF definition:
  47463. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47464. */
  47465. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47466. /**
  47467. * The base color has two different interpretations depending on the value of metalness.
  47468. * When the material is a metal, the base color is the specific measured reflectance value
  47469. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47470. * of the material.
  47471. */
  47472. baseColor: Color3;
  47473. /**
  47474. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47475. * well as opacity information in the alpha channel.
  47476. */
  47477. baseTexture: BaseTexture;
  47478. /**
  47479. * Specifies the metallic scalar value of the material.
  47480. * Can also be used to scale the metalness values of the metallic texture.
  47481. */
  47482. metallic: number;
  47483. /**
  47484. * Specifies the roughness scalar value of the material.
  47485. * Can also be used to scale the roughness values of the metallic texture.
  47486. */
  47487. roughness: number;
  47488. /**
  47489. * Texture containing both the metallic value in the B channel and the
  47490. * roughness value in the G channel to keep better precision.
  47491. */
  47492. metallicRoughnessTexture: BaseTexture;
  47493. /**
  47494. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47495. *
  47496. * @param name The material name
  47497. * @param scene The scene the material will be use in.
  47498. */
  47499. constructor(name: string, scene: Scene);
  47500. /**
  47501. * Return the currrent class name of the material.
  47502. */
  47503. getClassName(): string;
  47504. /**
  47505. * Return the active textures of the material.
  47506. */
  47507. getActiveTextures(): BaseTexture[];
  47508. /**
  47509. * Checks to see if a texture is used in the material.
  47510. * @param texture - Base texture to use.
  47511. * @returns - Boolean specifying if a texture is used in the material.
  47512. */
  47513. hasTexture(texture: BaseTexture): boolean;
  47514. /**
  47515. * Makes a duplicate of the current material.
  47516. * @param name - name to use for the new material.
  47517. */
  47518. clone(name: string): PBRMetallicRoughnessMaterial;
  47519. /**
  47520. * Serialize the material to a parsable JSON object.
  47521. */
  47522. serialize(): any;
  47523. /**
  47524. * Parses a JSON object correponding to the serialize function.
  47525. */
  47526. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47527. }
  47528. }
  47529. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47530. import { Scene } from "babylonjs/scene";
  47531. import { Color3 } from "babylonjs/Maths/math";
  47532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47533. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47534. /**
  47535. * The PBR material of BJS following the specular glossiness convention.
  47536. *
  47537. * This fits to the PBR convention in the GLTF definition:
  47538. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47539. */
  47540. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47541. /**
  47542. * Specifies the diffuse color of the material.
  47543. */
  47544. diffuseColor: Color3;
  47545. /**
  47546. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47547. * channel.
  47548. */
  47549. diffuseTexture: BaseTexture;
  47550. /**
  47551. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47552. */
  47553. specularColor: Color3;
  47554. /**
  47555. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47556. */
  47557. glossiness: number;
  47558. /**
  47559. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47560. */
  47561. specularGlossinessTexture: BaseTexture;
  47562. /**
  47563. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47564. *
  47565. * @param name The material name
  47566. * @param scene The scene the material will be use in.
  47567. */
  47568. constructor(name: string, scene: Scene);
  47569. /**
  47570. * Return the currrent class name of the material.
  47571. */
  47572. getClassName(): string;
  47573. /**
  47574. * Return the active textures of the material.
  47575. */
  47576. getActiveTextures(): BaseTexture[];
  47577. /**
  47578. * Checks to see if a texture is used in the material.
  47579. * @param texture - Base texture to use.
  47580. * @returns - Boolean specifying if a texture is used in the material.
  47581. */
  47582. hasTexture(texture: BaseTexture): boolean;
  47583. /**
  47584. * Makes a duplicate of the current material.
  47585. * @param name - name to use for the new material.
  47586. */
  47587. clone(name: string): PBRSpecularGlossinessMaterial;
  47588. /**
  47589. * Serialize the material to a parsable JSON object.
  47590. */
  47591. serialize(): any;
  47592. /**
  47593. * Parses a JSON object correponding to the serialize function.
  47594. */
  47595. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47596. }
  47597. }
  47598. declare module "babylonjs/Materials/PBR/index" {
  47599. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47600. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47601. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47602. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47603. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47604. }
  47605. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47606. import { Nullable } from "babylonjs/types";
  47607. import { Scene } from "babylonjs/scene";
  47608. import { Matrix } from "babylonjs/Maths/math";
  47609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47610. /**
  47611. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47612. * It can help converting any input color in a desired output one. This can then be used to create effects
  47613. * from sepia, black and white to sixties or futuristic rendering...
  47614. *
  47615. * The only supported format is currently 3dl.
  47616. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47617. */
  47618. export class ColorGradingTexture extends BaseTexture {
  47619. /**
  47620. * The current texture matrix. (will always be identity in color grading texture)
  47621. */
  47622. private _textureMatrix;
  47623. /**
  47624. * The texture URL.
  47625. */
  47626. url: string;
  47627. /**
  47628. * Empty line regex stored for GC.
  47629. */
  47630. private static _noneEmptyLineRegex;
  47631. private _engine;
  47632. /**
  47633. * Instantiates a ColorGradingTexture from the following parameters.
  47634. *
  47635. * @param url The location of the color gradind data (currently only supporting 3dl)
  47636. * @param scene The scene the texture will be used in
  47637. */
  47638. constructor(url: string, scene: Scene);
  47639. /**
  47640. * Returns the texture matrix used in most of the material.
  47641. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47642. */
  47643. getTextureMatrix(): Matrix;
  47644. /**
  47645. * Occurs when the file being loaded is a .3dl LUT file.
  47646. */
  47647. private load3dlTexture;
  47648. /**
  47649. * Starts the loading process of the texture.
  47650. */
  47651. private loadTexture;
  47652. /**
  47653. * Clones the color gradind texture.
  47654. */
  47655. clone(): ColorGradingTexture;
  47656. /**
  47657. * Called during delayed load for textures.
  47658. */
  47659. delayLoad(): void;
  47660. /**
  47661. * Parses a color grading texture serialized by Babylon.
  47662. * @param parsedTexture The texture information being parsedTexture
  47663. * @param scene The scene to load the texture in
  47664. * @param rootUrl The root url of the data assets to load
  47665. * @return A color gradind texture
  47666. */
  47667. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47668. /**
  47669. * Serializes the LUT texture to json format.
  47670. */
  47671. serialize(): any;
  47672. }
  47673. }
  47674. declare module "babylonjs/Misc/dds" {
  47675. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47676. import { Engine } from "babylonjs/Engines/engine";
  47677. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47678. import { Nullable } from "babylonjs/types";
  47679. import { Scene } from "babylonjs/scene";
  47680. /**
  47681. * Direct draw surface info
  47682. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47683. */
  47684. export interface DDSInfo {
  47685. /**
  47686. * Width of the texture
  47687. */
  47688. width: number;
  47689. /**
  47690. * Width of the texture
  47691. */
  47692. height: number;
  47693. /**
  47694. * Number of Mipmaps for the texture
  47695. * @see https://en.wikipedia.org/wiki/Mipmap
  47696. */
  47697. mipmapCount: number;
  47698. /**
  47699. * If the textures format is a known fourCC format
  47700. * @see https://www.fourcc.org/
  47701. */
  47702. isFourCC: boolean;
  47703. /**
  47704. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47705. */
  47706. isRGB: boolean;
  47707. /**
  47708. * If the texture is a lumincance format
  47709. */
  47710. isLuminance: boolean;
  47711. /**
  47712. * If this is a cube texture
  47713. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47714. */
  47715. isCube: boolean;
  47716. /**
  47717. * If the texture is a compressed format eg. FOURCC_DXT1
  47718. */
  47719. isCompressed: boolean;
  47720. /**
  47721. * The dxgiFormat of the texture
  47722. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47723. */
  47724. dxgiFormat: number;
  47725. /**
  47726. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47727. */
  47728. textureType: number;
  47729. /**
  47730. * Sphericle polynomial created for the dds texture
  47731. */
  47732. sphericalPolynomial?: SphericalPolynomial;
  47733. }
  47734. /**
  47735. * Class used to provide DDS decompression tools
  47736. */
  47737. export class DDSTools {
  47738. /**
  47739. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47740. */
  47741. static StoreLODInAlphaChannel: boolean;
  47742. /**
  47743. * Gets DDS information from an array buffer
  47744. * @param arrayBuffer defines the array buffer to read data from
  47745. * @returns the DDS information
  47746. */
  47747. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47748. private static _FloatView;
  47749. private static _Int32View;
  47750. private static _ToHalfFloat;
  47751. private static _FromHalfFloat;
  47752. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47753. private static _GetHalfFloatRGBAArrayBuffer;
  47754. private static _GetFloatRGBAArrayBuffer;
  47755. private static _GetFloatAsUIntRGBAArrayBuffer;
  47756. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47757. private static _GetRGBAArrayBuffer;
  47758. private static _ExtractLongWordOrder;
  47759. private static _GetRGBArrayBuffer;
  47760. private static _GetLuminanceArrayBuffer;
  47761. /**
  47762. * Uploads DDS Levels to a Babylon Texture
  47763. * @hidden
  47764. */
  47765. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47766. }
  47767. module "babylonjs/Engines/engine" {
  47768. interface Engine {
  47769. /**
  47770. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47771. * @param rootUrl defines the url where the file to load is located
  47772. * @param scene defines the current scene
  47773. * @param lodScale defines scale to apply to the mip map selection
  47774. * @param lodOffset defines offset to apply to the mip map selection
  47775. * @param onLoad defines an optional callback raised when the texture is loaded
  47776. * @param onError defines an optional callback raised if there is an issue to load the texture
  47777. * @param format defines the format of the data
  47778. * @param forcedExtension defines the extension to use to pick the right loader
  47779. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47780. * @returns the cube texture as an InternalTexture
  47781. */
  47782. 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;
  47783. }
  47784. }
  47785. }
  47786. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47787. import { Nullable } from "babylonjs/types";
  47788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47789. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47790. /**
  47791. * Implementation of the DDS Texture Loader.
  47792. * @hidden
  47793. */
  47794. export class _DDSTextureLoader implements IInternalTextureLoader {
  47795. /**
  47796. * Defines wether the loader supports cascade loading the different faces.
  47797. */
  47798. readonly supportCascades: boolean;
  47799. /**
  47800. * This returns if the loader support the current file information.
  47801. * @param extension defines the file extension of the file being loaded
  47802. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47803. * @param fallback defines the fallback internal texture if any
  47804. * @param isBase64 defines whether the texture is encoded as a base64
  47805. * @param isBuffer defines whether the texture data are stored as a buffer
  47806. * @returns true if the loader can load the specified file
  47807. */
  47808. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47809. /**
  47810. * Transform the url before loading if required.
  47811. * @param rootUrl the url of the texture
  47812. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47813. * @returns the transformed texture
  47814. */
  47815. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47816. /**
  47817. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47818. * @param rootUrl the url of the texture
  47819. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47820. * @returns the fallback texture
  47821. */
  47822. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47823. /**
  47824. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47825. * @param data contains the texture data
  47826. * @param texture defines the BabylonJS internal texture
  47827. * @param createPolynomials will be true if polynomials have been requested
  47828. * @param onLoad defines the callback to trigger once the texture is ready
  47829. * @param onError defines the callback to trigger in case of error
  47830. */
  47831. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47832. /**
  47833. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47834. * @param data contains the texture data
  47835. * @param texture defines the BabylonJS internal texture
  47836. * @param callback defines the method to call once ready to upload
  47837. */
  47838. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47839. }
  47840. }
  47841. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47842. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47843. /** @hidden */
  47844. export var rgbdEncodePixelShader: {
  47845. name: string;
  47846. shader: string;
  47847. };
  47848. }
  47849. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47850. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47851. /** @hidden */
  47852. export var rgbdDecodePixelShader: {
  47853. name: string;
  47854. shader: string;
  47855. };
  47856. }
  47857. declare module "babylonjs/Misc/environmentTextureTools" {
  47858. import { Nullable } from "babylonjs/types";
  47859. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47860. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47861. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47862. import "babylonjs/Shaders/rgbdEncode.fragment";
  47863. import "babylonjs/Shaders/rgbdDecode.fragment";
  47864. /**
  47865. * Raw texture data and descriptor sufficient for WebGL texture upload
  47866. */
  47867. export interface EnvironmentTextureInfo {
  47868. /**
  47869. * Version of the environment map
  47870. */
  47871. version: number;
  47872. /**
  47873. * Width of image
  47874. */
  47875. width: number;
  47876. /**
  47877. * Irradiance information stored in the file.
  47878. */
  47879. irradiance: any;
  47880. /**
  47881. * Specular information stored in the file.
  47882. */
  47883. specular: any;
  47884. }
  47885. /**
  47886. * Sets of helpers addressing the serialization and deserialization of environment texture
  47887. * stored in a BabylonJS env file.
  47888. * Those files are usually stored as .env files.
  47889. */
  47890. export class EnvironmentTextureTools {
  47891. /**
  47892. * Magic number identifying the env file.
  47893. */
  47894. private static _MagicBytes;
  47895. /**
  47896. * Gets the environment info from an env file.
  47897. * @param data The array buffer containing the .env bytes.
  47898. * @returns the environment file info (the json header) if successfully parsed.
  47899. */
  47900. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47901. /**
  47902. * Creates an environment texture from a loaded cube texture.
  47903. * @param texture defines the cube texture to convert in env file
  47904. * @return a promise containing the environment data if succesfull.
  47905. */
  47906. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47907. /**
  47908. * Creates a JSON representation of the spherical data.
  47909. * @param texture defines the texture containing the polynomials
  47910. * @return the JSON representation of the spherical info
  47911. */
  47912. private static _CreateEnvTextureIrradiance;
  47913. /**
  47914. * Uploads the texture info contained in the env file to the GPU.
  47915. * @param texture defines the internal texture to upload to
  47916. * @param arrayBuffer defines the buffer cotaining the data to load
  47917. * @param info defines the texture info retrieved through the GetEnvInfo method
  47918. * @returns a promise
  47919. */
  47920. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47921. /**
  47922. * Uploads the levels of image data to the GPU.
  47923. * @param texture defines the internal texture to upload to
  47924. * @param imageData defines the array buffer views of image data [mipmap][face]
  47925. * @returns a promise
  47926. */
  47927. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47928. /**
  47929. * Uploads spherical polynomials information to the texture.
  47930. * @param texture defines the texture we are trying to upload the information to
  47931. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47932. */
  47933. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47934. /** @hidden */
  47935. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47936. }
  47937. }
  47938. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47939. import { Nullable } from "babylonjs/types";
  47940. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47941. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47942. /**
  47943. * Implementation of the ENV Texture Loader.
  47944. * @hidden
  47945. */
  47946. export class _ENVTextureLoader implements IInternalTextureLoader {
  47947. /**
  47948. * Defines wether the loader supports cascade loading the different faces.
  47949. */
  47950. readonly supportCascades: boolean;
  47951. /**
  47952. * This returns if the loader support the current file information.
  47953. * @param extension defines the file extension of the file being loaded
  47954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47955. * @param fallback defines the fallback internal texture if any
  47956. * @param isBase64 defines whether the texture is encoded as a base64
  47957. * @param isBuffer defines whether the texture data are stored as a buffer
  47958. * @returns true if the loader can load the specified file
  47959. */
  47960. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47961. /**
  47962. * Transform the url before loading if required.
  47963. * @param rootUrl the url of the texture
  47964. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47965. * @returns the transformed texture
  47966. */
  47967. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47968. /**
  47969. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47970. * @param rootUrl the url of the texture
  47971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47972. * @returns the fallback texture
  47973. */
  47974. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47975. /**
  47976. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47977. * @param data contains the texture data
  47978. * @param texture defines the BabylonJS internal texture
  47979. * @param createPolynomials will be true if polynomials have been requested
  47980. * @param onLoad defines the callback to trigger once the texture is ready
  47981. * @param onError defines the callback to trigger in case of error
  47982. */
  47983. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47984. /**
  47985. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47986. * @param data contains the texture data
  47987. * @param texture defines the BabylonJS internal texture
  47988. * @param callback defines the method to call once ready to upload
  47989. */
  47990. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47991. }
  47992. }
  47993. declare module "babylonjs/Misc/khronosTextureContainer" {
  47994. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47995. /**
  47996. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47997. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47998. */
  47999. export class KhronosTextureContainer {
  48000. /** contents of the KTX container file */
  48001. arrayBuffer: any;
  48002. private static HEADER_LEN;
  48003. private static COMPRESSED_2D;
  48004. private static COMPRESSED_3D;
  48005. private static TEX_2D;
  48006. private static TEX_3D;
  48007. /**
  48008. * Gets the openGL type
  48009. */
  48010. glType: number;
  48011. /**
  48012. * Gets the openGL type size
  48013. */
  48014. glTypeSize: number;
  48015. /**
  48016. * Gets the openGL format
  48017. */
  48018. glFormat: number;
  48019. /**
  48020. * Gets the openGL internal format
  48021. */
  48022. glInternalFormat: number;
  48023. /**
  48024. * Gets the base internal format
  48025. */
  48026. glBaseInternalFormat: number;
  48027. /**
  48028. * Gets image width in pixel
  48029. */
  48030. pixelWidth: number;
  48031. /**
  48032. * Gets image height in pixel
  48033. */
  48034. pixelHeight: number;
  48035. /**
  48036. * Gets image depth in pixels
  48037. */
  48038. pixelDepth: number;
  48039. /**
  48040. * Gets the number of array elements
  48041. */
  48042. numberOfArrayElements: number;
  48043. /**
  48044. * Gets the number of faces
  48045. */
  48046. numberOfFaces: number;
  48047. /**
  48048. * Gets the number of mipmap levels
  48049. */
  48050. numberOfMipmapLevels: number;
  48051. /**
  48052. * Gets the bytes of key value data
  48053. */
  48054. bytesOfKeyValueData: number;
  48055. /**
  48056. * Gets the load type
  48057. */
  48058. loadType: number;
  48059. /**
  48060. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48061. */
  48062. isInvalid: boolean;
  48063. /**
  48064. * Creates a new KhronosTextureContainer
  48065. * @param arrayBuffer contents of the KTX container file
  48066. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48067. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48068. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48069. */
  48070. constructor(
  48071. /** contents of the KTX container file */
  48072. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48073. /**
  48074. * Uploads KTX content to a Babylon Texture.
  48075. * It is assumed that the texture has already been created & is currently bound
  48076. * @hidden
  48077. */
  48078. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48079. private _upload2DCompressedLevels;
  48080. }
  48081. }
  48082. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48083. import { Nullable } from "babylonjs/types";
  48084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48085. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48086. /**
  48087. * Implementation of the KTX Texture Loader.
  48088. * @hidden
  48089. */
  48090. export class _KTXTextureLoader implements IInternalTextureLoader {
  48091. /**
  48092. * Defines wether the loader supports cascade loading the different faces.
  48093. */
  48094. readonly supportCascades: boolean;
  48095. /**
  48096. * This returns if the loader support the current file information.
  48097. * @param extension defines the file extension of the file being loaded
  48098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48099. * @param fallback defines the fallback internal texture if any
  48100. * @param isBase64 defines whether the texture is encoded as a base64
  48101. * @param isBuffer defines whether the texture data are stored as a buffer
  48102. * @returns true if the loader can load the specified file
  48103. */
  48104. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48105. /**
  48106. * Transform the url before loading if required.
  48107. * @param rootUrl the url of the texture
  48108. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48109. * @returns the transformed texture
  48110. */
  48111. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48112. /**
  48113. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48114. * @param rootUrl the url of the texture
  48115. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48116. * @returns the fallback texture
  48117. */
  48118. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48119. /**
  48120. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48121. * @param data contains the texture data
  48122. * @param texture defines the BabylonJS internal texture
  48123. * @param createPolynomials will be true if polynomials have been requested
  48124. * @param onLoad defines the callback to trigger once the texture is ready
  48125. * @param onError defines the callback to trigger in case of error
  48126. */
  48127. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48128. /**
  48129. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48130. * @param data contains the texture data
  48131. * @param texture defines the BabylonJS internal texture
  48132. * @param callback defines the method to call once ready to upload
  48133. */
  48134. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48135. }
  48136. }
  48137. declare module "babylonjs/Misc/tga" {
  48138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48139. /**
  48140. * Based on jsTGALoader - Javascript loader for TGA file
  48141. * By Vincent Thibault
  48142. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48143. */
  48144. export class TGATools {
  48145. private static _TYPE_INDEXED;
  48146. private static _TYPE_RGB;
  48147. private static _TYPE_GREY;
  48148. private static _TYPE_RLE_INDEXED;
  48149. private static _TYPE_RLE_RGB;
  48150. private static _TYPE_RLE_GREY;
  48151. private static _ORIGIN_MASK;
  48152. private static _ORIGIN_SHIFT;
  48153. private static _ORIGIN_BL;
  48154. private static _ORIGIN_BR;
  48155. private static _ORIGIN_UL;
  48156. private static _ORIGIN_UR;
  48157. /**
  48158. * Gets the header of a TGA file
  48159. * @param data defines the TGA data
  48160. * @returns the header
  48161. */
  48162. static GetTGAHeader(data: Uint8Array): any;
  48163. /**
  48164. * Uploads TGA content to a Babylon Texture
  48165. * @hidden
  48166. */
  48167. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48168. /** @hidden */
  48169. 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;
  48170. /** @hidden */
  48171. 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;
  48172. /** @hidden */
  48173. 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;
  48174. /** @hidden */
  48175. 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;
  48176. /** @hidden */
  48177. 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;
  48178. /** @hidden */
  48179. 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;
  48180. }
  48181. }
  48182. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48183. import { Nullable } from "babylonjs/types";
  48184. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48185. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48186. /**
  48187. * Implementation of the TGA Texture Loader.
  48188. * @hidden
  48189. */
  48190. export class _TGATextureLoader implements IInternalTextureLoader {
  48191. /**
  48192. * Defines wether the loader supports cascade loading the different faces.
  48193. */
  48194. readonly supportCascades: boolean;
  48195. /**
  48196. * This returns if the loader support the current file information.
  48197. * @param extension defines the file extension of the file being loaded
  48198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48199. * @param fallback defines the fallback internal texture if any
  48200. * @param isBase64 defines whether the texture is encoded as a base64
  48201. * @param isBuffer defines whether the texture data are stored as a buffer
  48202. * @returns true if the loader can load the specified file
  48203. */
  48204. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48205. /**
  48206. * Transform the url before loading if required.
  48207. * @param rootUrl the url of the texture
  48208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48209. * @returns the transformed texture
  48210. */
  48211. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48212. /**
  48213. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48214. * @param rootUrl the url of the texture
  48215. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48216. * @returns the fallback texture
  48217. */
  48218. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48219. /**
  48220. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48221. * @param data contains the texture data
  48222. * @param texture defines the BabylonJS internal texture
  48223. * @param createPolynomials will be true if polynomials have been requested
  48224. * @param onLoad defines the callback to trigger once the texture is ready
  48225. * @param onError defines the callback to trigger in case of error
  48226. */
  48227. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48228. /**
  48229. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48230. * @param data contains the texture data
  48231. * @param texture defines the BabylonJS internal texture
  48232. * @param callback defines the method to call once ready to upload
  48233. */
  48234. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48235. }
  48236. }
  48237. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48238. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48239. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48240. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48241. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48242. }
  48243. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48244. import { Scene } from "babylonjs/scene";
  48245. import { Texture } from "babylonjs/Materials/Textures/texture";
  48246. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48247. /**
  48248. * 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.
  48249. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48250. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48251. */
  48252. export class CustomProceduralTexture extends ProceduralTexture {
  48253. private _animate;
  48254. private _time;
  48255. private _config;
  48256. private _texturePath;
  48257. /**
  48258. * Instantiates a new Custom Procedural Texture.
  48259. * 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.
  48260. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48262. * @param name Define the name of the texture
  48263. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48264. * @param size Define the size of the texture to create
  48265. * @param scene Define the scene the texture belongs to
  48266. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48267. * @param generateMipMaps Define if the texture should creates mip maps or not
  48268. */
  48269. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48270. private _loadJson;
  48271. /**
  48272. * Is the texture ready to be used ? (rendered at least once)
  48273. * @returns true if ready, otherwise, false.
  48274. */
  48275. isReady(): boolean;
  48276. /**
  48277. * Render the texture to its associated render target.
  48278. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48279. */
  48280. render(useCameraPostProcess?: boolean): void;
  48281. /**
  48282. * Update the list of dependant textures samplers in the shader.
  48283. */
  48284. updateTextures(): void;
  48285. /**
  48286. * Update the uniform values of the procedural texture in the shader.
  48287. */
  48288. updateShaderUniforms(): void;
  48289. /**
  48290. * Define if the texture animates or not.
  48291. */
  48292. animate: boolean;
  48293. }
  48294. }
  48295. declare module "babylonjs/Shaders/noise.fragment" {
  48296. /** @hidden */
  48297. export var noisePixelShader: {
  48298. name: string;
  48299. shader: string;
  48300. };
  48301. }
  48302. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48303. import { Nullable } from "babylonjs/types";
  48304. import { Scene } from "babylonjs/scene";
  48305. import { Texture } from "babylonjs/Materials/Textures/texture";
  48306. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48307. import "babylonjs/Shaders/noise.fragment";
  48308. /**
  48309. * Class used to generate noise procedural textures
  48310. */
  48311. export class NoiseProceduralTexture extends ProceduralTexture {
  48312. private _time;
  48313. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48314. brightness: number;
  48315. /** Defines the number of octaves to process */
  48316. octaves: number;
  48317. /** Defines the level of persistence (0.8 by default) */
  48318. persistence: number;
  48319. /** Gets or sets animation speed factor (default is 1) */
  48320. animationSpeedFactor: number;
  48321. /**
  48322. * Creates a new NoiseProceduralTexture
  48323. * @param name defines the name fo the texture
  48324. * @param size defines the size of the texture (default is 256)
  48325. * @param scene defines the hosting scene
  48326. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48327. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48328. */
  48329. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48330. private _updateShaderUniforms;
  48331. protected _getDefines(): string;
  48332. /** Generate the current state of the procedural texture */
  48333. render(useCameraPostProcess?: boolean): void;
  48334. /**
  48335. * Serializes this noise procedural texture
  48336. * @returns a serialized noise procedural texture object
  48337. */
  48338. serialize(): any;
  48339. /**
  48340. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48341. * @param parsedTexture defines parsed texture data
  48342. * @param scene defines the current scene
  48343. * @param rootUrl defines the root URL containing noise procedural texture information
  48344. * @returns a parsed NoiseProceduralTexture
  48345. */
  48346. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48347. }
  48348. }
  48349. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48350. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48351. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48352. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48353. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48354. }
  48355. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48356. import { Nullable } from "babylonjs/types";
  48357. import { Scene } from "babylonjs/scene";
  48358. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48359. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48360. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48361. /**
  48362. * Raw cube texture where the raw buffers are passed in
  48363. */
  48364. export class RawCubeTexture extends CubeTexture {
  48365. /**
  48366. * Creates a cube texture where the raw buffers are passed in.
  48367. * @param scene defines the scene the texture is attached to
  48368. * @param data defines the array of data to use to create each face
  48369. * @param size defines the size of the textures
  48370. * @param format defines the format of the data
  48371. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48372. * @param generateMipMaps defines if the engine should generate the mip levels
  48373. * @param invertY defines if data must be stored with Y axis inverted
  48374. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48375. * @param compression defines the compression used (null by default)
  48376. */
  48377. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48378. /**
  48379. * Updates the raw cube texture.
  48380. * @param data defines the data to store
  48381. * @param format defines the data format
  48382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48383. * @param invertY defines if data must be stored with Y axis inverted
  48384. * @param compression defines the compression used (null by default)
  48385. * @param level defines which level of the texture to update
  48386. */
  48387. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48388. /**
  48389. * Updates a raw cube texture with RGBD encoded data.
  48390. * @param data defines the array of data [mipmap][face] to use to create each face
  48391. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48392. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48393. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48394. * @returns a promsie that resolves when the operation is complete
  48395. */
  48396. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48397. /**
  48398. * Clones the raw cube texture.
  48399. * @return a new cube texture
  48400. */
  48401. clone(): CubeTexture;
  48402. /** @hidden */
  48403. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48404. }
  48405. }
  48406. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48407. import { Scene } from "babylonjs/scene";
  48408. import { Texture } from "babylonjs/Materials/Textures/texture";
  48409. /**
  48410. * Class used to store 3D textures containing user data
  48411. */
  48412. export class RawTexture3D extends Texture {
  48413. /** Gets or sets the texture format to use */
  48414. format: number;
  48415. private _engine;
  48416. /**
  48417. * Create a new RawTexture3D
  48418. * @param data defines the data of the texture
  48419. * @param width defines the width of the texture
  48420. * @param height defines the height of the texture
  48421. * @param depth defines the depth of the texture
  48422. * @param format defines the texture format to use
  48423. * @param scene defines the hosting scene
  48424. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48425. * @param invertY defines if texture must be stored with Y axis inverted
  48426. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48427. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48428. */
  48429. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48430. /** Gets or sets the texture format to use */
  48431. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48432. /**
  48433. * Update the texture with new data
  48434. * @param data defines the data to store in the texture
  48435. */
  48436. update(data: ArrayBufferView): void;
  48437. }
  48438. }
  48439. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48440. import { Scene } from "babylonjs/scene";
  48441. import { Plane } from "babylonjs/Maths/math";
  48442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48443. /**
  48444. * Creates a refraction texture used by refraction channel of the standard material.
  48445. * It is like a mirror but to see through a material.
  48446. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48447. */
  48448. export class RefractionTexture extends RenderTargetTexture {
  48449. /**
  48450. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48451. * 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.
  48452. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48453. */
  48454. refractionPlane: Plane;
  48455. /**
  48456. * Define how deep under the surface we should see.
  48457. */
  48458. depth: number;
  48459. /**
  48460. * Creates a refraction texture used by refraction channel of the standard material.
  48461. * It is like a mirror but to see through a material.
  48462. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48463. * @param name Define the texture name
  48464. * @param size Define the size of the underlying texture
  48465. * @param scene Define the scene the refraction belongs to
  48466. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48467. */
  48468. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48469. /**
  48470. * Clone the refraction texture.
  48471. * @returns the cloned texture
  48472. */
  48473. clone(): RefractionTexture;
  48474. /**
  48475. * Serialize the texture to a JSON representation you could use in Parse later on
  48476. * @returns the serialized JSON representation
  48477. */
  48478. serialize(): any;
  48479. }
  48480. }
  48481. declare module "babylonjs/Materials/Textures/index" {
  48482. export * from "babylonjs/Materials/Textures/baseTexture";
  48483. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48484. export * from "babylonjs/Materials/Textures/cubeTexture";
  48485. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48486. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48487. export * from "babylonjs/Materials/Textures/internalTexture";
  48488. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48489. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48490. export * from "babylonjs/Materials/Textures/Loaders/index";
  48491. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48492. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48493. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48494. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48495. export * from "babylonjs/Materials/Textures/rawTexture";
  48496. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48497. export * from "babylonjs/Materials/Textures/refractionTexture";
  48498. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48499. export * from "babylonjs/Materials/Textures/texture";
  48500. export * from "babylonjs/Materials/Textures/videoTexture";
  48501. }
  48502. declare module "babylonjs/Materials/index" {
  48503. export * from "babylonjs/Materials/Background/index";
  48504. export * from "babylonjs/Materials/colorCurves";
  48505. export * from "babylonjs/Materials/effect";
  48506. export * from "babylonjs/Materials/fresnelParameters";
  48507. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48508. export * from "babylonjs/Materials/material";
  48509. export * from "babylonjs/Materials/materialDefines";
  48510. export * from "babylonjs/Materials/materialHelper";
  48511. export * from "babylonjs/Materials/multiMaterial";
  48512. export * from "babylonjs/Materials/PBR/index";
  48513. export * from "babylonjs/Materials/pushMaterial";
  48514. export * from "babylonjs/Materials/shaderMaterial";
  48515. export * from "babylonjs/Materials/standardMaterial";
  48516. export * from "babylonjs/Materials/Textures/index";
  48517. export * from "babylonjs/Materials/uniformBuffer";
  48518. export * from "babylonjs/Materials/materialFlags";
  48519. }
  48520. declare module "babylonjs/Maths/index" {
  48521. export * from "babylonjs/Maths/math.scalar";
  48522. export * from "babylonjs/Maths/math";
  48523. export * from "babylonjs/Maths/sphericalPolynomial";
  48524. }
  48525. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48526. import { IDisposable } from "babylonjs/scene";
  48527. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48528. /**
  48529. * Configuration for Draco compression
  48530. */
  48531. export interface IDracoCompressionConfiguration {
  48532. /**
  48533. * Configuration for the decoder.
  48534. */
  48535. decoder?: {
  48536. /**
  48537. * The url to the WebAssembly module.
  48538. */
  48539. wasmUrl?: string;
  48540. /**
  48541. * The url to the WebAssembly binary.
  48542. */
  48543. wasmBinaryUrl?: string;
  48544. /**
  48545. * The url to the fallback JavaScript module.
  48546. */
  48547. fallbackUrl?: string;
  48548. };
  48549. }
  48550. /**
  48551. * Draco compression (https://google.github.io/draco/)
  48552. *
  48553. * This class wraps the Draco module.
  48554. *
  48555. * **Encoder**
  48556. *
  48557. * The encoder is not currently implemented.
  48558. *
  48559. * **Decoder**
  48560. *
  48561. * 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.
  48562. *
  48563. * To update the configuration, use the following code:
  48564. * ```javascript
  48565. * DracoCompression.Configuration = {
  48566. * decoder: {
  48567. * wasmUrl: "<url to the WebAssembly library>",
  48568. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48569. * fallbackUrl: "<url to the fallback JavaScript library>",
  48570. * }
  48571. * };
  48572. * ```
  48573. *
  48574. * 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.
  48575. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48576. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48577. *
  48578. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48579. * ```javascript
  48580. * var dracoCompression = new DracoCompression();
  48581. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48582. * [VertexBuffer.PositionKind]: 0
  48583. * });
  48584. * ```
  48585. *
  48586. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48587. */
  48588. export class DracoCompression implements IDisposable {
  48589. private static _DecoderModulePromise;
  48590. /**
  48591. * The configuration. Defaults to the following urls:
  48592. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48593. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48594. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48595. */
  48596. static Configuration: IDracoCompressionConfiguration;
  48597. /**
  48598. * Returns true if the decoder is available.
  48599. */
  48600. static readonly DecoderAvailable: boolean;
  48601. /**
  48602. * Constructor
  48603. */
  48604. constructor();
  48605. /**
  48606. * Stop all async operations and release resources.
  48607. */
  48608. dispose(): void;
  48609. /**
  48610. * Decode Draco compressed mesh data to vertex data.
  48611. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48612. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48613. * @returns A promise that resolves with the decoded vertex data
  48614. */
  48615. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48616. [kind: string]: number;
  48617. }): Promise<VertexData>;
  48618. private static _GetDecoderModule;
  48619. private static _LoadScriptAsync;
  48620. private static _LoadFileAsync;
  48621. }
  48622. }
  48623. declare module "babylonjs/Meshes/Compression/index" {
  48624. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48625. }
  48626. declare module "babylonjs/Meshes/csg" {
  48627. import { Nullable } from "babylonjs/types";
  48628. import { Scene } from "babylonjs/scene";
  48629. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48630. import { Mesh } from "babylonjs/Meshes/mesh";
  48631. import { Material } from "babylonjs/Materials/material";
  48632. /**
  48633. * Class for building Constructive Solid Geometry
  48634. */
  48635. export class CSG {
  48636. private polygons;
  48637. /**
  48638. * The world matrix
  48639. */
  48640. matrix: Matrix;
  48641. /**
  48642. * Stores the position
  48643. */
  48644. position: Vector3;
  48645. /**
  48646. * Stores the rotation
  48647. */
  48648. rotation: Vector3;
  48649. /**
  48650. * Stores the rotation quaternion
  48651. */
  48652. rotationQuaternion: Nullable<Quaternion>;
  48653. /**
  48654. * Stores the scaling vector
  48655. */
  48656. scaling: Vector3;
  48657. /**
  48658. * Convert the Mesh to CSG
  48659. * @param mesh The Mesh to convert to CSG
  48660. * @returns A new CSG from the Mesh
  48661. */
  48662. static FromMesh(mesh: Mesh): CSG;
  48663. /**
  48664. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48665. * @param polygons Polygons used to construct a CSG solid
  48666. */
  48667. private static FromPolygons;
  48668. /**
  48669. * Clones, or makes a deep copy, of the CSG
  48670. * @returns A new CSG
  48671. */
  48672. clone(): CSG;
  48673. /**
  48674. * Unions this CSG with another CSG
  48675. * @param csg The CSG to union against this CSG
  48676. * @returns The unioned CSG
  48677. */
  48678. union(csg: CSG): CSG;
  48679. /**
  48680. * Unions this CSG with another CSG in place
  48681. * @param csg The CSG to union against this CSG
  48682. */
  48683. unionInPlace(csg: CSG): void;
  48684. /**
  48685. * Subtracts this CSG with another CSG
  48686. * @param csg The CSG to subtract against this CSG
  48687. * @returns A new CSG
  48688. */
  48689. subtract(csg: CSG): CSG;
  48690. /**
  48691. * Subtracts this CSG with another CSG in place
  48692. * @param csg The CSG to subtact against this CSG
  48693. */
  48694. subtractInPlace(csg: CSG): void;
  48695. /**
  48696. * Intersect this CSG with another CSG
  48697. * @param csg The CSG to intersect against this CSG
  48698. * @returns A new CSG
  48699. */
  48700. intersect(csg: CSG): CSG;
  48701. /**
  48702. * Intersects this CSG with another CSG in place
  48703. * @param csg The CSG to intersect against this CSG
  48704. */
  48705. intersectInPlace(csg: CSG): void;
  48706. /**
  48707. * Return a new CSG solid with solid and empty space switched. This solid is
  48708. * not modified.
  48709. * @returns A new CSG solid with solid and empty space switched
  48710. */
  48711. inverse(): CSG;
  48712. /**
  48713. * Inverses the CSG in place
  48714. */
  48715. inverseInPlace(): void;
  48716. /**
  48717. * This is used to keep meshes transformations so they can be restored
  48718. * when we build back a Babylon Mesh
  48719. * NB : All CSG operations are performed in world coordinates
  48720. * @param csg The CSG to copy the transform attributes from
  48721. * @returns This CSG
  48722. */
  48723. copyTransformAttributes(csg: CSG): CSG;
  48724. /**
  48725. * Build Raw mesh from CSG
  48726. * Coordinates here are in world space
  48727. * @param name The name of the mesh geometry
  48728. * @param scene The Scene
  48729. * @param keepSubMeshes Specifies if the submeshes should be kept
  48730. * @returns A new Mesh
  48731. */
  48732. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48733. /**
  48734. * Build Mesh from CSG taking material and transforms into account
  48735. * @param name The name of the Mesh
  48736. * @param material The material of the Mesh
  48737. * @param scene The Scene
  48738. * @param keepSubMeshes Specifies if submeshes should be kept
  48739. * @returns The new Mesh
  48740. */
  48741. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48742. }
  48743. }
  48744. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  48745. import { Nullable } from "babylonjs/types";
  48746. import { Scene } from "babylonjs/scene";
  48747. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  48748. import { Mesh } from "babylonjs/Meshes/mesh";
  48749. /**
  48750. * Class containing static functions to help procedurally build meshes
  48751. */
  48752. export class RibbonBuilder {
  48753. /**
  48754. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48755. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48756. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48757. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48758. * * 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
  48759. * * 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
  48760. * * 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
  48761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48763. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48764. * * 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
  48765. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48766. * * 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
  48767. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48769. * @param name defines the name of the mesh
  48770. * @param options defines the options used to create the mesh
  48771. * @param scene defines the hosting scene
  48772. * @returns the ribbon mesh
  48773. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48775. */
  48776. static CreateRibbon(name: string, options: {
  48777. pathArray: Vector3[][];
  48778. closeArray?: boolean;
  48779. closePath?: boolean;
  48780. offset?: number;
  48781. updatable?: boolean;
  48782. sideOrientation?: number;
  48783. frontUVs?: Vector4;
  48784. backUVs?: Vector4;
  48785. instance?: Mesh;
  48786. invertUV?: boolean;
  48787. uvs?: Vector2[];
  48788. colors?: Color4[];
  48789. }, scene?: Nullable<Scene>): Mesh;
  48790. }
  48791. }
  48792. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  48793. import { Vector4 } from "babylonjs/Maths/math";
  48794. import { Mesh } from "babylonjs/Meshes/mesh";
  48795. /**
  48796. * Class containing static functions to help procedurally build meshes
  48797. */
  48798. export class TorusKnotBuilder {
  48799. /**
  48800. * Creates a torus knot mesh
  48801. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48802. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48803. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48804. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48808. * @param name defines the name of the mesh
  48809. * @param options defines the options used to create the mesh
  48810. * @param scene defines the hosting scene
  48811. * @returns the torus knot mesh
  48812. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48813. */
  48814. static CreateTorusKnot(name: string, options: {
  48815. radius?: number;
  48816. tube?: number;
  48817. radialSegments?: number;
  48818. tubularSegments?: number;
  48819. p?: number;
  48820. q?: number;
  48821. updatable?: boolean;
  48822. sideOrientation?: number;
  48823. frontUVs?: Vector4;
  48824. backUVs?: Vector4;
  48825. }, scene: any): Mesh;
  48826. }
  48827. }
  48828. declare module "babylonjs/Meshes/polygonMesh" {
  48829. import { Scene } from "babylonjs/scene";
  48830. import { Vector2, Path2 } from "babylonjs/Maths/math";
  48831. import { Mesh } from "babylonjs/Meshes/mesh";
  48832. /**
  48833. * Polygon
  48834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48835. */
  48836. export class Polygon {
  48837. /**
  48838. * Creates a rectangle
  48839. * @param xmin bottom X coord
  48840. * @param ymin bottom Y coord
  48841. * @param xmax top X coord
  48842. * @param ymax top Y coord
  48843. * @returns points that make the resulting rectation
  48844. */
  48845. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48846. /**
  48847. * Creates a circle
  48848. * @param radius radius of circle
  48849. * @param cx scale in x
  48850. * @param cy scale in y
  48851. * @param numberOfSides number of sides that make up the circle
  48852. * @returns points that make the resulting circle
  48853. */
  48854. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48855. /**
  48856. * Creates a polygon from input string
  48857. * @param input Input polygon data
  48858. * @returns the parsed points
  48859. */
  48860. static Parse(input: string): Vector2[];
  48861. /**
  48862. * Starts building a polygon from x and y coordinates
  48863. * @param x x coordinate
  48864. * @param y y coordinate
  48865. * @returns the started path2
  48866. */
  48867. static StartingAt(x: number, y: number): Path2;
  48868. }
  48869. /**
  48870. * Builds a polygon
  48871. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48872. */
  48873. export class PolygonMeshBuilder {
  48874. private _points;
  48875. private _outlinepoints;
  48876. private _holes;
  48877. private _name;
  48878. private _scene;
  48879. private _epoints;
  48880. private _eholes;
  48881. private _addToepoint;
  48882. /**
  48883. * Babylon reference to the earcut plugin.
  48884. */
  48885. bjsEarcut: any;
  48886. /**
  48887. * Creates a PolygonMeshBuilder
  48888. * @param name name of the builder
  48889. * @param contours Path of the polygon
  48890. * @param scene scene to add to
  48891. * @param earcutInjection can be used to inject your own earcut reference
  48892. */
  48893. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  48894. /**
  48895. * Adds a whole within the polygon
  48896. * @param hole Array of points defining the hole
  48897. * @returns this
  48898. */
  48899. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48900. /**
  48901. * Creates the polygon
  48902. * @param updatable If the mesh should be updatable
  48903. * @param depth The depth of the mesh created
  48904. * @returns the created mesh
  48905. */
  48906. build(updatable?: boolean, depth?: number): Mesh;
  48907. /**
  48908. * Adds a side to the polygon
  48909. * @param positions points that make the polygon
  48910. * @param normals normals of the polygon
  48911. * @param uvs uvs of the polygon
  48912. * @param indices indices of the polygon
  48913. * @param bounds bounds of the polygon
  48914. * @param points points of the polygon
  48915. * @param depth depth of the polygon
  48916. * @param flip flip of the polygon
  48917. */
  48918. private addSide;
  48919. }
  48920. }
  48921. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  48922. import { Scene } from "babylonjs/scene";
  48923. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  48924. import { Mesh } from "babylonjs/Meshes/mesh";
  48925. /**
  48926. * Class containing static functions to help procedurally build meshes
  48927. */
  48928. export class PolygonBuilder {
  48929. /**
  48930. * Creates a polygon mesh
  48931. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48932. * * 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
  48933. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48936. * * Remember you can only change the shape positions, not their number when updating a polygon
  48937. * @param name defines the name of the mesh
  48938. * @param options defines the options used to create the mesh
  48939. * @param scene defines the hosting scene
  48940. * @param earcutInjection can be used to inject your own earcut reference
  48941. * @returns the polygon mesh
  48942. */
  48943. static CreatePolygon(name: string, options: {
  48944. shape: Vector3[];
  48945. holes?: Vector3[][];
  48946. depth?: number;
  48947. faceUV?: Vector4[];
  48948. faceColors?: Color4[];
  48949. updatable?: boolean;
  48950. sideOrientation?: number;
  48951. frontUVs?: Vector4;
  48952. backUVs?: Vector4;
  48953. }, scene: Scene, earcutInjection?: any): Mesh;
  48954. /**
  48955. * Creates an extruded polygon mesh, with depth in the Y direction.
  48956. * * 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)
  48957. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48958. * @param name defines the name of the mesh
  48959. * @param options defines the options used to create the mesh
  48960. * @param scene defines the hosting scene
  48961. * @param earcutInjection can be used to inject your own earcut reference
  48962. * @returns the polygon mesh
  48963. */
  48964. static ExtrudePolygon(name: string, options: {
  48965. shape: Vector3[];
  48966. holes?: Vector3[][];
  48967. depth?: number;
  48968. faceUV?: Vector4[];
  48969. faceColors?: Color4[];
  48970. updatable?: boolean;
  48971. sideOrientation?: number;
  48972. frontUVs?: Vector4;
  48973. backUVs?: Vector4;
  48974. }, scene: Scene, earcutInjection?: any): Mesh;
  48975. }
  48976. }
  48977. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  48978. import { Nullable } from "babylonjs/types";
  48979. import { Scene } from "babylonjs/scene";
  48980. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48981. import { Mesh } from "babylonjs/Meshes/mesh";
  48982. /**
  48983. * Class containing static functions to help procedurally build meshes
  48984. */
  48985. export class ShapeBuilder {
  48986. /**
  48987. * 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.
  48988. * * 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.
  48989. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48990. * * 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.
  48991. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48992. * * 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
  48993. * * 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
  48994. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48999. * @param name defines the name of the mesh
  49000. * @param options defines the options used to create the mesh
  49001. * @param scene defines the hosting scene
  49002. * @returns the extruded shape mesh
  49003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49005. */
  49006. static ExtrudeShape(name: string, options: {
  49007. shape: Vector3[];
  49008. path: Vector3[];
  49009. scale?: number;
  49010. rotation?: number;
  49011. cap?: number;
  49012. updatable?: boolean;
  49013. sideOrientation?: number;
  49014. frontUVs?: Vector4;
  49015. backUVs?: Vector4;
  49016. instance?: Mesh;
  49017. invertUV?: boolean;
  49018. }, scene?: Nullable<Scene>): Mesh;
  49019. /**
  49020. * Creates an custom extruded shape mesh.
  49021. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49022. * * 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.
  49023. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49024. * * 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
  49025. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49026. * * 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
  49027. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49028. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49029. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49030. * * 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
  49031. * * 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
  49032. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49037. * @param name defines the name of the mesh
  49038. * @param options defines the options used to create the mesh
  49039. * @param scene defines the hosting scene
  49040. * @returns the custom extruded shape mesh
  49041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49044. */
  49045. static ExtrudeShapeCustom(name: string, options: {
  49046. shape: Vector3[];
  49047. path: Vector3[];
  49048. scaleFunction?: any;
  49049. rotationFunction?: any;
  49050. ribbonCloseArray?: boolean;
  49051. ribbonClosePath?: boolean;
  49052. cap?: number;
  49053. updatable?: boolean;
  49054. sideOrientation?: number;
  49055. frontUVs?: Vector4;
  49056. backUVs?: Vector4;
  49057. instance?: Mesh;
  49058. invertUV?: boolean;
  49059. }, scene: Scene): Mesh;
  49060. private static _ExtrudeShapeGeneric;
  49061. }
  49062. }
  49063. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49064. import { Scene } from "babylonjs/scene";
  49065. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49066. import { Mesh } from "babylonjs/Meshes/mesh";
  49067. /**
  49068. * Class containing static functions to help procedurally build meshes
  49069. */
  49070. export class LatheBuilder {
  49071. /**
  49072. * Creates lathe mesh.
  49073. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49074. * * 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
  49075. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49076. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49077. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49078. * * 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
  49079. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49080. * * 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
  49081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49083. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49085. * @param name defines the name of the mesh
  49086. * @param options defines the options used to create the mesh
  49087. * @param scene defines the hosting scene
  49088. * @returns the lathe mesh
  49089. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49090. */
  49091. static CreateLathe(name: string, options: {
  49092. shape: Vector3[];
  49093. radius?: number;
  49094. tessellation?: number;
  49095. clip?: number;
  49096. arc?: number;
  49097. closed?: boolean;
  49098. updatable?: boolean;
  49099. sideOrientation?: number;
  49100. frontUVs?: Vector4;
  49101. backUVs?: Vector4;
  49102. cap?: number;
  49103. invertUV?: boolean;
  49104. }, scene: Scene): Mesh;
  49105. }
  49106. }
  49107. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49108. import { Scene } from "babylonjs/scene";
  49109. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49110. import { Mesh } from "babylonjs/Meshes/mesh";
  49111. /**
  49112. * Class containing static functions to help procedurally build meshes
  49113. */
  49114. export class TubeBuilder {
  49115. /**
  49116. * Creates a tube mesh.
  49117. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49118. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49119. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49120. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49121. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49122. * * 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)
  49123. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49124. * * 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
  49125. * * 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
  49126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49128. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49130. * @param name defines the name of the mesh
  49131. * @param options defines the options used to create the mesh
  49132. * @param scene defines the hosting scene
  49133. * @returns the tube mesh
  49134. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49135. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49136. */
  49137. static CreateTube(name: string, options: {
  49138. path: Vector3[];
  49139. radius?: number;
  49140. tessellation?: number;
  49141. radiusFunction?: {
  49142. (i: number, distance: number): number;
  49143. };
  49144. cap?: number;
  49145. arc?: number;
  49146. updatable?: boolean;
  49147. sideOrientation?: number;
  49148. frontUVs?: Vector4;
  49149. backUVs?: Vector4;
  49150. instance?: Mesh;
  49151. invertUV?: boolean;
  49152. }, scene: Scene): Mesh;
  49153. }
  49154. }
  49155. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49156. import { Scene } from "babylonjs/scene";
  49157. import { Vector4 } from "babylonjs/Maths/math";
  49158. import { Mesh } from "babylonjs/Meshes/mesh";
  49159. /**
  49160. * Class containing static functions to help procedurally build meshes
  49161. */
  49162. export class IcoSphereBuilder {
  49163. /**
  49164. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49165. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49166. * * 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`)
  49167. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49168. * * 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
  49169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49172. * @param name defines the name of the mesh
  49173. * @param options defines the options used to create the mesh
  49174. * @param scene defines the hosting scene
  49175. * @returns the icosahedron mesh
  49176. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49177. */
  49178. static CreateIcoSphere(name: string, options: {
  49179. radius?: number;
  49180. radiusX?: number;
  49181. radiusY?: number;
  49182. radiusZ?: number;
  49183. flat?: boolean;
  49184. subdivisions?: number;
  49185. sideOrientation?: number;
  49186. frontUVs?: Vector4;
  49187. backUVs?: Vector4;
  49188. updatable?: boolean;
  49189. }, scene: Scene): Mesh;
  49190. }
  49191. }
  49192. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49193. import { Vector3 } from "babylonjs/Maths/math";
  49194. import { Mesh } from "babylonjs/Meshes/mesh";
  49195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49196. /**
  49197. * Class containing static functions to help procedurally build meshes
  49198. */
  49199. export class DecalBuilder {
  49200. /**
  49201. * Creates a decal mesh.
  49202. * 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
  49203. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49204. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49205. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49206. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49207. * @param name defines the name of the mesh
  49208. * @param sourceMesh defines the mesh where the decal must be applied
  49209. * @param options defines the options used to create the mesh
  49210. * @param scene defines the hosting scene
  49211. * @returns the decal mesh
  49212. * @see https://doc.babylonjs.com/how_to/decals
  49213. */
  49214. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49215. position?: Vector3;
  49216. normal?: Vector3;
  49217. size?: Vector3;
  49218. angle?: number;
  49219. }): Mesh;
  49220. }
  49221. }
  49222. declare module "babylonjs/Meshes/meshBuilder" {
  49223. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49224. import { Nullable } from "babylonjs/types";
  49225. import { Scene } from "babylonjs/scene";
  49226. import { Mesh } from "babylonjs/Meshes/mesh";
  49227. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49228. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49230. /**
  49231. * Class containing static functions to help procedurally build meshes
  49232. */
  49233. export class MeshBuilder {
  49234. /**
  49235. * Creates a box mesh
  49236. * * The parameter `size` sets the size (float) of each box side (default 1)
  49237. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49238. * * 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)
  49239. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49244. * @param name defines the name of the mesh
  49245. * @param options defines the options used to create the mesh
  49246. * @param scene defines the hosting scene
  49247. * @returns the box mesh
  49248. */
  49249. static CreateBox(name: string, options: {
  49250. size?: number;
  49251. width?: number;
  49252. height?: number;
  49253. depth?: number;
  49254. faceUV?: Vector4[];
  49255. faceColors?: Color4[];
  49256. sideOrientation?: number;
  49257. frontUVs?: Vector4;
  49258. backUVs?: Vector4;
  49259. updatable?: boolean;
  49260. }, scene?: Nullable<Scene>): Mesh;
  49261. /**
  49262. * Creates a sphere mesh
  49263. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49264. * * 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`)
  49265. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49266. * * 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
  49267. * * 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)
  49268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49271. * @param name defines the name of the mesh
  49272. * @param options defines the options used to create the mesh
  49273. * @param scene defines the hosting scene
  49274. * @returns the sphere mesh
  49275. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49276. */
  49277. static CreateSphere(name: string, options: {
  49278. segments?: number;
  49279. diameter?: number;
  49280. diameterX?: number;
  49281. diameterY?: number;
  49282. diameterZ?: number;
  49283. arc?: number;
  49284. slice?: number;
  49285. sideOrientation?: number;
  49286. frontUVs?: Vector4;
  49287. backUVs?: Vector4;
  49288. updatable?: boolean;
  49289. }, scene: any): Mesh;
  49290. /**
  49291. * Creates a plane polygonal mesh. By default, this is a disc
  49292. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49293. * * 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
  49294. * * 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
  49295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49298. * @param name defines the name of the mesh
  49299. * @param options defines the options used to create the mesh
  49300. * @param scene defines the hosting scene
  49301. * @returns the plane polygonal mesh
  49302. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49303. */
  49304. static CreateDisc(name: string, options: {
  49305. radius?: number;
  49306. tessellation?: number;
  49307. arc?: number;
  49308. updatable?: boolean;
  49309. sideOrientation?: number;
  49310. frontUVs?: Vector4;
  49311. backUVs?: Vector4;
  49312. }, scene?: Nullable<Scene>): Mesh;
  49313. /**
  49314. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49315. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49316. * * 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`)
  49317. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49318. * * 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
  49319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49322. * @param name defines the name of the mesh
  49323. * @param options defines the options used to create the mesh
  49324. * @param scene defines the hosting scene
  49325. * @returns the icosahedron mesh
  49326. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49327. */
  49328. static CreateIcoSphere(name: string, options: {
  49329. radius?: number;
  49330. radiusX?: number;
  49331. radiusY?: number;
  49332. radiusZ?: number;
  49333. flat?: boolean;
  49334. subdivisions?: number;
  49335. sideOrientation?: number;
  49336. frontUVs?: Vector4;
  49337. backUVs?: Vector4;
  49338. updatable?: boolean;
  49339. }, scene: Scene): Mesh;
  49340. /**
  49341. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49342. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49343. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49344. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49345. * * 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
  49346. * * 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
  49347. * * 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
  49348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49351. * * 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
  49352. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49353. * * 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
  49354. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49356. * @param name defines the name of the mesh
  49357. * @param options defines the options used to create the mesh
  49358. * @param scene defines the hosting scene
  49359. * @returns the ribbon mesh
  49360. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49362. */
  49363. static CreateRibbon(name: string, options: {
  49364. pathArray: Vector3[][];
  49365. closeArray?: boolean;
  49366. closePath?: boolean;
  49367. offset?: number;
  49368. updatable?: boolean;
  49369. sideOrientation?: number;
  49370. frontUVs?: Vector4;
  49371. backUVs?: Vector4;
  49372. instance?: Mesh;
  49373. invertUV?: boolean;
  49374. uvs?: Vector2[];
  49375. colors?: Color4[];
  49376. }, scene?: Nullable<Scene>): Mesh;
  49377. /**
  49378. * Creates a cylinder or a cone mesh
  49379. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49380. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49381. * * 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.
  49382. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49383. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49384. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49385. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49386. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49387. * * 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).
  49388. * * 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
  49389. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49390. * * 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
  49391. * * 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.
  49392. * * If `enclose` is false, a ring surface is one element.
  49393. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49394. * * 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
  49395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49398. * @param name defines the name of the mesh
  49399. * @param options defines the options used to create the mesh
  49400. * @param scene defines the hosting scene
  49401. * @returns the cylinder mesh
  49402. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49403. */
  49404. static CreateCylinder(name: string, options: {
  49405. height?: number;
  49406. diameterTop?: number;
  49407. diameterBottom?: number;
  49408. diameter?: number;
  49409. tessellation?: number;
  49410. subdivisions?: number;
  49411. arc?: number;
  49412. faceColors?: Color4[];
  49413. faceUV?: Vector4[];
  49414. updatable?: boolean;
  49415. hasRings?: boolean;
  49416. enclose?: boolean;
  49417. sideOrientation?: number;
  49418. frontUVs?: Vector4;
  49419. backUVs?: Vector4;
  49420. }, scene: any): Mesh;
  49421. /**
  49422. * Creates a torus mesh
  49423. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49424. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49425. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49429. * @param name defines the name of the mesh
  49430. * @param options defines the options used to create the mesh
  49431. * @param scene defines the hosting scene
  49432. * @returns the torus mesh
  49433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49434. */
  49435. static CreateTorus(name: string, options: {
  49436. diameter?: number;
  49437. thickness?: number;
  49438. tessellation?: number;
  49439. updatable?: boolean;
  49440. sideOrientation?: number;
  49441. frontUVs?: Vector4;
  49442. backUVs?: Vector4;
  49443. }, scene: any): Mesh;
  49444. /**
  49445. * Creates a torus knot mesh
  49446. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49447. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49448. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49449. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49453. * @param name defines the name of the mesh
  49454. * @param options defines the options used to create the mesh
  49455. * @param scene defines the hosting scene
  49456. * @returns the torus knot mesh
  49457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49458. */
  49459. static CreateTorusKnot(name: string, options: {
  49460. radius?: number;
  49461. tube?: number;
  49462. radialSegments?: number;
  49463. tubularSegments?: number;
  49464. p?: number;
  49465. q?: number;
  49466. updatable?: boolean;
  49467. sideOrientation?: number;
  49468. frontUVs?: Vector4;
  49469. backUVs?: Vector4;
  49470. }, scene: any): Mesh;
  49471. /**
  49472. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49473. * * 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
  49474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49475. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49476. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49477. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49479. * * 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
  49480. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49483. * @param name defines the name of the new line system
  49484. * @param options defines the options used to create the line system
  49485. * @param scene defines the hosting scene
  49486. * @returns a new line system mesh
  49487. */
  49488. static CreateLineSystem(name: string, options: {
  49489. lines: Vector3[][];
  49490. updatable?: boolean;
  49491. instance?: Nullable<LinesMesh>;
  49492. colors?: Nullable<Color4[][]>;
  49493. useVertexAlpha?: boolean;
  49494. }, scene: Nullable<Scene>): LinesMesh;
  49495. /**
  49496. * Creates a line mesh
  49497. * 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
  49498. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49499. * * The parameter `points` is an array successive Vector3
  49500. * * 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
  49501. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49502. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49503. * * When updating an instance, remember that only point positions can change, not the number of points
  49504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49506. * @param name defines the name of the new line system
  49507. * @param options defines the options used to create the line system
  49508. * @param scene defines the hosting scene
  49509. * @returns a new line mesh
  49510. */
  49511. static CreateLines(name: string, options: {
  49512. points: Vector3[];
  49513. updatable?: boolean;
  49514. instance?: Nullable<LinesMesh>;
  49515. colors?: Color4[];
  49516. useVertexAlpha?: boolean;
  49517. }, scene?: Nullable<Scene>): LinesMesh;
  49518. /**
  49519. * Creates a dashed line mesh
  49520. * * 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
  49521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49522. * * The parameter `points` is an array successive Vector3
  49523. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49524. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49525. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49526. * * 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
  49527. * * When updating an instance, remember that only point positions can change, not the number of points
  49528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49529. * @param name defines the name of the mesh
  49530. * @param options defines the options used to create the mesh
  49531. * @param scene defines the hosting scene
  49532. * @returns the dashed line mesh
  49533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49534. */
  49535. static CreateDashedLines(name: string, options: {
  49536. points: Vector3[];
  49537. dashSize?: number;
  49538. gapSize?: number;
  49539. dashNb?: number;
  49540. updatable?: boolean;
  49541. instance?: LinesMesh;
  49542. }, scene?: Nullable<Scene>): LinesMesh;
  49543. /**
  49544. * 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.
  49545. * * 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.
  49546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49547. * * 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.
  49548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49549. * * 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
  49550. * * 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
  49551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49556. * @param name defines the name of the mesh
  49557. * @param options defines the options used to create the mesh
  49558. * @param scene defines the hosting scene
  49559. * @returns the extruded shape mesh
  49560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49562. */
  49563. static ExtrudeShape(name: string, options: {
  49564. shape: Vector3[];
  49565. path: Vector3[];
  49566. scale?: number;
  49567. rotation?: number;
  49568. cap?: number;
  49569. updatable?: boolean;
  49570. sideOrientation?: number;
  49571. frontUVs?: Vector4;
  49572. backUVs?: Vector4;
  49573. instance?: Mesh;
  49574. invertUV?: boolean;
  49575. }, scene?: Nullable<Scene>): Mesh;
  49576. /**
  49577. * Creates an custom extruded shape mesh.
  49578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49579. * * 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.
  49580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49581. * * 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
  49582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49583. * * 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
  49584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49587. * * 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
  49588. * * 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
  49589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49594. * @param name defines the name of the mesh
  49595. * @param options defines the options used to create the mesh
  49596. * @param scene defines the hosting scene
  49597. * @returns the custom extruded shape mesh
  49598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49601. */
  49602. static ExtrudeShapeCustom(name: string, options: {
  49603. shape: Vector3[];
  49604. path: Vector3[];
  49605. scaleFunction?: any;
  49606. rotationFunction?: any;
  49607. ribbonCloseArray?: boolean;
  49608. ribbonClosePath?: boolean;
  49609. cap?: number;
  49610. updatable?: boolean;
  49611. sideOrientation?: number;
  49612. frontUVs?: Vector4;
  49613. backUVs?: Vector4;
  49614. instance?: Mesh;
  49615. invertUV?: boolean;
  49616. }, scene: Scene): Mesh;
  49617. /**
  49618. * Creates lathe mesh.
  49619. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49620. * * 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
  49621. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49622. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49623. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49624. * * 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
  49625. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49626. * * 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
  49627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49631. * @param name defines the name of the mesh
  49632. * @param options defines the options used to create the mesh
  49633. * @param scene defines the hosting scene
  49634. * @returns the lathe mesh
  49635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49636. */
  49637. static CreateLathe(name: string, options: {
  49638. shape: Vector3[];
  49639. radius?: number;
  49640. tessellation?: number;
  49641. clip?: number;
  49642. arc?: number;
  49643. closed?: boolean;
  49644. updatable?: boolean;
  49645. sideOrientation?: number;
  49646. frontUVs?: Vector4;
  49647. backUVs?: Vector4;
  49648. cap?: number;
  49649. invertUV?: boolean;
  49650. }, scene: Scene): Mesh;
  49651. /**
  49652. * Creates a plane mesh
  49653. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49654. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49655. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49659. * @param name defines the name of the mesh
  49660. * @param options defines the options used to create the mesh
  49661. * @param scene defines the hosting scene
  49662. * @returns the plane mesh
  49663. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49664. */
  49665. static CreatePlane(name: string, options: {
  49666. size?: number;
  49667. width?: number;
  49668. height?: number;
  49669. sideOrientation?: number;
  49670. frontUVs?: Vector4;
  49671. backUVs?: Vector4;
  49672. updatable?: boolean;
  49673. sourcePlane?: Plane;
  49674. }, scene: Scene): Mesh;
  49675. /**
  49676. * Creates a ground mesh
  49677. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49678. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49680. * @param name defines the name of the mesh
  49681. * @param options defines the options used to create the mesh
  49682. * @param scene defines the hosting scene
  49683. * @returns the ground mesh
  49684. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49685. */
  49686. static CreateGround(name: string, options: {
  49687. width?: number;
  49688. height?: number;
  49689. subdivisions?: number;
  49690. subdivisionsX?: number;
  49691. subdivisionsY?: number;
  49692. updatable?: boolean;
  49693. }, scene: any): Mesh;
  49694. /**
  49695. * Creates a tiled ground mesh
  49696. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49697. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49698. * * 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
  49699. * * 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
  49700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49701. * @param name defines the name of the mesh
  49702. * @param options defines the options used to create the mesh
  49703. * @param scene defines the hosting scene
  49704. * @returns the tiled ground mesh
  49705. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49706. */
  49707. static CreateTiledGround(name: string, options: {
  49708. xmin: number;
  49709. zmin: number;
  49710. xmax: number;
  49711. zmax: number;
  49712. subdivisions?: {
  49713. w: number;
  49714. h: number;
  49715. };
  49716. precision?: {
  49717. w: number;
  49718. h: number;
  49719. };
  49720. updatable?: boolean;
  49721. }, scene: Scene): Mesh;
  49722. /**
  49723. * Creates a ground mesh from a height map
  49724. * * The parameter `url` sets the URL of the height map image resource.
  49725. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49726. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49727. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49728. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49729. * * 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.
  49730. * * 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).
  49731. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49733. * @param name defines the name of the mesh
  49734. * @param url defines the url to the height map
  49735. * @param options defines the options used to create the mesh
  49736. * @param scene defines the hosting scene
  49737. * @returns the ground mesh
  49738. * @see https://doc.babylonjs.com/babylon101/height_map
  49739. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49740. */
  49741. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49742. width?: number;
  49743. height?: number;
  49744. subdivisions?: number;
  49745. minHeight?: number;
  49746. maxHeight?: number;
  49747. colorFilter?: Color3;
  49748. alphaFilter?: number;
  49749. updatable?: boolean;
  49750. onReady?: (mesh: GroundMesh) => void;
  49751. }, scene: Scene): GroundMesh;
  49752. /**
  49753. * Creates a polygon mesh
  49754. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49755. * * 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
  49756. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49759. * * Remember you can only change the shape positions, not their number when updating a polygon
  49760. * @param name defines the name of the mesh
  49761. * @param options defines the options used to create the mesh
  49762. * @param scene defines the hosting scene
  49763. * @param earcutInjection can be used to inject your own earcut reference
  49764. * @returns the polygon mesh
  49765. */
  49766. static CreatePolygon(name: string, options: {
  49767. shape: Vector3[];
  49768. holes?: Vector3[][];
  49769. depth?: number;
  49770. faceUV?: Vector4[];
  49771. faceColors?: Color4[];
  49772. updatable?: boolean;
  49773. sideOrientation?: number;
  49774. frontUVs?: Vector4;
  49775. backUVs?: Vector4;
  49776. }, scene: Scene, earcutInjection?: any): Mesh;
  49777. /**
  49778. * Creates an extruded polygon mesh, with depth in the Y direction.
  49779. * * 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)
  49780. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49781. * @param name defines the name of the mesh
  49782. * @param options defines the options used to create the mesh
  49783. * @param scene defines the hosting scene
  49784. * @param earcutInjection can be used to inject your own earcut reference
  49785. * @returns the polygon mesh
  49786. */
  49787. static ExtrudePolygon(name: string, options: {
  49788. shape: Vector3[];
  49789. holes?: Vector3[][];
  49790. depth?: number;
  49791. faceUV?: Vector4[];
  49792. faceColors?: Color4[];
  49793. updatable?: boolean;
  49794. sideOrientation?: number;
  49795. frontUVs?: Vector4;
  49796. backUVs?: Vector4;
  49797. }, scene: Scene, earcutInjection?: any): Mesh;
  49798. /**
  49799. * Creates a tube mesh.
  49800. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49801. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49802. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49803. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49804. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49805. * * 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)
  49806. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49807. * * 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
  49808. * * 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
  49809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49813. * @param name defines the name of the mesh
  49814. * @param options defines the options used to create the mesh
  49815. * @param scene defines the hosting scene
  49816. * @returns the tube mesh
  49817. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49818. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49819. */
  49820. static CreateTube(name: string, options: {
  49821. path: Vector3[];
  49822. radius?: number;
  49823. tessellation?: number;
  49824. radiusFunction?: {
  49825. (i: number, distance: number): number;
  49826. };
  49827. cap?: number;
  49828. arc?: number;
  49829. updatable?: boolean;
  49830. sideOrientation?: number;
  49831. frontUVs?: Vector4;
  49832. backUVs?: Vector4;
  49833. instance?: Mesh;
  49834. invertUV?: boolean;
  49835. }, scene: Scene): Mesh;
  49836. /**
  49837. * Creates a polyhedron mesh
  49838. * * 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
  49839. * * The parameter `size` (positive float, default 1) sets the polygon size
  49840. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49841. * * 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`
  49842. * * 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
  49843. * * 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)`)
  49844. * * 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
  49845. * * 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
  49846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49849. * @param name defines the name of the mesh
  49850. * @param options defines the options used to create the mesh
  49851. * @param scene defines the hosting scene
  49852. * @returns the polyhedron mesh
  49853. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49854. */
  49855. static CreatePolyhedron(name: string, options: {
  49856. type?: number;
  49857. size?: number;
  49858. sizeX?: number;
  49859. sizeY?: number;
  49860. sizeZ?: number;
  49861. custom?: any;
  49862. faceUV?: Vector4[];
  49863. faceColors?: Color4[];
  49864. flat?: boolean;
  49865. updatable?: boolean;
  49866. sideOrientation?: number;
  49867. frontUVs?: Vector4;
  49868. backUVs?: Vector4;
  49869. }, scene: Scene): Mesh;
  49870. /**
  49871. * Creates a decal mesh.
  49872. * 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
  49873. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49874. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49875. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49876. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49877. * @param name defines the name of the mesh
  49878. * @param sourceMesh defines the mesh where the decal must be applied
  49879. * @param options defines the options used to create the mesh
  49880. * @param scene defines the hosting scene
  49881. * @returns the decal mesh
  49882. * @see https://doc.babylonjs.com/how_to/decals
  49883. */
  49884. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49885. position?: Vector3;
  49886. normal?: Vector3;
  49887. size?: Vector3;
  49888. angle?: number;
  49889. }): Mesh;
  49890. }
  49891. }
  49892. declare module "babylonjs/Meshes/meshSimplification" {
  49893. import { Mesh } from "babylonjs/Meshes/mesh";
  49894. /**
  49895. * A simplifier interface for future simplification implementations
  49896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49897. */
  49898. export interface ISimplifier {
  49899. /**
  49900. * Simplification of a given mesh according to the given settings.
  49901. * Since this requires computation, it is assumed that the function runs async.
  49902. * @param settings The settings of the simplification, including quality and distance
  49903. * @param successCallback A callback that will be called after the mesh was simplified.
  49904. * @param errorCallback in case of an error, this callback will be called. optional.
  49905. */
  49906. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49907. }
  49908. /**
  49909. * Expected simplification settings.
  49910. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49911. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49912. */
  49913. export interface ISimplificationSettings {
  49914. /**
  49915. * Gets or sets the expected quality
  49916. */
  49917. quality: number;
  49918. /**
  49919. * Gets or sets the distance when this optimized version should be used
  49920. */
  49921. distance: number;
  49922. /**
  49923. * Gets an already optimized mesh
  49924. */
  49925. optimizeMesh?: boolean;
  49926. }
  49927. /**
  49928. * Class used to specify simplification options
  49929. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49930. */
  49931. export class SimplificationSettings implements ISimplificationSettings {
  49932. /** expected quality */
  49933. quality: number;
  49934. /** distance when this optimized version should be used */
  49935. distance: number;
  49936. /** already optimized mesh */
  49937. optimizeMesh?: boolean | undefined;
  49938. /**
  49939. * Creates a SimplificationSettings
  49940. * @param quality expected quality
  49941. * @param distance distance when this optimized version should be used
  49942. * @param optimizeMesh already optimized mesh
  49943. */
  49944. constructor(
  49945. /** expected quality */
  49946. quality: number,
  49947. /** distance when this optimized version should be used */
  49948. distance: number,
  49949. /** already optimized mesh */
  49950. optimizeMesh?: boolean | undefined);
  49951. }
  49952. /**
  49953. * Interface used to define a simplification task
  49954. */
  49955. export interface ISimplificationTask {
  49956. /**
  49957. * Array of settings
  49958. */
  49959. settings: Array<ISimplificationSettings>;
  49960. /**
  49961. * Simplification type
  49962. */
  49963. simplificationType: SimplificationType;
  49964. /**
  49965. * Mesh to simplify
  49966. */
  49967. mesh: Mesh;
  49968. /**
  49969. * Callback called on success
  49970. */
  49971. successCallback?: () => void;
  49972. /**
  49973. * Defines if parallel processing can be used
  49974. */
  49975. parallelProcessing: boolean;
  49976. }
  49977. /**
  49978. * Queue used to order the simplification tasks
  49979. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49980. */
  49981. export class SimplificationQueue {
  49982. private _simplificationArray;
  49983. /**
  49984. * Gets a boolean indicating that the process is still running
  49985. */
  49986. running: boolean;
  49987. /**
  49988. * Creates a new queue
  49989. */
  49990. constructor();
  49991. /**
  49992. * Adds a new simplification task
  49993. * @param task defines a task to add
  49994. */
  49995. addTask(task: ISimplificationTask): void;
  49996. /**
  49997. * Execute next task
  49998. */
  49999. executeNext(): void;
  50000. /**
  50001. * Execute a simplification task
  50002. * @param task defines the task to run
  50003. */
  50004. runSimplification(task: ISimplificationTask): void;
  50005. private getSimplifier;
  50006. }
  50007. /**
  50008. * The implemented types of simplification
  50009. * At the moment only Quadratic Error Decimation is implemented
  50010. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50011. */
  50012. export enum SimplificationType {
  50013. /** Quadratic error decimation */
  50014. QUADRATIC = 0
  50015. }
  50016. }
  50017. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50018. import { Scene } from "babylonjs/scene";
  50019. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50020. import { ISceneComponent } from "babylonjs/sceneComponent";
  50021. module "babylonjs/scene" {
  50022. interface Scene {
  50023. /** @hidden (Backing field) */
  50024. _simplificationQueue: SimplificationQueue;
  50025. /**
  50026. * Gets or sets the simplification queue attached to the scene
  50027. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50028. */
  50029. simplificationQueue: SimplificationQueue;
  50030. }
  50031. }
  50032. module "babylonjs/Meshes/mesh" {
  50033. interface Mesh {
  50034. /**
  50035. * Simplify the mesh according to the given array of settings.
  50036. * Function will return immediately and will simplify async
  50037. * @param settings a collection of simplification settings
  50038. * @param parallelProcessing should all levels calculate parallel or one after the other
  50039. * @param simplificationType the type of simplification to run
  50040. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50041. * @returns the current mesh
  50042. */
  50043. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50044. }
  50045. }
  50046. /**
  50047. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50048. * created in a scene
  50049. */
  50050. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50051. /**
  50052. * The component name helpfull to identify the component in the list of scene components.
  50053. */
  50054. readonly name: string;
  50055. /**
  50056. * The scene the component belongs to.
  50057. */
  50058. scene: Scene;
  50059. /**
  50060. * Creates a new instance of the component for the given scene
  50061. * @param scene Defines the scene to register the component in
  50062. */
  50063. constructor(scene: Scene);
  50064. /**
  50065. * Registers the component in a given scene
  50066. */
  50067. register(): void;
  50068. /**
  50069. * Rebuilds the elements related to this component in case of
  50070. * context lost for instance.
  50071. */
  50072. rebuild(): void;
  50073. /**
  50074. * Disposes the component and the associated ressources
  50075. */
  50076. dispose(): void;
  50077. private _beforeCameraUpdate;
  50078. }
  50079. }
  50080. declare module "babylonjs/Meshes/Builders/index" {
  50081. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50082. export * from "babylonjs/Meshes/Builders/discBuilder";
  50083. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50084. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50085. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50086. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50087. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50088. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50089. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50090. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50091. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50092. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50093. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50094. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50095. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50096. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50097. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50098. }
  50099. declare module "babylonjs/Meshes/index" {
  50100. export * from "babylonjs/Meshes/abstractMesh";
  50101. export * from "babylonjs/Meshes/buffer";
  50102. export * from "babylonjs/Meshes/Compression/index";
  50103. export * from "babylonjs/Meshes/csg";
  50104. export * from "babylonjs/Meshes/geometry";
  50105. export * from "babylonjs/Meshes/groundMesh";
  50106. export * from "babylonjs/Meshes/instancedMesh";
  50107. export * from "babylonjs/Meshes/linesMesh";
  50108. export * from "babylonjs/Meshes/mesh";
  50109. export * from "babylonjs/Meshes/mesh.vertexData";
  50110. export * from "babylonjs/Meshes/meshBuilder";
  50111. export * from "babylonjs/Meshes/meshSimplification";
  50112. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50113. export * from "babylonjs/Meshes/polygonMesh";
  50114. export * from "babylonjs/Meshes/subMesh";
  50115. export * from "babylonjs/Meshes/transformNode";
  50116. export * from "babylonjs/Meshes/Builders/index";
  50117. }
  50118. declare module "babylonjs/Morph/index" {
  50119. export * from "babylonjs/Morph/morphTarget";
  50120. export * from "babylonjs/Morph/morphTargetManager";
  50121. }
  50122. declare module "babylonjs/Offline/database" {
  50123. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50124. /**
  50125. * Class used to enable access to IndexedDB
  50126. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50127. */
  50128. export class Database implements IOfflineProvider {
  50129. private _callbackManifestChecked;
  50130. private _currentSceneUrl;
  50131. private _db;
  50132. private _enableSceneOffline;
  50133. private _enableTexturesOffline;
  50134. private _manifestVersionFound;
  50135. private _mustUpdateRessources;
  50136. private _hasReachedQuota;
  50137. private _isSupported;
  50138. private _idbFactory;
  50139. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50140. private static IsUASupportingBlobStorage;
  50141. /**
  50142. * Gets a boolean indicating if Database storate is enabled (off by default)
  50143. */
  50144. static IDBStorageEnabled: boolean;
  50145. /**
  50146. * Gets a boolean indicating if scene must be saved in the database
  50147. */
  50148. readonly enableSceneOffline: boolean;
  50149. /**
  50150. * Gets a boolean indicating if textures must be saved in the database
  50151. */
  50152. readonly enableTexturesOffline: boolean;
  50153. /**
  50154. * Creates a new Database
  50155. * @param urlToScene defines the url to load the scene
  50156. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50157. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50158. */
  50159. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50160. private static _ParseURL;
  50161. private static _ReturnFullUrlLocation;
  50162. private _checkManifestFile;
  50163. /**
  50164. * Open the database and make it available
  50165. * @param successCallback defines the callback to call on success
  50166. * @param errorCallback defines the callback to call on error
  50167. */
  50168. open(successCallback: () => void, errorCallback: () => void): void;
  50169. /**
  50170. * Loads an image from the database
  50171. * @param url defines the url to load from
  50172. * @param image defines the target DOM image
  50173. */
  50174. loadImage(url: string, image: HTMLImageElement): void;
  50175. private _loadImageFromDBAsync;
  50176. private _saveImageIntoDBAsync;
  50177. private _checkVersionFromDB;
  50178. private _loadVersionFromDBAsync;
  50179. private _saveVersionIntoDBAsync;
  50180. /**
  50181. * Loads a file from database
  50182. * @param url defines the URL to load from
  50183. * @param sceneLoaded defines a callback to call on success
  50184. * @param progressCallBack defines a callback to call when progress changed
  50185. * @param errorCallback defines a callback to call on error
  50186. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50187. */
  50188. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50189. private _loadFileAsync;
  50190. private _saveFileAsync;
  50191. /**
  50192. * Validates if xhr data is correct
  50193. * @param xhr defines the request to validate
  50194. * @param dataType defines the expected data type
  50195. * @returns true if data is correct
  50196. */
  50197. private static _ValidateXHRData;
  50198. }
  50199. }
  50200. declare module "babylonjs/Offline/index" {
  50201. export * from "babylonjs/Offline/database";
  50202. export * from "babylonjs/Offline/IOfflineProvider";
  50203. }
  50204. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50205. /** @hidden */
  50206. export var gpuUpdateParticlesPixelShader: {
  50207. name: string;
  50208. shader: string;
  50209. };
  50210. }
  50211. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50212. /** @hidden */
  50213. export var gpuUpdateParticlesVertexShader: {
  50214. name: string;
  50215. shader: string;
  50216. };
  50217. }
  50218. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50219. /** @hidden */
  50220. export var clipPlaneFragmentDeclaration2: {
  50221. name: string;
  50222. shader: string;
  50223. };
  50224. }
  50225. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50226. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50227. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50228. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50229. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50230. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50231. /** @hidden */
  50232. export var gpuRenderParticlesPixelShader: {
  50233. name: string;
  50234. shader: string;
  50235. };
  50236. }
  50237. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50238. /** @hidden */
  50239. export var clipPlaneVertexDeclaration2: {
  50240. name: string;
  50241. shader: string;
  50242. };
  50243. }
  50244. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50245. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50246. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50247. /** @hidden */
  50248. export var gpuRenderParticlesVertexShader: {
  50249. name: string;
  50250. shader: string;
  50251. };
  50252. }
  50253. declare module "babylonjs/Particles/gpuParticleSystem" {
  50254. import { Nullable } from "babylonjs/types";
  50255. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50256. import { Observable } from "babylonjs/Misc/observable";
  50257. import { Color4, Color3 } from "babylonjs/Maths/math";
  50258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50259. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50260. import { Scene, IDisposable } from "babylonjs/scene";
  50261. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50262. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50263. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50264. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50265. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50266. /**
  50267. * This represents a GPU particle system in Babylon
  50268. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50269. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50270. */
  50271. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50272. /**
  50273. * The layer mask we are rendering the particles through.
  50274. */
  50275. layerMask: number;
  50276. private _capacity;
  50277. private _activeCount;
  50278. private _currentActiveCount;
  50279. private _accumulatedCount;
  50280. private _renderEffect;
  50281. private _updateEffect;
  50282. private _buffer0;
  50283. private _buffer1;
  50284. private _spriteBuffer;
  50285. private _updateVAO;
  50286. private _renderVAO;
  50287. private _targetIndex;
  50288. private _sourceBuffer;
  50289. private _targetBuffer;
  50290. private _engine;
  50291. private _currentRenderId;
  50292. private _started;
  50293. private _stopped;
  50294. private _timeDelta;
  50295. private _randomTexture;
  50296. private _randomTexture2;
  50297. private _attributesStrideSize;
  50298. private _updateEffectOptions;
  50299. private _randomTextureSize;
  50300. private _actualFrame;
  50301. private readonly _rawTextureWidth;
  50302. /**
  50303. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50304. */
  50305. static readonly IsSupported: boolean;
  50306. /**
  50307. * An event triggered when the system is disposed.
  50308. */
  50309. onDisposeObservable: Observable<GPUParticleSystem>;
  50310. /**
  50311. * Gets the maximum number of particles active at the same time.
  50312. * @returns The max number of active particles.
  50313. */
  50314. getCapacity(): number;
  50315. /**
  50316. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50317. * to override the particles.
  50318. */
  50319. forceDepthWrite: boolean;
  50320. /**
  50321. * Gets or set the number of active particles
  50322. */
  50323. activeParticleCount: number;
  50324. private _preWarmDone;
  50325. /**
  50326. * Is this system ready to be used/rendered
  50327. * @return true if the system is ready
  50328. */
  50329. isReady(): boolean;
  50330. /**
  50331. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50332. * @returns True if it has been started, otherwise false.
  50333. */
  50334. isStarted(): boolean;
  50335. /**
  50336. * Starts the particle system and begins to emit
  50337. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50338. */
  50339. start(delay?: number): void;
  50340. /**
  50341. * Stops the particle system.
  50342. */
  50343. stop(): void;
  50344. /**
  50345. * Remove all active particles
  50346. */
  50347. reset(): void;
  50348. /**
  50349. * Returns the string "GPUParticleSystem"
  50350. * @returns a string containing the class name
  50351. */
  50352. getClassName(): string;
  50353. private _colorGradientsTexture;
  50354. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50355. /**
  50356. * Adds a new color gradient
  50357. * @param gradient defines the gradient to use (between 0 and 1)
  50358. * @param color1 defines the color to affect to the specified gradient
  50359. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50360. * @returns the current particle system
  50361. */
  50362. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50363. /**
  50364. * Remove a specific color gradient
  50365. * @param gradient defines the gradient to remove
  50366. * @returns the current particle system
  50367. */
  50368. removeColorGradient(gradient: number): GPUParticleSystem;
  50369. private _angularSpeedGradientsTexture;
  50370. private _sizeGradientsTexture;
  50371. private _velocityGradientsTexture;
  50372. private _limitVelocityGradientsTexture;
  50373. private _dragGradientsTexture;
  50374. private _addFactorGradient;
  50375. /**
  50376. * Adds a new size gradient
  50377. * @param gradient defines the gradient to use (between 0 and 1)
  50378. * @param factor defines the size factor to affect to the specified gradient
  50379. * @returns the current particle system
  50380. */
  50381. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50382. /**
  50383. * Remove a specific size gradient
  50384. * @param gradient defines the gradient to remove
  50385. * @returns the current particle system
  50386. */
  50387. removeSizeGradient(gradient: number): GPUParticleSystem;
  50388. /**
  50389. * Adds a new angular speed gradient
  50390. * @param gradient defines the gradient to use (between 0 and 1)
  50391. * @param factor defines the angular speed to affect to the specified gradient
  50392. * @returns the current particle system
  50393. */
  50394. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50395. /**
  50396. * Remove a specific angular speed gradient
  50397. * @param gradient defines the gradient to remove
  50398. * @returns the current particle system
  50399. */
  50400. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50401. /**
  50402. * Adds a new velocity gradient
  50403. * @param gradient defines the gradient to use (between 0 and 1)
  50404. * @param factor defines the velocity to affect to the specified gradient
  50405. * @returns the current particle system
  50406. */
  50407. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50408. /**
  50409. * Remove a specific velocity gradient
  50410. * @param gradient defines the gradient to remove
  50411. * @returns the current particle system
  50412. */
  50413. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50414. /**
  50415. * Adds a new limit velocity gradient
  50416. * @param gradient defines the gradient to use (between 0 and 1)
  50417. * @param factor defines the limit velocity value to affect to the specified gradient
  50418. * @returns the current particle system
  50419. */
  50420. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50421. /**
  50422. * Remove a specific limit velocity gradient
  50423. * @param gradient defines the gradient to remove
  50424. * @returns the current particle system
  50425. */
  50426. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50427. /**
  50428. * Adds a new drag gradient
  50429. * @param gradient defines the gradient to use (between 0 and 1)
  50430. * @param factor defines the drag value to affect to the specified gradient
  50431. * @returns the current particle system
  50432. */
  50433. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50434. /**
  50435. * Remove a specific drag gradient
  50436. * @param gradient defines the gradient to remove
  50437. * @returns the current particle system
  50438. */
  50439. removeDragGradient(gradient: number): GPUParticleSystem;
  50440. /**
  50441. * Not supported by GPUParticleSystem
  50442. * @param gradient defines the gradient to use (between 0 and 1)
  50443. * @param factor defines the emit rate value to affect to the specified gradient
  50444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50445. * @returns the current particle system
  50446. */
  50447. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50448. /**
  50449. * Not supported by GPUParticleSystem
  50450. * @param gradient defines the gradient to remove
  50451. * @returns the current particle system
  50452. */
  50453. removeEmitRateGradient(gradient: number): IParticleSystem;
  50454. /**
  50455. * Not supported by GPUParticleSystem
  50456. * @param gradient defines the gradient to use (between 0 and 1)
  50457. * @param factor defines the start size value to affect to the specified gradient
  50458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50459. * @returns the current particle system
  50460. */
  50461. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50462. /**
  50463. * Not supported by GPUParticleSystem
  50464. * @param gradient defines the gradient to remove
  50465. * @returns the current particle system
  50466. */
  50467. removeStartSizeGradient(gradient: number): IParticleSystem;
  50468. /**
  50469. * Not supported by GPUParticleSystem
  50470. * @param gradient defines the gradient to use (between 0 and 1)
  50471. * @param min defines the color remap minimal range
  50472. * @param max defines the color remap maximal range
  50473. * @returns the current particle system
  50474. */
  50475. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50476. /**
  50477. * Not supported by GPUParticleSystem
  50478. * @param gradient defines the gradient to remove
  50479. * @returns the current particle system
  50480. */
  50481. removeColorRemapGradient(): IParticleSystem;
  50482. /**
  50483. * Not supported by GPUParticleSystem
  50484. * @param gradient defines the gradient to use (between 0 and 1)
  50485. * @param min defines the alpha remap minimal range
  50486. * @param max defines the alpha remap maximal range
  50487. * @returns the current particle system
  50488. */
  50489. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50490. /**
  50491. * Not supported by GPUParticleSystem
  50492. * @param gradient defines the gradient to remove
  50493. * @returns the current particle system
  50494. */
  50495. removeAlphaRemapGradient(): IParticleSystem;
  50496. /**
  50497. * Not supported by GPUParticleSystem
  50498. * @param gradient defines the gradient to use (between 0 and 1)
  50499. * @param color defines the color to affect to the specified gradient
  50500. * @returns the current particle system
  50501. */
  50502. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50503. /**
  50504. * Not supported by GPUParticleSystem
  50505. * @param gradient defines the gradient to remove
  50506. * @returns the current particle system
  50507. */
  50508. removeRampGradient(): IParticleSystem;
  50509. /**
  50510. * Not supported by GPUParticleSystem
  50511. * @returns the list of ramp gradients
  50512. */
  50513. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50514. /**
  50515. * Not supported by GPUParticleSystem
  50516. * Gets or sets a boolean indicating that ramp gradients must be used
  50517. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50518. */
  50519. useRampGradients: boolean;
  50520. /**
  50521. * Not supported by GPUParticleSystem
  50522. * @param gradient defines the gradient to use (between 0 and 1)
  50523. * @param factor defines the life time factor to affect to the specified gradient
  50524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50525. * @returns the current particle system
  50526. */
  50527. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50528. /**
  50529. * Not supported by GPUParticleSystem
  50530. * @param gradient defines the gradient to remove
  50531. * @returns the current particle system
  50532. */
  50533. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50534. /**
  50535. * Instantiates a GPU particle system.
  50536. * 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.
  50537. * @param name The name of the particle system
  50538. * @param options The options used to create the system
  50539. * @param scene The scene the particle system belongs to
  50540. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50541. */
  50542. constructor(name: string, options: Partial<{
  50543. capacity: number;
  50544. randomTextureSize: number;
  50545. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50546. protected _reset(): void;
  50547. private _createUpdateVAO;
  50548. private _createRenderVAO;
  50549. private _initialize;
  50550. /** @hidden */
  50551. _recreateUpdateEffect(): void;
  50552. /** @hidden */
  50553. _recreateRenderEffect(): void;
  50554. /**
  50555. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50556. * @param preWarm defines if we are in the pre-warmimg phase
  50557. */
  50558. animate(preWarm?: boolean): void;
  50559. private _createFactorGradientTexture;
  50560. private _createSizeGradientTexture;
  50561. private _createAngularSpeedGradientTexture;
  50562. private _createVelocityGradientTexture;
  50563. private _createLimitVelocityGradientTexture;
  50564. private _createDragGradientTexture;
  50565. private _createColorGradientTexture;
  50566. /**
  50567. * Renders the particle system in its current state
  50568. * @param preWarm defines if the system should only update the particles but not render them
  50569. * @returns the current number of particles
  50570. */
  50571. render(preWarm?: boolean): number;
  50572. /**
  50573. * Rebuilds the particle system
  50574. */
  50575. rebuild(): void;
  50576. private _releaseBuffers;
  50577. private _releaseVAOs;
  50578. /**
  50579. * Disposes the particle system and free the associated resources
  50580. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50581. */
  50582. dispose(disposeTexture?: boolean): void;
  50583. /**
  50584. * Clones the particle system.
  50585. * @param name The name of the cloned object
  50586. * @param newEmitter The new emitter to use
  50587. * @returns the cloned particle system
  50588. */
  50589. clone(name: string, newEmitter: any): GPUParticleSystem;
  50590. /**
  50591. * Serializes the particle system to a JSON object.
  50592. * @returns the JSON object
  50593. */
  50594. serialize(): any;
  50595. /**
  50596. * Parses a JSON object to create a GPU particle system.
  50597. * @param parsedParticleSystem The JSON object to parse
  50598. * @param scene The scene to create the particle system in
  50599. * @param rootUrl The root url to use to load external dependencies like texture
  50600. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50601. * @returns the parsed GPU particle system
  50602. */
  50603. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50604. }
  50605. }
  50606. declare module "babylonjs/Particles/particleSystemSet" {
  50607. import { Nullable } from "babylonjs/types";
  50608. import { Color3 } from "babylonjs/Maths/math";
  50609. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50611. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50612. import { Scene, IDisposable } from "babylonjs/scene";
  50613. /**
  50614. * Represents a set of particle systems working together to create a specific effect
  50615. */
  50616. export class ParticleSystemSet implements IDisposable {
  50617. private _emitterCreationOptions;
  50618. private _emitterNode;
  50619. /**
  50620. * Gets the particle system list
  50621. */
  50622. systems: IParticleSystem[];
  50623. /**
  50624. * Gets the emitter node used with this set
  50625. */
  50626. readonly emitterNode: Nullable<TransformNode>;
  50627. /**
  50628. * Creates a new emitter mesh as a sphere
  50629. * @param options defines the options used to create the sphere
  50630. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50631. * @param scene defines the hosting scene
  50632. */
  50633. setEmitterAsSphere(options: {
  50634. diameter: number;
  50635. segments: number;
  50636. color: Color3;
  50637. }, renderingGroupId: number, scene: Scene): void;
  50638. /**
  50639. * Starts all particle systems of the set
  50640. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50641. */
  50642. start(emitter?: AbstractMesh): void;
  50643. /**
  50644. * Release all associated resources
  50645. */
  50646. dispose(): void;
  50647. /**
  50648. * Serialize the set into a JSON compatible object
  50649. * @returns a JSON compatible representation of the set
  50650. */
  50651. serialize(): any;
  50652. /**
  50653. * Parse a new ParticleSystemSet from a serialized source
  50654. * @param data defines a JSON compatible representation of the set
  50655. * @param scene defines the hosting scene
  50656. * @param gpu defines if we want GPU particles or CPU particles
  50657. * @returns a new ParticleSystemSet
  50658. */
  50659. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50660. }
  50661. }
  50662. declare module "babylonjs/Particles/particleHelper" {
  50663. import { Nullable } from "babylonjs/types";
  50664. import { Scene } from "babylonjs/scene";
  50665. import { Vector3 } from "babylonjs/Maths/math";
  50666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50667. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50668. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50669. /**
  50670. * This class is made for on one-liner static method to help creating particle system set.
  50671. */
  50672. export class ParticleHelper {
  50673. /**
  50674. * Gets or sets base Assets URL
  50675. */
  50676. static BaseAssetsUrl: string;
  50677. /**
  50678. * Create a default particle system that you can tweak
  50679. * @param emitter defines the emitter to use
  50680. * @param capacity defines the system capacity (default is 500 particles)
  50681. * @param scene defines the hosting scene
  50682. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50683. * @returns the new Particle system
  50684. */
  50685. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50686. /**
  50687. * This is the main static method (one-liner) of this helper to create different particle systems
  50688. * @param type This string represents the type to the particle system to create
  50689. * @param scene The scene where the particle system should live
  50690. * @param gpu If the system will use gpu
  50691. * @returns the ParticleSystemSet created
  50692. */
  50693. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50694. /**
  50695. * Static function used to export a particle system to a ParticleSystemSet variable.
  50696. * Please note that the emitter shape is not exported
  50697. * @param systems defines the particle systems to export
  50698. * @returns the created particle system set
  50699. */
  50700. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50701. }
  50702. }
  50703. declare module "babylonjs/Particles/particleSystemComponent" {
  50704. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50705. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50706. import "babylonjs/Shaders/particles.vertex";
  50707. module "babylonjs/Engines/engine" {
  50708. interface Engine {
  50709. /**
  50710. * Create an effect to use with particle systems.
  50711. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50712. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50713. * @param uniformsNames defines a list of attribute names
  50714. * @param samplers defines an array of string used to represent textures
  50715. * @param defines defines the string containing the defines to use to compile the shaders
  50716. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50717. * @param onCompiled defines a function to call when the effect creation is successful
  50718. * @param onError defines a function to call when the effect creation has failed
  50719. * @returns the new Effect
  50720. */
  50721. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50722. }
  50723. }
  50724. module "babylonjs/Meshes/mesh" {
  50725. interface Mesh {
  50726. /**
  50727. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50728. * @returns an array of IParticleSystem
  50729. */
  50730. getEmittedParticleSystems(): IParticleSystem[];
  50731. /**
  50732. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50733. * @returns an array of IParticleSystem
  50734. */
  50735. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50736. }
  50737. }
  50738. /**
  50739. * @hidden
  50740. */
  50741. export var _IDoNeedToBeInTheBuild: number;
  50742. }
  50743. declare module "babylonjs/Particles/index" {
  50744. export * from "babylonjs/Particles/baseParticleSystem";
  50745. export * from "babylonjs/Particles/EmitterTypes/index";
  50746. export * from "babylonjs/Particles/gpuParticleSystem";
  50747. export * from "babylonjs/Particles/IParticleSystem";
  50748. export * from "babylonjs/Particles/particle";
  50749. export * from "babylonjs/Particles/particleHelper";
  50750. export * from "babylonjs/Particles/particleSystem";
  50751. export * from "babylonjs/Particles/particleSystemComponent";
  50752. export * from "babylonjs/Particles/particleSystemSet";
  50753. export * from "babylonjs/Particles/solidParticle";
  50754. export * from "babylonjs/Particles/solidParticleSystem";
  50755. export * from "babylonjs/Particles/subEmitter";
  50756. }
  50757. declare module "babylonjs/Physics/physicsEngineComponent" {
  50758. import { Nullable } from "babylonjs/types";
  50759. import { Observable, Observer } from "babylonjs/Misc/observable";
  50760. import { Vector3 } from "babylonjs/Maths/math";
  50761. import { Mesh } from "babylonjs/Meshes/mesh";
  50762. import { ISceneComponent } from "babylonjs/sceneComponent";
  50763. import { Scene } from "babylonjs/scene";
  50764. import { Node } from "babylonjs/node";
  50765. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50766. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50767. module "babylonjs/scene" {
  50768. interface Scene {
  50769. /** @hidden (Backing field) */
  50770. _physicsEngine: Nullable<IPhysicsEngine>;
  50771. /**
  50772. * Gets the current physics engine
  50773. * @returns a IPhysicsEngine or null if none attached
  50774. */
  50775. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50776. /**
  50777. * Enables physics to the current scene
  50778. * @param gravity defines the scene's gravity for the physics engine
  50779. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50780. * @return a boolean indicating if the physics engine was initialized
  50781. */
  50782. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50783. /**
  50784. * Disables and disposes the physics engine associated with the scene
  50785. */
  50786. disablePhysicsEngine(): void;
  50787. /**
  50788. * Gets a boolean indicating if there is an active physics engine
  50789. * @returns a boolean indicating if there is an active physics engine
  50790. */
  50791. isPhysicsEnabled(): boolean;
  50792. /**
  50793. * Deletes a physics compound impostor
  50794. * @param compound defines the compound to delete
  50795. */
  50796. deleteCompoundImpostor(compound: any): void;
  50797. /**
  50798. * An event triggered when physic simulation is about to be run
  50799. */
  50800. onBeforePhysicsObservable: Observable<Scene>;
  50801. /**
  50802. * An event triggered when physic simulation has been done
  50803. */
  50804. onAfterPhysicsObservable: Observable<Scene>;
  50805. }
  50806. }
  50807. module "babylonjs/Meshes/abstractMesh" {
  50808. interface AbstractMesh {
  50809. /** @hidden */
  50810. _physicsImpostor: Nullable<PhysicsImpostor>;
  50811. /**
  50812. * Gets or sets impostor used for physic simulation
  50813. * @see http://doc.babylonjs.com/features/physics_engine
  50814. */
  50815. physicsImpostor: Nullable<PhysicsImpostor>;
  50816. /**
  50817. * Gets the current physics impostor
  50818. * @see http://doc.babylonjs.com/features/physics_engine
  50819. * @returns a physics impostor or null
  50820. */
  50821. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50822. /** Apply a physic impulse to the mesh
  50823. * @param force defines the force to apply
  50824. * @param contactPoint defines where to apply the force
  50825. * @returns the current mesh
  50826. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50827. */
  50828. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50829. /**
  50830. * Creates a physic joint between two meshes
  50831. * @param otherMesh defines the other mesh to use
  50832. * @param pivot1 defines the pivot to use on this mesh
  50833. * @param pivot2 defines the pivot to use on the other mesh
  50834. * @param options defines additional options (can be plugin dependent)
  50835. * @returns the current mesh
  50836. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50837. */
  50838. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50839. /** @hidden */
  50840. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50841. }
  50842. }
  50843. /**
  50844. * Defines the physics engine scene component responsible to manage a physics engine
  50845. */
  50846. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50847. /**
  50848. * The component name helpful to identify the component in the list of scene components.
  50849. */
  50850. readonly name: string;
  50851. /**
  50852. * The scene the component belongs to.
  50853. */
  50854. scene: Scene;
  50855. /**
  50856. * Creates a new instance of the component for the given scene
  50857. * @param scene Defines the scene to register the component in
  50858. */
  50859. constructor(scene: Scene);
  50860. /**
  50861. * Registers the component in a given scene
  50862. */
  50863. register(): void;
  50864. /**
  50865. * Rebuilds the elements related to this component in case of
  50866. * context lost for instance.
  50867. */
  50868. rebuild(): void;
  50869. /**
  50870. * Disposes the component and the associated ressources
  50871. */
  50872. dispose(): void;
  50873. }
  50874. }
  50875. declare module "babylonjs/Physics/physicsHelper" {
  50876. import { Nullable } from "babylonjs/types";
  50877. import { Vector3 } from "babylonjs/Maths/math";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { Ray } from "babylonjs/Culling/ray";
  50880. import { Scene } from "babylonjs/scene";
  50881. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50882. /**
  50883. * A helper for physics simulations
  50884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50885. */
  50886. export class PhysicsHelper {
  50887. private _scene;
  50888. private _physicsEngine;
  50889. /**
  50890. * Initializes the Physics helper
  50891. * @param scene Babylon.js scene
  50892. */
  50893. constructor(scene: Scene);
  50894. /**
  50895. * Applies a radial explosion impulse
  50896. * @param origin the origin of the explosion
  50897. * @param radius the explosion radius
  50898. * @param strength the explosion strength
  50899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50900. * @returns A physics radial explosion event, or null
  50901. */
  50902. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50903. /**
  50904. * Applies a radial explosion force
  50905. * @param origin the origin of the explosion
  50906. * @param radius the explosion radius
  50907. * @param strength the explosion strength
  50908. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50909. * @returns A physics radial explosion event, or null
  50910. */
  50911. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50912. /**
  50913. * Creates a gravitational field
  50914. * @param origin the origin of the explosion
  50915. * @param radius the explosion radius
  50916. * @param strength the explosion strength
  50917. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50918. * @returns A physics gravitational field event, or null
  50919. */
  50920. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50921. /**
  50922. * Creates a physics updraft event
  50923. * @param origin the origin of the updraft
  50924. * @param radius the radius of the updraft
  50925. * @param strength the strength of the updraft
  50926. * @param height the height of the updraft
  50927. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50928. * @returns A physics updraft event, or null
  50929. */
  50930. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50931. /**
  50932. * Creates a physics vortex event
  50933. * @param origin the of the vortex
  50934. * @param radius the radius of the vortex
  50935. * @param strength the strength of the vortex
  50936. * @param height the height of the vortex
  50937. * @returns a Physics vortex event, or null
  50938. * A physics vortex event or null
  50939. */
  50940. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50941. }
  50942. /**
  50943. * Represents a physics radial explosion event
  50944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50945. */
  50946. export class PhysicsRadialExplosionEvent {
  50947. private _scene;
  50948. private _sphere;
  50949. private _sphereOptions;
  50950. private _rays;
  50951. private _dataFetched;
  50952. /**
  50953. * Initializes a radial explosioin event
  50954. * @param scene BabylonJS scene
  50955. */
  50956. constructor(scene: Scene);
  50957. /**
  50958. * Returns the data related to the radial explosion event (sphere & rays).
  50959. * @returns The radial explosion event data
  50960. */
  50961. getData(): PhysicsRadialExplosionEventData;
  50962. /**
  50963. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50964. * @param impostor A physics imposter
  50965. * @param origin the origin of the explosion
  50966. * @param radius the explosion radius
  50967. * @param strength the explosion strength
  50968. * @param falloff possible options: Constant & Linear
  50969. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50970. */
  50971. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50972. /**
  50973. * Disposes the sphere.
  50974. * @param force Specifies if the sphere should be disposed by force
  50975. */
  50976. dispose(force?: boolean): void;
  50977. /*** Helpers ***/
  50978. private _prepareSphere;
  50979. private _intersectsWithSphere;
  50980. }
  50981. /**
  50982. * Represents a gravitational field event
  50983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50984. */
  50985. export class PhysicsGravitationalFieldEvent {
  50986. private _physicsHelper;
  50987. private _scene;
  50988. private _origin;
  50989. private _radius;
  50990. private _strength;
  50991. private _falloff;
  50992. private _tickCallback;
  50993. private _sphere;
  50994. private _dataFetched;
  50995. /**
  50996. * Initializes the physics gravitational field event
  50997. * @param physicsHelper A physics helper
  50998. * @param scene BabylonJS scene
  50999. * @param origin The origin position of the gravitational field event
  51000. * @param radius The radius of the gravitational field event
  51001. * @param strength The strength of the gravitational field event
  51002. * @param falloff The falloff for the gravitational field event
  51003. */
  51004. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51005. /**
  51006. * Returns the data related to the gravitational field event (sphere).
  51007. * @returns A gravitational field event
  51008. */
  51009. getData(): PhysicsGravitationalFieldEventData;
  51010. /**
  51011. * Enables the gravitational field.
  51012. */
  51013. enable(): void;
  51014. /**
  51015. * Disables the gravitational field.
  51016. */
  51017. disable(): void;
  51018. /**
  51019. * Disposes the sphere.
  51020. * @param force The force to dispose from the gravitational field event
  51021. */
  51022. dispose(force?: boolean): void;
  51023. private _tick;
  51024. }
  51025. /**
  51026. * Represents a physics updraft event
  51027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51028. */
  51029. export class PhysicsUpdraftEvent {
  51030. private _scene;
  51031. private _origin;
  51032. private _radius;
  51033. private _strength;
  51034. private _height;
  51035. private _updraftMode;
  51036. private _physicsEngine;
  51037. private _originTop;
  51038. private _originDirection;
  51039. private _tickCallback;
  51040. private _cylinder;
  51041. private _cylinderPosition;
  51042. private _dataFetched;
  51043. /**
  51044. * Initializes the physics updraft event
  51045. * @param _scene BabylonJS scene
  51046. * @param _origin The origin position of the updraft
  51047. * @param _radius The radius of the updraft
  51048. * @param _strength The strength of the updraft
  51049. * @param _height The height of the updraft
  51050. * @param _updraftMode The mode of the updraft
  51051. */
  51052. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51053. /**
  51054. * Returns the data related to the updraft event (cylinder).
  51055. * @returns A physics updraft event
  51056. */
  51057. getData(): PhysicsUpdraftEventData;
  51058. /**
  51059. * Enables the updraft.
  51060. */
  51061. enable(): void;
  51062. /**
  51063. * Disables the cortex.
  51064. */
  51065. disable(): void;
  51066. /**
  51067. * Disposes the sphere.
  51068. * @param force Specifies if the updraft should be disposed by force
  51069. */
  51070. dispose(force?: boolean): void;
  51071. private getImpostorForceAndContactPoint;
  51072. private _tick;
  51073. /*** Helpers ***/
  51074. private _prepareCylinder;
  51075. private _intersectsWithCylinder;
  51076. }
  51077. /**
  51078. * Represents a physics vortex event
  51079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51080. */
  51081. export class PhysicsVortexEvent {
  51082. private _scene;
  51083. private _origin;
  51084. private _radius;
  51085. private _strength;
  51086. private _height;
  51087. private _physicsEngine;
  51088. private _originTop;
  51089. private _centripetalForceThreshold;
  51090. private _updraftMultiplier;
  51091. private _tickCallback;
  51092. private _cylinder;
  51093. private _cylinderPosition;
  51094. private _dataFetched;
  51095. /**
  51096. * Initializes the physics vortex event
  51097. * @param _scene The BabylonJS scene
  51098. * @param _origin The origin position of the vortex
  51099. * @param _radius The radius of the vortex
  51100. * @param _strength The strength of the vortex
  51101. * @param _height The height of the vortex
  51102. */
  51103. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51104. /**
  51105. * Returns the data related to the vortex event (cylinder).
  51106. * @returns The physics vortex event data
  51107. */
  51108. getData(): PhysicsVortexEventData;
  51109. /**
  51110. * Enables the vortex.
  51111. */
  51112. enable(): void;
  51113. /**
  51114. * Disables the cortex.
  51115. */
  51116. disable(): void;
  51117. /**
  51118. * Disposes the sphere.
  51119. * @param force
  51120. */
  51121. dispose(force?: boolean): void;
  51122. private getImpostorForceAndContactPoint;
  51123. private _tick;
  51124. /*** Helpers ***/
  51125. private _prepareCylinder;
  51126. private _intersectsWithCylinder;
  51127. }
  51128. /**
  51129. * The strenght of the force in correspondence to the distance of the affected object
  51130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51131. */
  51132. export enum PhysicsRadialImpulseFalloff {
  51133. /** Defines that impulse is constant in strength across it's whole radius */
  51134. Constant = 0,
  51135. /** DEfines that impulse gets weaker if it's further from the origin */
  51136. Linear = 1
  51137. }
  51138. /**
  51139. * The strength of the force in correspondence to the distance of the affected object
  51140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51141. */
  51142. export enum PhysicsUpdraftMode {
  51143. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51144. Center = 0,
  51145. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51146. Perpendicular = 1
  51147. }
  51148. /**
  51149. * Interface for a physics force and contact point
  51150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51151. */
  51152. export interface PhysicsForceAndContactPoint {
  51153. /**
  51154. * The force applied at the contact point
  51155. */
  51156. force: Vector3;
  51157. /**
  51158. * The contact point
  51159. */
  51160. contactPoint: Vector3;
  51161. }
  51162. /**
  51163. * Interface for radial explosion event data
  51164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51165. */
  51166. export interface PhysicsRadialExplosionEventData {
  51167. /**
  51168. * A sphere used for the radial explosion event
  51169. */
  51170. sphere: Mesh;
  51171. /**
  51172. * An array of rays for the radial explosion event
  51173. */
  51174. rays: Array<Ray>;
  51175. }
  51176. /**
  51177. * Interface for gravitational field event data
  51178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51179. */
  51180. export interface PhysicsGravitationalFieldEventData {
  51181. /**
  51182. * A sphere mesh used for the gravitational field event
  51183. */
  51184. sphere: Mesh;
  51185. }
  51186. /**
  51187. * Interface for updraft event data
  51188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51189. */
  51190. export interface PhysicsUpdraftEventData {
  51191. /**
  51192. * A cylinder used for the updraft event
  51193. */
  51194. cylinder: Mesh;
  51195. }
  51196. /**
  51197. * Interface for vortex event data
  51198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51199. */
  51200. export interface PhysicsVortexEventData {
  51201. /**
  51202. * A cylinder used for the vortex event
  51203. */
  51204. cylinder: Mesh;
  51205. }
  51206. }
  51207. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51208. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51209. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51210. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51211. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51212. import { Nullable } from "babylonjs/types";
  51213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51214. /**
  51215. * AmmoJS Physics plugin
  51216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51217. * @see https://github.com/kripken/ammo.js/
  51218. */
  51219. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51220. private _useDeltaForWorldStep;
  51221. /**
  51222. * Reference to the Ammo library
  51223. */
  51224. bjsAMMO: any;
  51225. /**
  51226. * Created ammoJS world which physics bodies are added to
  51227. */
  51228. world: any;
  51229. /**
  51230. * Name of the plugin
  51231. */
  51232. name: string;
  51233. private _timeStep;
  51234. private _fixedTimeStep;
  51235. private _maxSteps;
  51236. private _tmpQuaternion;
  51237. private _tmpAmmoTransform;
  51238. private _tmpAmmoQuaternion;
  51239. private _tmpAmmoConcreteContactResultCallback;
  51240. private _collisionConfiguration;
  51241. private _dispatcher;
  51242. private _overlappingPairCache;
  51243. private _solver;
  51244. private _tmpAmmoVectorA;
  51245. private _tmpAmmoVectorB;
  51246. private _tmpAmmoVectorC;
  51247. private _tmpContactCallbackResult;
  51248. private static readonly DISABLE_COLLISION_FLAG;
  51249. private static readonly KINEMATIC_FLAG;
  51250. private static readonly DISABLE_DEACTIVATION_FLAG;
  51251. /**
  51252. * Initializes the ammoJS plugin
  51253. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51254. * @param ammoInjection can be used to inject your own ammo reference
  51255. */
  51256. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51257. /**
  51258. * Sets the gravity of the physics world (m/(s^2))
  51259. * @param gravity Gravity to set
  51260. */
  51261. setGravity(gravity: Vector3): void;
  51262. /**
  51263. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51264. * @param timeStep timestep to use in seconds
  51265. */
  51266. setTimeStep(timeStep: number): void;
  51267. /**
  51268. * 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)
  51269. * @param fixedTimeStep fixedTimeStep to use in seconds
  51270. */
  51271. setFixedTimeStep(fixedTimeStep: number): void;
  51272. /**
  51273. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51274. * @param maxSteps the maximum number of steps by the physics engine per frame
  51275. */
  51276. setMaxSteps(maxSteps: number): void;
  51277. /**
  51278. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51279. * @returns the current timestep in seconds
  51280. */
  51281. getTimeStep(): number;
  51282. private _isImpostorInContact;
  51283. private _isImpostorPairInContact;
  51284. private _stepSimulation;
  51285. /**
  51286. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51287. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51288. * After the step the babylon meshes are set to the position of the physics imposters
  51289. * @param delta amount of time to step forward
  51290. * @param impostors array of imposters to update before/after the step
  51291. */
  51292. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51293. private _tmpVector;
  51294. private _tmpMatrix;
  51295. /**
  51296. * Applies an implulse on the imposter
  51297. * @param impostor imposter to apply impulse
  51298. * @param force amount of force to be applied to the imposter
  51299. * @param contactPoint the location to apply the impulse on the imposter
  51300. */
  51301. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51302. /**
  51303. * Applies a force on the imposter
  51304. * @param impostor imposter to apply force
  51305. * @param force amount of force to be applied to the imposter
  51306. * @param contactPoint the location to apply the force on the imposter
  51307. */
  51308. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51309. /**
  51310. * Creates a physics body using the plugin
  51311. * @param impostor the imposter to create the physics body on
  51312. */
  51313. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51314. /**
  51315. * Removes the physics body from the imposter and disposes of the body's memory
  51316. * @param impostor imposter to remove the physics body from
  51317. */
  51318. removePhysicsBody(impostor: PhysicsImpostor): void;
  51319. /**
  51320. * Generates a joint
  51321. * @param impostorJoint the imposter joint to create the joint with
  51322. */
  51323. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51324. /**
  51325. * Removes a joint
  51326. * @param impostorJoint the imposter joint to remove the joint from
  51327. */
  51328. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51329. private _addMeshVerts;
  51330. private _createShape;
  51331. /**
  51332. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51333. * @param impostor imposter containing the physics body and babylon object
  51334. */
  51335. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51336. /**
  51337. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51338. * @param impostor imposter containing the physics body and babylon object
  51339. * @param newPosition new position
  51340. * @param newRotation new rotation
  51341. */
  51342. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51343. /**
  51344. * If this plugin is supported
  51345. * @returns true if its supported
  51346. */
  51347. isSupported(): boolean;
  51348. /**
  51349. * Sets the linear velocity of the physics body
  51350. * @param impostor imposter to set the velocity on
  51351. * @param velocity velocity to set
  51352. */
  51353. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51354. /**
  51355. * Sets the angular velocity of the physics body
  51356. * @param impostor imposter to set the velocity on
  51357. * @param velocity velocity to set
  51358. */
  51359. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51360. /**
  51361. * gets the linear velocity
  51362. * @param impostor imposter to get linear velocity from
  51363. * @returns linear velocity
  51364. */
  51365. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51366. /**
  51367. * gets the angular velocity
  51368. * @param impostor imposter to get angular velocity from
  51369. * @returns angular velocity
  51370. */
  51371. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51372. /**
  51373. * Sets the mass of physics body
  51374. * @param impostor imposter to set the mass on
  51375. * @param mass mass to set
  51376. */
  51377. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51378. /**
  51379. * Gets the mass of the physics body
  51380. * @param impostor imposter to get the mass from
  51381. * @returns mass
  51382. */
  51383. getBodyMass(impostor: PhysicsImpostor): number;
  51384. /**
  51385. * Gets friction of the impostor
  51386. * @param impostor impostor to get friction from
  51387. * @returns friction value
  51388. */
  51389. getBodyFriction(impostor: PhysicsImpostor): number;
  51390. /**
  51391. * Sets friction of the impostor
  51392. * @param impostor impostor to set friction on
  51393. * @param friction friction value
  51394. */
  51395. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51396. /**
  51397. * Gets restitution of the impostor
  51398. * @param impostor impostor to get restitution from
  51399. * @returns restitution value
  51400. */
  51401. getBodyRestitution(impostor: PhysicsImpostor): number;
  51402. /**
  51403. * Sets resitution of the impostor
  51404. * @param impostor impostor to set resitution on
  51405. * @param restitution resitution value
  51406. */
  51407. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51408. /**
  51409. * Sleeps the physics body and stops it from being active
  51410. * @param impostor impostor to sleep
  51411. */
  51412. sleepBody(impostor: PhysicsImpostor): void;
  51413. /**
  51414. * Activates the physics body
  51415. * @param impostor impostor to activate
  51416. */
  51417. wakeUpBody(impostor: PhysicsImpostor): void;
  51418. /**
  51419. * Updates the distance parameters of the joint
  51420. * @param joint joint to update
  51421. * @param maxDistance maximum distance of the joint
  51422. * @param minDistance minimum distance of the joint
  51423. */
  51424. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51425. /**
  51426. * Sets a motor on the joint
  51427. * @param joint joint to set motor on
  51428. * @param speed speed of the motor
  51429. * @param maxForce maximum force of the motor
  51430. * @param motorIndex index of the motor
  51431. */
  51432. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51433. /**
  51434. * Sets the motors limit
  51435. * @param joint joint to set limit on
  51436. * @param upperLimit upper limit
  51437. * @param lowerLimit lower limit
  51438. */
  51439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51440. /**
  51441. * Syncs the position and rotation of a mesh with the impostor
  51442. * @param mesh mesh to sync
  51443. * @param impostor impostor to update the mesh with
  51444. */
  51445. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51446. /**
  51447. * Gets the radius of the impostor
  51448. * @param impostor impostor to get radius from
  51449. * @returns the radius
  51450. */
  51451. getRadius(impostor: PhysicsImpostor): number;
  51452. /**
  51453. * Gets the box size of the impostor
  51454. * @param impostor impostor to get box size from
  51455. * @param result the resulting box size
  51456. */
  51457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51458. /**
  51459. * Disposes of the impostor
  51460. */
  51461. dispose(): void;
  51462. }
  51463. }
  51464. declare module "babylonjs/Physics/Plugins/index" {
  51465. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51466. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51467. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51468. }
  51469. declare module "babylonjs/Physics/index" {
  51470. export * from "babylonjs/Physics/IPhysicsEngine";
  51471. export * from "babylonjs/Physics/physicsEngine";
  51472. export * from "babylonjs/Physics/physicsEngineComponent";
  51473. export * from "babylonjs/Physics/physicsHelper";
  51474. export * from "babylonjs/Physics/physicsImpostor";
  51475. export * from "babylonjs/Physics/physicsJoint";
  51476. export * from "babylonjs/Physics/Plugins/index";
  51477. }
  51478. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51479. /** @hidden */
  51480. export var blackAndWhitePixelShader: {
  51481. name: string;
  51482. shader: string;
  51483. };
  51484. }
  51485. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51486. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51487. import { Camera } from "babylonjs/Cameras/camera";
  51488. import { Engine } from "babylonjs/Engines/engine";
  51489. import "babylonjs/Shaders/blackAndWhite.fragment";
  51490. /**
  51491. * Post process used to render in black and white
  51492. */
  51493. export class BlackAndWhitePostProcess extends PostProcess {
  51494. /**
  51495. * Linear about to convert he result to black and white (default: 1)
  51496. */
  51497. degree: number;
  51498. /**
  51499. * Creates a black and white post process
  51500. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51501. * @param name The name of the effect.
  51502. * @param options The required width/height ratio to downsize to before computing the render pass.
  51503. * @param camera The camera to apply the render pass to.
  51504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51505. * @param engine The engine which the post process will be applied. (default: current engine)
  51506. * @param reusable If the post process can be reused on the same frame. (default: false)
  51507. */
  51508. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51509. }
  51510. }
  51511. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51512. import { Nullable } from "babylonjs/types";
  51513. import { Camera } from "babylonjs/Cameras/camera";
  51514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51515. import { Engine } from "babylonjs/Engines/engine";
  51516. /**
  51517. * This represents a set of one or more post processes in Babylon.
  51518. * A post process can be used to apply a shader to a texture after it is rendered.
  51519. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51520. */
  51521. export class PostProcessRenderEffect {
  51522. private _postProcesses;
  51523. private _getPostProcesses;
  51524. private _singleInstance;
  51525. private _cameras;
  51526. private _indicesForCamera;
  51527. /**
  51528. * Name of the effect
  51529. * @hidden
  51530. */
  51531. _name: string;
  51532. /**
  51533. * Instantiates a post process render effect.
  51534. * A post process can be used to apply a shader to a texture after it is rendered.
  51535. * @param engine The engine the effect is tied to
  51536. * @param name The name of the effect
  51537. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51538. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51539. */
  51540. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51541. /**
  51542. * Checks if all the post processes in the effect are supported.
  51543. */
  51544. readonly isSupported: boolean;
  51545. /**
  51546. * Updates the current state of the effect
  51547. * @hidden
  51548. */
  51549. _update(): void;
  51550. /**
  51551. * Attaches the effect on cameras
  51552. * @param cameras The camera to attach to.
  51553. * @hidden
  51554. */
  51555. _attachCameras(cameras: Camera): void;
  51556. /**
  51557. * Attaches the effect on cameras
  51558. * @param cameras The camera to attach to.
  51559. * @hidden
  51560. */
  51561. _attachCameras(cameras: Camera[]): void;
  51562. /**
  51563. * Detatches the effect on cameras
  51564. * @param cameras The camera to detatch from.
  51565. * @hidden
  51566. */
  51567. _detachCameras(cameras: Camera): void;
  51568. /**
  51569. * Detatches the effect on cameras
  51570. * @param cameras The camera to detatch from.
  51571. * @hidden
  51572. */
  51573. _detachCameras(cameras: Camera[]): void;
  51574. /**
  51575. * Enables the effect on given cameras
  51576. * @param cameras The camera to enable.
  51577. * @hidden
  51578. */
  51579. _enable(cameras: Camera): void;
  51580. /**
  51581. * Enables the effect on given cameras
  51582. * @param cameras The camera to enable.
  51583. * @hidden
  51584. */
  51585. _enable(cameras: Nullable<Camera[]>): void;
  51586. /**
  51587. * Disables the effect on the given cameras
  51588. * @param cameras The camera to disable.
  51589. * @hidden
  51590. */
  51591. _disable(cameras: Camera): void;
  51592. /**
  51593. * Disables the effect on the given cameras
  51594. * @param cameras The camera to disable.
  51595. * @hidden
  51596. */
  51597. _disable(cameras: Nullable<Camera[]>): void;
  51598. /**
  51599. * Gets a list of the post processes contained in the effect.
  51600. * @param camera The camera to get the post processes on.
  51601. * @returns The list of the post processes in the effect.
  51602. */
  51603. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51604. }
  51605. }
  51606. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51607. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51608. /** @hidden */
  51609. export var extractHighlightsPixelShader: {
  51610. name: string;
  51611. shader: string;
  51612. };
  51613. }
  51614. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51615. import { Nullable } from "babylonjs/types";
  51616. import { Camera } from "babylonjs/Cameras/camera";
  51617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51618. import { Engine } from "babylonjs/Engines/engine";
  51619. import "babylonjs/Shaders/extractHighlights.fragment";
  51620. /**
  51621. * 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.
  51622. */
  51623. export class ExtractHighlightsPostProcess extends PostProcess {
  51624. /**
  51625. * The luminance threshold, pixels below this value will be set to black.
  51626. */
  51627. threshold: number;
  51628. /** @hidden */
  51629. _exposure: number;
  51630. /**
  51631. * Post process which has the input texture to be used when performing highlight extraction
  51632. * @hidden
  51633. */
  51634. _inputPostProcess: Nullable<PostProcess>;
  51635. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51636. }
  51637. }
  51638. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51639. /** @hidden */
  51640. export var bloomMergePixelShader: {
  51641. name: string;
  51642. shader: string;
  51643. };
  51644. }
  51645. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51647. import { Nullable } from "babylonjs/types";
  51648. import { Engine } from "babylonjs/Engines/engine";
  51649. import { Camera } from "babylonjs/Cameras/camera";
  51650. import "babylonjs/Shaders/bloomMerge.fragment";
  51651. /**
  51652. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51653. */
  51654. export class BloomMergePostProcess extends PostProcess {
  51655. /** Weight of the bloom to be added to the original input. */
  51656. weight: number;
  51657. /**
  51658. * Creates a new instance of @see BloomMergePostProcess
  51659. * @param name The name of the effect.
  51660. * @param originalFromInput Post process which's input will be used for the merge.
  51661. * @param blurred Blurred highlights post process which's output will be used.
  51662. * @param weight Weight of the bloom to be added to the original input.
  51663. * @param options The required width/height ratio to downsize to before computing the render pass.
  51664. * @param camera The camera to apply the render pass to.
  51665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51666. * @param engine The engine which the post process will be applied. (default: current engine)
  51667. * @param reusable If the post process can be reused on the same frame. (default: false)
  51668. * @param textureType Type of textures used when performing the post process. (default: 0)
  51669. * @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)
  51670. */
  51671. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51672. /** Weight of the bloom to be added to the original input. */
  51673. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51674. }
  51675. }
  51676. declare module "babylonjs/PostProcesses/bloomEffect" {
  51677. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51678. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51679. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51680. import { Camera } from "babylonjs/Cameras/camera";
  51681. import { Scene } from "babylonjs/scene";
  51682. /**
  51683. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51684. */
  51685. export class BloomEffect extends PostProcessRenderEffect {
  51686. private bloomScale;
  51687. /**
  51688. * @hidden Internal
  51689. */
  51690. _effects: Array<PostProcess>;
  51691. /**
  51692. * @hidden Internal
  51693. */
  51694. _downscale: ExtractHighlightsPostProcess;
  51695. private _blurX;
  51696. private _blurY;
  51697. private _merge;
  51698. /**
  51699. * The luminance threshold to find bright areas of the image to bloom.
  51700. */
  51701. threshold: number;
  51702. /**
  51703. * The strength of the bloom.
  51704. */
  51705. weight: number;
  51706. /**
  51707. * Specifies the size of the bloom blur kernel, relative to the final output size
  51708. */
  51709. kernel: number;
  51710. /**
  51711. * Creates a new instance of @see BloomEffect
  51712. * @param scene The scene the effect belongs to.
  51713. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51714. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51715. * @param bloomWeight The the strength of bloom.
  51716. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51717. * @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)
  51718. */
  51719. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51720. /**
  51721. * Disposes each of the internal effects for a given camera.
  51722. * @param camera The camera to dispose the effect on.
  51723. */
  51724. disposeEffects(camera: Camera): void;
  51725. /**
  51726. * @hidden Internal
  51727. */
  51728. _updateEffects(): void;
  51729. /**
  51730. * Internal
  51731. * @returns if all the contained post processes are ready.
  51732. * @hidden
  51733. */
  51734. _isReady(): boolean;
  51735. }
  51736. }
  51737. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51738. /** @hidden */
  51739. export var chromaticAberrationPixelShader: {
  51740. name: string;
  51741. shader: string;
  51742. };
  51743. }
  51744. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51745. import { Vector2 } from "babylonjs/Maths/math";
  51746. import { Nullable } from "babylonjs/types";
  51747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51748. import { Camera } from "babylonjs/Cameras/camera";
  51749. import { Engine } from "babylonjs/Engines/engine";
  51750. import "babylonjs/Shaders/chromaticAberration.fragment";
  51751. /**
  51752. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51753. */
  51754. export class ChromaticAberrationPostProcess extends PostProcess {
  51755. /**
  51756. * The amount of seperation of rgb channels (default: 30)
  51757. */
  51758. aberrationAmount: number;
  51759. /**
  51760. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51761. */
  51762. radialIntensity: number;
  51763. /**
  51764. * 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))
  51765. */
  51766. direction: Vector2;
  51767. /**
  51768. * 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))
  51769. */
  51770. centerPosition: Vector2;
  51771. /**
  51772. * Creates a new instance ChromaticAberrationPostProcess
  51773. * @param name The name of the effect.
  51774. * @param screenWidth The width of the screen to apply the effect on.
  51775. * @param screenHeight The height of the screen to apply the effect on.
  51776. * @param options The required width/height ratio to downsize to before computing the render pass.
  51777. * @param camera The camera to apply the render pass to.
  51778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51779. * @param engine The engine which the post process will be applied. (default: current engine)
  51780. * @param reusable If the post process can be reused on the same frame. (default: false)
  51781. * @param textureType Type of textures used when performing the post process. (default: 0)
  51782. * @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)
  51783. */
  51784. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51785. }
  51786. }
  51787. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51788. /** @hidden */
  51789. export var circleOfConfusionPixelShader: {
  51790. name: string;
  51791. shader: string;
  51792. };
  51793. }
  51794. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51795. import { Nullable } from "babylonjs/types";
  51796. import { Engine } from "babylonjs/Engines/engine";
  51797. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51799. import { Camera } from "babylonjs/Cameras/camera";
  51800. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51801. /**
  51802. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51803. */
  51804. export class CircleOfConfusionPostProcess extends PostProcess {
  51805. /**
  51806. * 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.
  51807. */
  51808. lensSize: number;
  51809. /**
  51810. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51811. */
  51812. fStop: number;
  51813. /**
  51814. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51815. */
  51816. focusDistance: number;
  51817. /**
  51818. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51819. */
  51820. focalLength: number;
  51821. private _depthTexture;
  51822. /**
  51823. * Creates a new instance CircleOfConfusionPostProcess
  51824. * @param name The name of the effect.
  51825. * @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.
  51826. * @param options The required width/height ratio to downsize to before computing the render pass.
  51827. * @param camera The camera to apply the render pass to.
  51828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51829. * @param engine The engine which the post process will be applied. (default: current engine)
  51830. * @param reusable If the post process can be reused on the same frame. (default: false)
  51831. * @param textureType Type of textures used when performing the post process. (default: 0)
  51832. * @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)
  51833. */
  51834. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51835. /**
  51836. * 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.
  51837. */
  51838. depthTexture: RenderTargetTexture;
  51839. }
  51840. }
  51841. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51842. /** @hidden */
  51843. export var colorCorrectionPixelShader: {
  51844. name: string;
  51845. shader: string;
  51846. };
  51847. }
  51848. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51849. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51850. import { Engine } from "babylonjs/Engines/engine";
  51851. import { Camera } from "babylonjs/Cameras/camera";
  51852. import "babylonjs/Shaders/colorCorrection.fragment";
  51853. /**
  51854. *
  51855. * This post-process allows the modification of rendered colors by using
  51856. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51857. *
  51858. * The object needs to be provided an url to a texture containing the color
  51859. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51860. * Use an image editing software to tweak the LUT to match your needs.
  51861. *
  51862. * For an example of a color LUT, see here:
  51863. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51864. * For explanations on color grading, see here:
  51865. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51866. *
  51867. */
  51868. export class ColorCorrectionPostProcess extends PostProcess {
  51869. private _colorTableTexture;
  51870. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51871. }
  51872. }
  51873. declare module "babylonjs/Shaders/convolution.fragment" {
  51874. /** @hidden */
  51875. export var convolutionPixelShader: {
  51876. name: string;
  51877. shader: string;
  51878. };
  51879. }
  51880. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51881. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51882. import { Nullable } from "babylonjs/types";
  51883. import { Camera } from "babylonjs/Cameras/camera";
  51884. import { Engine } from "babylonjs/Engines/engine";
  51885. import "babylonjs/Shaders/convolution.fragment";
  51886. /**
  51887. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51888. * input texture to perform effects such as edge detection or sharpening
  51889. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51890. */
  51891. export class ConvolutionPostProcess extends PostProcess {
  51892. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51893. kernel: number[];
  51894. /**
  51895. * Creates a new instance ConvolutionPostProcess
  51896. * @param name The name of the effect.
  51897. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51898. * @param options The required width/height ratio to downsize to before computing the render pass.
  51899. * @param camera The camera to apply the render pass to.
  51900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51901. * @param engine The engine which the post process will be applied. (default: current engine)
  51902. * @param reusable If the post process can be reused on the same frame. (default: false)
  51903. * @param textureType Type of textures used when performing the post process. (default: 0)
  51904. */
  51905. constructor(name: string,
  51906. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51907. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51908. /**
  51909. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51910. */
  51911. static EdgeDetect0Kernel: number[];
  51912. /**
  51913. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51914. */
  51915. static EdgeDetect1Kernel: number[];
  51916. /**
  51917. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51918. */
  51919. static EdgeDetect2Kernel: number[];
  51920. /**
  51921. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51922. */
  51923. static SharpenKernel: number[];
  51924. /**
  51925. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51926. */
  51927. static EmbossKernel: number[];
  51928. /**
  51929. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51930. */
  51931. static GaussianKernel: number[];
  51932. }
  51933. }
  51934. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51935. import { Nullable } from "babylonjs/types";
  51936. import { Vector2 } from "babylonjs/Maths/math";
  51937. import { Camera } from "babylonjs/Cameras/camera";
  51938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51939. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51940. import { Engine } from "babylonjs/Engines/engine";
  51941. import { Scene } from "babylonjs/scene";
  51942. /**
  51943. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51944. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51945. * based on samples that have a large difference in distance than the center pixel.
  51946. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51947. */
  51948. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51949. direction: Vector2;
  51950. /**
  51951. * Creates a new instance CircleOfConfusionPostProcess
  51952. * @param name The name of the effect.
  51953. * @param scene The scene the effect belongs to.
  51954. * @param direction The direction the blur should be applied.
  51955. * @param kernel The size of the kernel used to blur.
  51956. * @param options The required width/height ratio to downsize to before computing the render pass.
  51957. * @param camera The camera to apply the render pass to.
  51958. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51959. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51961. * @param engine The engine which the post process will be applied. (default: current engine)
  51962. * @param reusable If the post process can be reused on the same frame. (default: false)
  51963. * @param textureType Type of textures used when performing the post process. (default: 0)
  51964. * @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)
  51965. */
  51966. 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);
  51967. }
  51968. }
  51969. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51970. /** @hidden */
  51971. export var depthOfFieldMergePixelShader: {
  51972. name: string;
  51973. shader: string;
  51974. };
  51975. }
  51976. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51977. import { Nullable } from "babylonjs/types";
  51978. import { Camera } from "babylonjs/Cameras/camera";
  51979. import { Effect } from "babylonjs/Materials/effect";
  51980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51981. import { Engine } from "babylonjs/Engines/engine";
  51982. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51983. /**
  51984. * Options to be set when merging outputs from the default pipeline.
  51985. */
  51986. export class DepthOfFieldMergePostProcessOptions {
  51987. /**
  51988. * The original image to merge on top of
  51989. */
  51990. originalFromInput: PostProcess;
  51991. /**
  51992. * Parameters to perform the merge of the depth of field effect
  51993. */
  51994. depthOfField?: {
  51995. circleOfConfusion: PostProcess;
  51996. blurSteps: Array<PostProcess>;
  51997. };
  51998. /**
  51999. * Parameters to perform the merge of bloom effect
  52000. */
  52001. bloom?: {
  52002. blurred: PostProcess;
  52003. weight: number;
  52004. };
  52005. }
  52006. /**
  52007. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52008. */
  52009. export class DepthOfFieldMergePostProcess extends PostProcess {
  52010. private blurSteps;
  52011. /**
  52012. * Creates a new instance of DepthOfFieldMergePostProcess
  52013. * @param name The name of the effect.
  52014. * @param originalFromInput Post process which's input will be used for the merge.
  52015. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52016. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52017. * @param options The required width/height ratio to downsize to before computing the render pass.
  52018. * @param camera The camera to apply the render pass to.
  52019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52020. * @param engine The engine which the post process will be applied. (default: current engine)
  52021. * @param reusable If the post process can be reused on the same frame. (default: false)
  52022. * @param textureType Type of textures used when performing the post process. (default: 0)
  52023. * @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)
  52024. */
  52025. 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);
  52026. /**
  52027. * Updates the effect with the current post process compile time values and recompiles the shader.
  52028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52031. * @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
  52032. * @param onCompiled Called when the shader has been compiled.
  52033. * @param onError Called if there is an error when compiling a shader.
  52034. */
  52035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52036. }
  52037. }
  52038. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52039. import { Nullable } from "babylonjs/types";
  52040. import { Camera } from "babylonjs/Cameras/camera";
  52041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52042. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52043. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52044. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52045. import { Scene } from "babylonjs/scene";
  52046. /**
  52047. * Specifies the level of max blur that should be applied when using the depth of field effect
  52048. */
  52049. export enum DepthOfFieldEffectBlurLevel {
  52050. /**
  52051. * Subtle blur
  52052. */
  52053. Low = 0,
  52054. /**
  52055. * Medium blur
  52056. */
  52057. Medium = 1,
  52058. /**
  52059. * Large blur
  52060. */
  52061. High = 2
  52062. }
  52063. /**
  52064. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52065. */
  52066. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52067. private _circleOfConfusion;
  52068. /**
  52069. * @hidden Internal, blurs from high to low
  52070. */
  52071. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52072. private _depthOfFieldBlurY;
  52073. private _dofMerge;
  52074. /**
  52075. * @hidden Internal post processes in depth of field effect
  52076. */
  52077. _effects: Array<PostProcess>;
  52078. /**
  52079. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52080. */
  52081. focalLength: number;
  52082. /**
  52083. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52084. */
  52085. fStop: number;
  52086. /**
  52087. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52088. */
  52089. focusDistance: number;
  52090. /**
  52091. * 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.
  52092. */
  52093. lensSize: number;
  52094. /**
  52095. * Creates a new instance DepthOfFieldEffect
  52096. * @param scene The scene the effect belongs to.
  52097. * @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.
  52098. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52099. * @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)
  52100. */
  52101. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52102. /**
  52103. * 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.
  52104. */
  52105. depthTexture: RenderTargetTexture;
  52106. /**
  52107. * Disposes each of the internal effects for a given camera.
  52108. * @param camera The camera to dispose the effect on.
  52109. */
  52110. disposeEffects(camera: Camera): void;
  52111. /**
  52112. * @hidden Internal
  52113. */
  52114. _updateEffects(): void;
  52115. /**
  52116. * Internal
  52117. * @returns if all the contained post processes are ready.
  52118. * @hidden
  52119. */
  52120. _isReady(): boolean;
  52121. }
  52122. }
  52123. declare module "babylonjs/Shaders/displayPass.fragment" {
  52124. /** @hidden */
  52125. export var displayPassPixelShader: {
  52126. name: string;
  52127. shader: string;
  52128. };
  52129. }
  52130. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52131. import { Nullable } from "babylonjs/types";
  52132. import { Camera } from "babylonjs/Cameras/camera";
  52133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52134. import { Engine } from "babylonjs/Engines/engine";
  52135. import "babylonjs/Shaders/displayPass.fragment";
  52136. /**
  52137. * DisplayPassPostProcess which produces an output the same as it's input
  52138. */
  52139. export class DisplayPassPostProcess extends PostProcess {
  52140. /**
  52141. * Creates the DisplayPassPostProcess
  52142. * @param name The name of the effect.
  52143. * @param options The required width/height ratio to downsize to before computing the render pass.
  52144. * @param camera The camera to apply the render pass to.
  52145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52146. * @param engine The engine which the post process will be applied. (default: current engine)
  52147. * @param reusable If the post process can be reused on the same frame. (default: false)
  52148. */
  52149. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52150. }
  52151. }
  52152. declare module "babylonjs/Shaders/filter.fragment" {
  52153. /** @hidden */
  52154. export var filterPixelShader: {
  52155. name: string;
  52156. shader: string;
  52157. };
  52158. }
  52159. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52160. import { Nullable } from "babylonjs/types";
  52161. import { Matrix } from "babylonjs/Maths/math";
  52162. import { Camera } from "babylonjs/Cameras/camera";
  52163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52164. import { Engine } from "babylonjs/Engines/engine";
  52165. import "babylonjs/Shaders/filter.fragment";
  52166. /**
  52167. * Applies a kernel filter to the image
  52168. */
  52169. export class FilterPostProcess extends PostProcess {
  52170. /** The matrix to be applied to the image */
  52171. kernelMatrix: Matrix;
  52172. /**
  52173. *
  52174. * @param name The name of the effect.
  52175. * @param kernelMatrix The matrix to be applied to the image
  52176. * @param options The required width/height ratio to downsize to before computing the render pass.
  52177. * @param camera The camera to apply the render pass to.
  52178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52179. * @param engine The engine which the post process will be applied. (default: current engine)
  52180. * @param reusable If the post process can be reused on the same frame. (default: false)
  52181. */
  52182. constructor(name: string,
  52183. /** The matrix to be applied to the image */
  52184. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52185. }
  52186. }
  52187. declare module "babylonjs/Shaders/fxaa.fragment" {
  52188. /** @hidden */
  52189. export var fxaaPixelShader: {
  52190. name: string;
  52191. shader: string;
  52192. };
  52193. }
  52194. declare module "babylonjs/Shaders/fxaa.vertex" {
  52195. /** @hidden */
  52196. export var fxaaVertexShader: {
  52197. name: string;
  52198. shader: string;
  52199. };
  52200. }
  52201. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52202. import { Nullable } from "babylonjs/types";
  52203. import { Camera } from "babylonjs/Cameras/camera";
  52204. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52205. import { Engine } from "babylonjs/Engines/engine";
  52206. import "babylonjs/Shaders/fxaa.fragment";
  52207. import "babylonjs/Shaders/fxaa.vertex";
  52208. /**
  52209. * Fxaa post process
  52210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52211. */
  52212. export class FxaaPostProcess extends PostProcess {
  52213. /** @hidden */
  52214. texelWidth: number;
  52215. /** @hidden */
  52216. texelHeight: number;
  52217. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52218. private _getDefines;
  52219. }
  52220. }
  52221. declare module "babylonjs/Shaders/grain.fragment" {
  52222. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52223. /** @hidden */
  52224. export var grainPixelShader: {
  52225. name: string;
  52226. shader: string;
  52227. };
  52228. }
  52229. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52230. import { Nullable } from "babylonjs/types";
  52231. import { Camera } from "babylonjs/Cameras/camera";
  52232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52233. import { Engine } from "babylonjs/Engines/engine";
  52234. import "babylonjs/Shaders/grain.fragment";
  52235. /**
  52236. * The GrainPostProcess adds noise to the image at mid luminance levels
  52237. */
  52238. export class GrainPostProcess extends PostProcess {
  52239. /**
  52240. * The intensity of the grain added (default: 30)
  52241. */
  52242. intensity: number;
  52243. /**
  52244. * If the grain should be randomized on every frame
  52245. */
  52246. animated: boolean;
  52247. /**
  52248. * Creates a new instance of @see GrainPostProcess
  52249. * @param name The name of the effect.
  52250. * @param options The required width/height ratio to downsize to before computing the render pass.
  52251. * @param camera The camera to apply the render pass to.
  52252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52253. * @param engine The engine which the post process will be applied. (default: current engine)
  52254. * @param reusable If the post process can be reused on the same frame. (default: false)
  52255. * @param textureType Type of textures used when performing the post process. (default: 0)
  52256. * @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)
  52257. */
  52258. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52259. }
  52260. }
  52261. declare module "babylonjs/Shaders/highlights.fragment" {
  52262. /** @hidden */
  52263. export var highlightsPixelShader: {
  52264. name: string;
  52265. shader: string;
  52266. };
  52267. }
  52268. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52269. import { Nullable } from "babylonjs/types";
  52270. import { Camera } from "babylonjs/Cameras/camera";
  52271. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52272. import { Engine } from "babylonjs/Engines/engine";
  52273. import "babylonjs/Shaders/highlights.fragment";
  52274. /**
  52275. * Extracts highlights from the image
  52276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52277. */
  52278. export class HighlightsPostProcess extends PostProcess {
  52279. /**
  52280. * Extracts highlights from the image
  52281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52282. * @param name The name of the effect.
  52283. * @param options The required width/height ratio to downsize to before computing the render pass.
  52284. * @param camera The camera to apply the render pass to.
  52285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52286. * @param engine The engine which the post process will be applied. (default: current engine)
  52287. * @param reusable If the post process can be reused on the same frame. (default: false)
  52288. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52289. */
  52290. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52291. }
  52292. }
  52293. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52294. /** @hidden */
  52295. export var mrtFragmentDeclaration: {
  52296. name: string;
  52297. shader: string;
  52298. };
  52299. }
  52300. declare module "babylonjs/Shaders/geometry.fragment" {
  52301. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52302. /** @hidden */
  52303. export var geometryPixelShader: {
  52304. name: string;
  52305. shader: string;
  52306. };
  52307. }
  52308. declare module "babylonjs/Shaders/geometry.vertex" {
  52309. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52310. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52311. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52312. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52313. /** @hidden */
  52314. export var geometryVertexShader: {
  52315. name: string;
  52316. shader: string;
  52317. };
  52318. }
  52319. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52320. import { Matrix } from "babylonjs/Maths/math";
  52321. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52322. import { Mesh } from "babylonjs/Meshes/mesh";
  52323. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52324. import { Effect } from "babylonjs/Materials/effect";
  52325. import { Scene } from "babylonjs/scene";
  52326. import "babylonjs/Shaders/geometry.fragment";
  52327. import "babylonjs/Shaders/geometry.vertex";
  52328. /**
  52329. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52330. */
  52331. export class GeometryBufferRenderer {
  52332. /**
  52333. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52334. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52335. */
  52336. static readonly POSITION_TEXTURE_TYPE: number;
  52337. /**
  52338. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52339. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52340. */
  52341. static readonly VELOCITY_TEXTURE_TYPE: number;
  52342. /**
  52343. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52344. * in order to compute objects velocities when enableVelocity is set to "true"
  52345. * @hidden
  52346. */
  52347. _previousTransformationMatrices: {
  52348. [index: number]: Matrix;
  52349. };
  52350. private _scene;
  52351. private _multiRenderTarget;
  52352. private _ratio;
  52353. private _enablePosition;
  52354. private _enableVelocity;
  52355. private _positionIndex;
  52356. private _velocityIndex;
  52357. protected _effect: Effect;
  52358. protected _cachedDefines: string;
  52359. /**
  52360. * Set the render list (meshes to be rendered) used in the G buffer.
  52361. */
  52362. renderList: Mesh[];
  52363. /**
  52364. * Gets wether or not G buffer are supported by the running hardware.
  52365. * This requires draw buffer supports
  52366. */
  52367. readonly isSupported: boolean;
  52368. /**
  52369. * Returns the index of the given texture type in the G-Buffer textures array
  52370. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52371. * @returns the index of the given texture type in the G-Buffer textures array
  52372. */
  52373. getTextureIndex(textureType: number): number;
  52374. /**
  52375. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52376. */
  52377. /**
  52378. * Sets whether or not objects positions are enabled for the G buffer.
  52379. */
  52380. enablePosition: boolean;
  52381. /**
  52382. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52383. */
  52384. /**
  52385. * Sets wether or not objects velocities are enabled for the G buffer.
  52386. */
  52387. enableVelocity: boolean;
  52388. /**
  52389. * Gets the scene associated with the buffer.
  52390. */
  52391. readonly scene: Scene;
  52392. /**
  52393. * Gets the ratio used by the buffer during its creation.
  52394. * How big is the buffer related to the main canvas.
  52395. */
  52396. readonly ratio: number;
  52397. /** @hidden */
  52398. static _SceneComponentInitialization: (scene: Scene) => void;
  52399. /**
  52400. * Creates a new G Buffer for the scene
  52401. * @param scene The scene the buffer belongs to
  52402. * @param ratio How big is the buffer related to the main canvas.
  52403. */
  52404. constructor(scene: Scene, ratio?: number);
  52405. /**
  52406. * Checks wether everything is ready to render a submesh to the G buffer.
  52407. * @param subMesh the submesh to check readiness for
  52408. * @param useInstances is the mesh drawn using instance or not
  52409. * @returns true if ready otherwise false
  52410. */
  52411. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52412. /**
  52413. * Gets the current underlying G Buffer.
  52414. * @returns the buffer
  52415. */
  52416. getGBuffer(): MultiRenderTarget;
  52417. /**
  52418. * Gets the number of samples used to render the buffer (anti aliasing).
  52419. */
  52420. /**
  52421. * Sets the number of samples used to render the buffer (anti aliasing).
  52422. */
  52423. samples: number;
  52424. /**
  52425. * Disposes the renderer and frees up associated resources.
  52426. */
  52427. dispose(): void;
  52428. protected _createRenderTargets(): void;
  52429. }
  52430. }
  52431. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52432. /** @hidden */
  52433. export var motionBlurPixelShader: {
  52434. name: string;
  52435. shader: string;
  52436. };
  52437. }
  52438. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52439. import { Nullable } from "babylonjs/types";
  52440. import { Camera } from "babylonjs/Cameras/camera";
  52441. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52442. import { Scene } from "babylonjs/scene";
  52443. import "babylonjs/Shaders/motionBlur.fragment";
  52444. import { Engine } from "babylonjs/Engines/engine";
  52445. /**
  52446. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52447. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52448. * As an example, all you have to do is to create the post-process:
  52449. * var mb = new BABYLON.MotionBlurPostProcess(
  52450. * 'mb', // The name of the effect.
  52451. * scene, // The scene containing the objects to blur according to their velocity.
  52452. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52453. * camera // The camera to apply the render pass to.
  52454. * );
  52455. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52456. */
  52457. export class MotionBlurPostProcess extends PostProcess {
  52458. /**
  52459. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52460. */
  52461. motionStrength: number;
  52462. /**
  52463. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52464. */
  52465. /**
  52466. * Sets the number of iterations to be used for motion blur quality
  52467. */
  52468. motionBlurSamples: number;
  52469. private _motionBlurSamples;
  52470. private _geometryBufferRenderer;
  52471. /**
  52472. * Creates a new instance MotionBlurPostProcess
  52473. * @param name The name of the effect.
  52474. * @param scene The scene containing the objects to blur according to their velocity.
  52475. * @param options The required width/height ratio to downsize to before computing the render pass.
  52476. * @param camera The camera to apply the render pass to.
  52477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52478. * @param engine The engine which the post process will be applied. (default: current engine)
  52479. * @param reusable If the post process can be reused on the same frame. (default: false)
  52480. * @param textureType Type of textures used when performing the post process. (default: 0)
  52481. * @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)
  52482. */
  52483. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52484. /**
  52485. * Disposes the post process.
  52486. * @param camera The camera to dispose the post process on.
  52487. */
  52488. dispose(camera?: Camera): void;
  52489. }
  52490. }
  52491. declare module "babylonjs/Shaders/refraction.fragment" {
  52492. /** @hidden */
  52493. export var refractionPixelShader: {
  52494. name: string;
  52495. shader: string;
  52496. };
  52497. }
  52498. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52499. import { Color3 } from "babylonjs/Maths/math";
  52500. import { Camera } from "babylonjs/Cameras/camera";
  52501. import { Texture } from "babylonjs/Materials/Textures/texture";
  52502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52503. import { Engine } from "babylonjs/Engines/engine";
  52504. import "babylonjs/Shaders/refraction.fragment";
  52505. /**
  52506. * Post process which applies a refractin texture
  52507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52508. */
  52509. export class RefractionPostProcess extends PostProcess {
  52510. /** the base color of the refraction (used to taint the rendering) */
  52511. color: Color3;
  52512. /** simulated refraction depth */
  52513. depth: number;
  52514. /** the coefficient of the base color (0 to remove base color tainting) */
  52515. colorLevel: number;
  52516. private _refTexture;
  52517. private _ownRefractionTexture;
  52518. /**
  52519. * Gets or sets the refraction texture
  52520. * Please note that you are responsible for disposing the texture if you set it manually
  52521. */
  52522. refractionTexture: Texture;
  52523. /**
  52524. * Initializes the RefractionPostProcess
  52525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52526. * @param name The name of the effect.
  52527. * @param refractionTextureUrl Url of the refraction texture to use
  52528. * @param color the base color of the refraction (used to taint the rendering)
  52529. * @param depth simulated refraction depth
  52530. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52531. * @param camera The camera to apply the render pass to.
  52532. * @param options The required width/height ratio to downsize to before computing the render pass.
  52533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52534. * @param engine The engine which the post process will be applied. (default: current engine)
  52535. * @param reusable If the post process can be reused on the same frame. (default: false)
  52536. */
  52537. constructor(name: string, refractionTextureUrl: string,
  52538. /** the base color of the refraction (used to taint the rendering) */
  52539. color: Color3,
  52540. /** simulated refraction depth */
  52541. depth: number,
  52542. /** the coefficient of the base color (0 to remove base color tainting) */
  52543. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52544. /**
  52545. * Disposes of the post process
  52546. * @param camera Camera to dispose post process on
  52547. */
  52548. dispose(camera: Camera): void;
  52549. }
  52550. }
  52551. declare module "babylonjs/Shaders/sharpen.fragment" {
  52552. /** @hidden */
  52553. export var sharpenPixelShader: {
  52554. name: string;
  52555. shader: string;
  52556. };
  52557. }
  52558. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52559. import { Nullable } from "babylonjs/types";
  52560. import { Camera } from "babylonjs/Cameras/camera";
  52561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52562. import "babylonjs/Shaders/sharpen.fragment";
  52563. import { Engine } from "babylonjs/Engines/engine";
  52564. /**
  52565. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52566. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52567. */
  52568. export class SharpenPostProcess extends PostProcess {
  52569. /**
  52570. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52571. */
  52572. colorAmount: number;
  52573. /**
  52574. * How much sharpness should be applied (default: 0.3)
  52575. */
  52576. edgeAmount: number;
  52577. /**
  52578. * Creates a new instance ConvolutionPostProcess
  52579. * @param name The name of the effect.
  52580. * @param options The required width/height ratio to downsize to before computing the render pass.
  52581. * @param camera The camera to apply the render pass to.
  52582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52583. * @param engine The engine which the post process will be applied. (default: current engine)
  52584. * @param reusable If the post process can be reused on the same frame. (default: false)
  52585. * @param textureType Type of textures used when performing the post process. (default: 0)
  52586. * @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)
  52587. */
  52588. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52589. }
  52590. }
  52591. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52592. import { Nullable } from "babylonjs/types";
  52593. import { Camera } from "babylonjs/Cameras/camera";
  52594. import { Engine } from "babylonjs/Engines/engine";
  52595. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52596. /**
  52597. * PostProcessRenderPipeline
  52598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52599. */
  52600. export class PostProcessRenderPipeline {
  52601. private engine;
  52602. private _renderEffects;
  52603. private _renderEffectsForIsolatedPass;
  52604. /**
  52605. * @hidden
  52606. */
  52607. protected _cameras: Camera[];
  52608. /** @hidden */
  52609. _name: string;
  52610. /**
  52611. * Gets pipeline name
  52612. */
  52613. readonly name: string;
  52614. /**
  52615. * Initializes a PostProcessRenderPipeline
  52616. * @param engine engine to add the pipeline to
  52617. * @param name name of the pipeline
  52618. */
  52619. constructor(engine: Engine, name: string);
  52620. /**
  52621. * Gets the class name
  52622. * @returns "PostProcessRenderPipeline"
  52623. */
  52624. getClassName(): string;
  52625. /**
  52626. * If all the render effects in the pipeline are supported
  52627. */
  52628. readonly isSupported: boolean;
  52629. /**
  52630. * Adds an effect to the pipeline
  52631. * @param renderEffect the effect to add
  52632. */
  52633. addEffect(renderEffect: PostProcessRenderEffect): void;
  52634. /** @hidden */
  52635. _rebuild(): void;
  52636. /** @hidden */
  52637. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52638. /** @hidden */
  52639. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52640. /** @hidden */
  52641. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52642. /** @hidden */
  52643. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52644. /** @hidden */
  52645. _attachCameras(cameras: Camera, unique: boolean): void;
  52646. /** @hidden */
  52647. _attachCameras(cameras: Camera[], unique: boolean): void;
  52648. /** @hidden */
  52649. _detachCameras(cameras: Camera): void;
  52650. /** @hidden */
  52651. _detachCameras(cameras: Nullable<Camera[]>): void;
  52652. /** @hidden */
  52653. _update(): void;
  52654. /** @hidden */
  52655. _reset(): void;
  52656. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52657. /**
  52658. * Disposes of the pipeline
  52659. */
  52660. dispose(): void;
  52661. }
  52662. }
  52663. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52664. import { IAnimatable } from "babylonjs/Misc/tools";
  52665. import { Camera } from "babylonjs/Cameras/camera";
  52666. import { IDisposable } from "babylonjs/scene";
  52667. import { Scene } from "babylonjs/scene";
  52668. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52669. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52670. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52671. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52672. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52673. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52674. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52675. import { Animation } from "babylonjs/Animations/animation";
  52676. /**
  52677. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52678. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52679. */
  52680. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52681. private _scene;
  52682. private _camerasToBeAttached;
  52683. /**
  52684. * ID of the sharpen post process,
  52685. */
  52686. private readonly SharpenPostProcessId;
  52687. /**
  52688. * @ignore
  52689. * ID of the image processing post process;
  52690. */
  52691. readonly ImageProcessingPostProcessId: string;
  52692. /**
  52693. * @ignore
  52694. * ID of the Fast Approximate Anti-Aliasing post process;
  52695. */
  52696. readonly FxaaPostProcessId: string;
  52697. /**
  52698. * ID of the chromatic aberration post process,
  52699. */
  52700. private readonly ChromaticAberrationPostProcessId;
  52701. /**
  52702. * ID of the grain post process
  52703. */
  52704. private readonly GrainPostProcessId;
  52705. /**
  52706. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52707. */
  52708. sharpen: SharpenPostProcess;
  52709. private _sharpenEffect;
  52710. private bloom;
  52711. /**
  52712. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52713. */
  52714. depthOfField: DepthOfFieldEffect;
  52715. /**
  52716. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52717. */
  52718. fxaa: FxaaPostProcess;
  52719. /**
  52720. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52721. */
  52722. imageProcessing: ImageProcessingPostProcess;
  52723. /**
  52724. * Chromatic aberration post process which will shift rgb colors in the image
  52725. */
  52726. chromaticAberration: ChromaticAberrationPostProcess;
  52727. private _chromaticAberrationEffect;
  52728. /**
  52729. * Grain post process which add noise to the image
  52730. */
  52731. grain: GrainPostProcess;
  52732. private _grainEffect;
  52733. /**
  52734. * Glow post process which adds a glow to emissive areas of the image
  52735. */
  52736. private _glowLayer;
  52737. /**
  52738. * Animations which can be used to tweak settings over a period of time
  52739. */
  52740. animations: Animation[];
  52741. private _imageProcessingConfigurationObserver;
  52742. private _sharpenEnabled;
  52743. private _bloomEnabled;
  52744. private _depthOfFieldEnabled;
  52745. private _depthOfFieldBlurLevel;
  52746. private _fxaaEnabled;
  52747. private _imageProcessingEnabled;
  52748. private _defaultPipelineTextureType;
  52749. private _bloomScale;
  52750. private _chromaticAberrationEnabled;
  52751. private _grainEnabled;
  52752. private _buildAllowed;
  52753. /**
  52754. * Gets active scene
  52755. */
  52756. readonly scene: Scene;
  52757. /**
  52758. * Enable or disable the sharpen process from the pipeline
  52759. */
  52760. sharpenEnabled: boolean;
  52761. private _resizeObserver;
  52762. private _hardwareScaleLevel;
  52763. private _bloomKernel;
  52764. /**
  52765. * Specifies the size of the bloom blur kernel, relative to the final output size
  52766. */
  52767. bloomKernel: number;
  52768. /**
  52769. * Specifies the weight of the bloom in the final rendering
  52770. */
  52771. private _bloomWeight;
  52772. /**
  52773. * Specifies the luma threshold for the area that will be blurred by the bloom
  52774. */
  52775. private _bloomThreshold;
  52776. private _hdr;
  52777. /**
  52778. * The strength of the bloom.
  52779. */
  52780. bloomWeight: number;
  52781. /**
  52782. * The strength of the bloom.
  52783. */
  52784. bloomThreshold: number;
  52785. /**
  52786. * The scale of the bloom, lower value will provide better performance.
  52787. */
  52788. bloomScale: number;
  52789. /**
  52790. * Enable or disable the bloom from the pipeline
  52791. */
  52792. bloomEnabled: boolean;
  52793. private _rebuildBloom;
  52794. /**
  52795. * If the depth of field is enabled.
  52796. */
  52797. depthOfFieldEnabled: boolean;
  52798. /**
  52799. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52800. */
  52801. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52802. /**
  52803. * If the anti aliasing is enabled.
  52804. */
  52805. fxaaEnabled: boolean;
  52806. private _samples;
  52807. /**
  52808. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52809. */
  52810. samples: number;
  52811. /**
  52812. * If image processing is enabled.
  52813. */
  52814. imageProcessingEnabled: boolean;
  52815. /**
  52816. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52817. */
  52818. glowLayerEnabled: boolean;
  52819. /**
  52820. * Enable or disable the chromaticAberration process from the pipeline
  52821. */
  52822. chromaticAberrationEnabled: boolean;
  52823. /**
  52824. * Enable or disable the grain process from the pipeline
  52825. */
  52826. grainEnabled: boolean;
  52827. /**
  52828. * @constructor
  52829. * @param name - The rendering pipeline name (default: "")
  52830. * @param hdr - If high dynamic range textures should be used (default: true)
  52831. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52832. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52833. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52834. */
  52835. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52836. /**
  52837. * Get the class name
  52838. * @returns "DefaultRenderingPipeline"
  52839. */
  52840. getClassName(): string;
  52841. /**
  52842. * Force the compilation of the entire pipeline.
  52843. */
  52844. prepare(): void;
  52845. private _hasCleared;
  52846. private _prevPostProcess;
  52847. private _prevPrevPostProcess;
  52848. private _setAutoClearAndTextureSharing;
  52849. private _depthOfFieldSceneObserver;
  52850. private _buildPipeline;
  52851. private _disposePostProcesses;
  52852. /**
  52853. * Adds a camera to the pipeline
  52854. * @param camera the camera to be added
  52855. */
  52856. addCamera(camera: Camera): void;
  52857. /**
  52858. * Removes a camera from the pipeline
  52859. * @param camera the camera to remove
  52860. */
  52861. removeCamera(camera: Camera): void;
  52862. /**
  52863. * Dispose of the pipeline and stop all post processes
  52864. */
  52865. dispose(): void;
  52866. /**
  52867. * Serialize the rendering pipeline (Used when exporting)
  52868. * @returns the serialized object
  52869. */
  52870. serialize(): any;
  52871. /**
  52872. * Parse the serialized pipeline
  52873. * @param source Source pipeline.
  52874. * @param scene The scene to load the pipeline to.
  52875. * @param rootUrl The URL of the serialized pipeline.
  52876. * @returns An instantiated pipeline from the serialized object.
  52877. */
  52878. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52879. }
  52880. }
  52881. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52882. /** @hidden */
  52883. export var lensHighlightsPixelShader: {
  52884. name: string;
  52885. shader: string;
  52886. };
  52887. }
  52888. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52889. /** @hidden */
  52890. export var depthOfFieldPixelShader: {
  52891. name: string;
  52892. shader: string;
  52893. };
  52894. }
  52895. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52896. import { Camera } from "babylonjs/Cameras/camera";
  52897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52898. import { Scene } from "babylonjs/scene";
  52899. import "babylonjs/Shaders/chromaticAberration.fragment";
  52900. import "babylonjs/Shaders/lensHighlights.fragment";
  52901. import "babylonjs/Shaders/depthOfField.fragment";
  52902. /**
  52903. * BABYLON.JS Chromatic Aberration GLSL Shader
  52904. * Author: Olivier Guyot
  52905. * Separates very slightly R, G and B colors on the edges of the screen
  52906. * Inspired by Francois Tarlier & Martins Upitis
  52907. */
  52908. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52909. /**
  52910. * @ignore
  52911. * The chromatic aberration PostProcess id in the pipeline
  52912. */
  52913. LensChromaticAberrationEffect: string;
  52914. /**
  52915. * @ignore
  52916. * The highlights enhancing PostProcess id in the pipeline
  52917. */
  52918. HighlightsEnhancingEffect: string;
  52919. /**
  52920. * @ignore
  52921. * The depth-of-field PostProcess id in the pipeline
  52922. */
  52923. LensDepthOfFieldEffect: string;
  52924. private _scene;
  52925. private _depthTexture;
  52926. private _grainTexture;
  52927. private _chromaticAberrationPostProcess;
  52928. private _highlightsPostProcess;
  52929. private _depthOfFieldPostProcess;
  52930. private _edgeBlur;
  52931. private _grainAmount;
  52932. private _chromaticAberration;
  52933. private _distortion;
  52934. private _highlightsGain;
  52935. private _highlightsThreshold;
  52936. private _dofDistance;
  52937. private _dofAperture;
  52938. private _dofDarken;
  52939. private _dofPentagon;
  52940. private _blurNoise;
  52941. /**
  52942. * @constructor
  52943. *
  52944. * Effect parameters are as follow:
  52945. * {
  52946. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52947. * edge_blur: number; // from 0 to x (1 for realism)
  52948. * distortion: number; // from 0 to x (1 for realism)
  52949. * grain_amount: number; // from 0 to 1
  52950. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52951. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52952. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52953. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52954. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52955. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52956. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52957. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52958. * }
  52959. * Note: if an effect parameter is unset, effect is disabled
  52960. *
  52961. * @param name The rendering pipeline name
  52962. * @param parameters - An object containing all parameters (see above)
  52963. * @param scene The scene linked to this pipeline
  52964. * @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)
  52965. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52966. */
  52967. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52968. /**
  52969. * Sets the amount of blur at the edges
  52970. * @param amount blur amount
  52971. */
  52972. setEdgeBlur(amount: number): void;
  52973. /**
  52974. * Sets edge blur to 0
  52975. */
  52976. disableEdgeBlur(): void;
  52977. /**
  52978. * Sets the amout of grain
  52979. * @param amount Amount of grain
  52980. */
  52981. setGrainAmount(amount: number): void;
  52982. /**
  52983. * Set grain amount to 0
  52984. */
  52985. disableGrain(): void;
  52986. /**
  52987. * Sets the chromatic aberration amount
  52988. * @param amount amount of chromatic aberration
  52989. */
  52990. setChromaticAberration(amount: number): void;
  52991. /**
  52992. * Sets chromatic aberration amount to 0
  52993. */
  52994. disableChromaticAberration(): void;
  52995. /**
  52996. * Sets the EdgeDistortion amount
  52997. * @param amount amount of EdgeDistortion
  52998. */
  52999. setEdgeDistortion(amount: number): void;
  53000. /**
  53001. * Sets edge distortion to 0
  53002. */
  53003. disableEdgeDistortion(): void;
  53004. /**
  53005. * Sets the FocusDistance amount
  53006. * @param amount amount of FocusDistance
  53007. */
  53008. setFocusDistance(amount: number): void;
  53009. /**
  53010. * Disables depth of field
  53011. */
  53012. disableDepthOfField(): void;
  53013. /**
  53014. * Sets the Aperture amount
  53015. * @param amount amount of Aperture
  53016. */
  53017. setAperture(amount: number): void;
  53018. /**
  53019. * Sets the DarkenOutOfFocus amount
  53020. * @param amount amount of DarkenOutOfFocus
  53021. */
  53022. setDarkenOutOfFocus(amount: number): void;
  53023. /**
  53024. * Creates a pentagon bokeh effect
  53025. */
  53026. enablePentagonBokeh(): void;
  53027. /**
  53028. * Disables the pentagon bokeh effect
  53029. */
  53030. disablePentagonBokeh(): void;
  53031. /**
  53032. * Enables noise blur
  53033. */
  53034. enableNoiseBlur(): void;
  53035. /**
  53036. * Disables noise blur
  53037. */
  53038. disableNoiseBlur(): void;
  53039. /**
  53040. * Sets the HighlightsGain amount
  53041. * @param amount amount of HighlightsGain
  53042. */
  53043. setHighlightsGain(amount: number): void;
  53044. /**
  53045. * Sets the HighlightsThreshold amount
  53046. * @param amount amount of HighlightsThreshold
  53047. */
  53048. setHighlightsThreshold(amount: number): void;
  53049. /**
  53050. * Disables highlights
  53051. */
  53052. disableHighlights(): void;
  53053. /**
  53054. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53055. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53056. */
  53057. dispose(disableDepthRender?: boolean): void;
  53058. private _createChromaticAberrationPostProcess;
  53059. private _createHighlightsPostProcess;
  53060. private _createDepthOfFieldPostProcess;
  53061. private _createGrainTexture;
  53062. }
  53063. }
  53064. declare module "babylonjs/Shaders/ssao2.fragment" {
  53065. /** @hidden */
  53066. export var ssao2PixelShader: {
  53067. name: string;
  53068. shader: string;
  53069. };
  53070. }
  53071. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53072. /** @hidden */
  53073. export var ssaoCombinePixelShader: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53079. import { Camera } from "babylonjs/Cameras/camera";
  53080. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53081. import { Scene } from "babylonjs/scene";
  53082. import "babylonjs/Shaders/ssao2.fragment";
  53083. import "babylonjs/Shaders/ssaoCombine.fragment";
  53084. /**
  53085. * Render pipeline to produce ssao effect
  53086. */
  53087. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53088. /**
  53089. * @ignore
  53090. * The PassPostProcess id in the pipeline that contains the original scene color
  53091. */
  53092. SSAOOriginalSceneColorEffect: string;
  53093. /**
  53094. * @ignore
  53095. * The SSAO PostProcess id in the pipeline
  53096. */
  53097. SSAORenderEffect: string;
  53098. /**
  53099. * @ignore
  53100. * The horizontal blur PostProcess id in the pipeline
  53101. */
  53102. SSAOBlurHRenderEffect: string;
  53103. /**
  53104. * @ignore
  53105. * The vertical blur PostProcess id in the pipeline
  53106. */
  53107. SSAOBlurVRenderEffect: string;
  53108. /**
  53109. * @ignore
  53110. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53111. */
  53112. SSAOCombineRenderEffect: string;
  53113. /**
  53114. * The output strength of the SSAO post-process. Default value is 1.0.
  53115. */
  53116. totalStrength: number;
  53117. /**
  53118. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53119. */
  53120. maxZ: number;
  53121. /**
  53122. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53123. */
  53124. minZAspect: number;
  53125. private _samples;
  53126. /**
  53127. * Number of samples used for the SSAO calculations. Default value is 8
  53128. */
  53129. samples: number;
  53130. private _textureSamples;
  53131. /**
  53132. * Number of samples to use for antialiasing
  53133. */
  53134. textureSamples: number;
  53135. /**
  53136. * Ratio object used for SSAO ratio and blur ratio
  53137. */
  53138. private _ratio;
  53139. /**
  53140. * Dynamically generated sphere sampler.
  53141. */
  53142. private _sampleSphere;
  53143. /**
  53144. * Blur filter offsets
  53145. */
  53146. private _samplerOffsets;
  53147. private _expensiveBlur;
  53148. /**
  53149. * If bilateral blur should be used
  53150. */
  53151. expensiveBlur: boolean;
  53152. /**
  53153. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53154. */
  53155. radius: number;
  53156. /**
  53157. * The base color of the SSAO post-process
  53158. * The final result is "base + ssao" between [0, 1]
  53159. */
  53160. base: number;
  53161. /**
  53162. * Support test.
  53163. */
  53164. static readonly IsSupported: boolean;
  53165. private _scene;
  53166. private _depthTexture;
  53167. private _normalTexture;
  53168. private _randomTexture;
  53169. private _originalColorPostProcess;
  53170. private _ssaoPostProcess;
  53171. private _blurHPostProcess;
  53172. private _blurVPostProcess;
  53173. private _ssaoCombinePostProcess;
  53174. private _firstUpdate;
  53175. /**
  53176. * @constructor
  53177. * @param name The rendering pipeline name
  53178. * @param scene The scene linked to this pipeline
  53179. * @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 }
  53180. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53181. */
  53182. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53183. /**
  53184. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53185. */
  53186. dispose(disableGeometryBufferRenderer?: boolean): void;
  53187. private _createBlurPostProcess;
  53188. /** @hidden */
  53189. _rebuild(): void;
  53190. private _bits;
  53191. private _radicalInverse_VdC;
  53192. private _hammersley;
  53193. private _hemisphereSample_uniform;
  53194. private _generateHemisphere;
  53195. private _createSSAOPostProcess;
  53196. private _createSSAOCombinePostProcess;
  53197. private _createRandomTexture;
  53198. /**
  53199. * Serialize the rendering pipeline (Used when exporting)
  53200. * @returns the serialized object
  53201. */
  53202. serialize(): any;
  53203. /**
  53204. * Parse the serialized pipeline
  53205. * @param source Source pipeline.
  53206. * @param scene The scene to load the pipeline to.
  53207. * @param rootUrl The URL of the serialized pipeline.
  53208. * @returns An instantiated pipeline from the serialized object.
  53209. */
  53210. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53211. }
  53212. }
  53213. declare module "babylonjs/Shaders/ssao.fragment" {
  53214. /** @hidden */
  53215. export var ssaoPixelShader: {
  53216. name: string;
  53217. shader: string;
  53218. };
  53219. }
  53220. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53221. import { Camera } from "babylonjs/Cameras/camera";
  53222. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53223. import { Scene } from "babylonjs/scene";
  53224. import "babylonjs/Shaders/ssao.fragment";
  53225. import "babylonjs/Shaders/ssaoCombine.fragment";
  53226. /**
  53227. * Render pipeline to produce ssao effect
  53228. */
  53229. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53230. /**
  53231. * @ignore
  53232. * The PassPostProcess id in the pipeline that contains the original scene color
  53233. */
  53234. SSAOOriginalSceneColorEffect: string;
  53235. /**
  53236. * @ignore
  53237. * The SSAO PostProcess id in the pipeline
  53238. */
  53239. SSAORenderEffect: string;
  53240. /**
  53241. * @ignore
  53242. * The horizontal blur PostProcess id in the pipeline
  53243. */
  53244. SSAOBlurHRenderEffect: string;
  53245. /**
  53246. * @ignore
  53247. * The vertical blur PostProcess id in the pipeline
  53248. */
  53249. SSAOBlurVRenderEffect: string;
  53250. /**
  53251. * @ignore
  53252. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53253. */
  53254. SSAOCombineRenderEffect: string;
  53255. /**
  53256. * The output strength of the SSAO post-process. Default value is 1.0.
  53257. */
  53258. totalStrength: number;
  53259. /**
  53260. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53261. */
  53262. radius: number;
  53263. /**
  53264. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53265. * Must not be equal to fallOff and superior to fallOff.
  53266. * Default value is 0.975
  53267. */
  53268. area: number;
  53269. /**
  53270. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53271. * Must not be equal to area and inferior to area.
  53272. * Default value is 0.0
  53273. */
  53274. fallOff: number;
  53275. /**
  53276. * The base color of the SSAO post-process
  53277. * The final result is "base + ssao" between [0, 1]
  53278. */
  53279. base: number;
  53280. private _scene;
  53281. private _depthTexture;
  53282. private _randomTexture;
  53283. private _originalColorPostProcess;
  53284. private _ssaoPostProcess;
  53285. private _blurHPostProcess;
  53286. private _blurVPostProcess;
  53287. private _ssaoCombinePostProcess;
  53288. private _firstUpdate;
  53289. /**
  53290. * @constructor
  53291. * @param name - The rendering pipeline name
  53292. * @param scene - The scene linked to this pipeline
  53293. * @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 }
  53294. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53295. */
  53296. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53297. /**
  53298. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53299. */
  53300. dispose(disableDepthRender?: boolean): void;
  53301. private _createBlurPostProcess;
  53302. /** @hidden */
  53303. _rebuild(): void;
  53304. private _createSSAOPostProcess;
  53305. private _createSSAOCombinePostProcess;
  53306. private _createRandomTexture;
  53307. }
  53308. }
  53309. declare module "babylonjs/Shaders/standard.fragment" {
  53310. /** @hidden */
  53311. export var standardPixelShader: {
  53312. name: string;
  53313. shader: string;
  53314. };
  53315. }
  53316. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53317. import { Nullable } from "babylonjs/types";
  53318. import { IAnimatable } from "babylonjs/Misc/tools";
  53319. import { Camera } from "babylonjs/Cameras/camera";
  53320. import { Texture } from "babylonjs/Materials/Textures/texture";
  53321. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53322. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53323. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53324. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53325. import { IDisposable } from "babylonjs/scene";
  53326. import { SpotLight } from "babylonjs/Lights/spotLight";
  53327. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53328. import { Scene } from "babylonjs/scene";
  53329. import { Animation } from "babylonjs/Animations/animation";
  53330. import "babylonjs/Shaders/standard.fragment";
  53331. /**
  53332. * Standard rendering pipeline
  53333. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53334. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53335. */
  53336. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53337. /**
  53338. * Public members
  53339. */
  53340. /**
  53341. * Post-process which contains the original scene color before the pipeline applies all the effects
  53342. */
  53343. originalPostProcess: Nullable<PostProcess>;
  53344. /**
  53345. * Post-process used to down scale an image x4
  53346. */
  53347. downSampleX4PostProcess: Nullable<PostProcess>;
  53348. /**
  53349. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53350. */
  53351. brightPassPostProcess: Nullable<PostProcess>;
  53352. /**
  53353. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53354. */
  53355. blurHPostProcesses: PostProcess[];
  53356. /**
  53357. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53358. */
  53359. blurVPostProcesses: PostProcess[];
  53360. /**
  53361. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53362. */
  53363. textureAdderPostProcess: Nullable<PostProcess>;
  53364. /**
  53365. * Post-process used to create volumetric lighting effect
  53366. */
  53367. volumetricLightPostProcess: Nullable<PostProcess>;
  53368. /**
  53369. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53370. */
  53371. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53372. /**
  53373. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53374. */
  53375. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53376. /**
  53377. * Post-process used to merge the volumetric light effect and the real scene color
  53378. */
  53379. volumetricLightMergePostProces: Nullable<PostProcess>;
  53380. /**
  53381. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53382. */
  53383. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53384. /**
  53385. * Base post-process used to calculate the average luminance of the final image for HDR
  53386. */
  53387. luminancePostProcess: Nullable<PostProcess>;
  53388. /**
  53389. * Post-processes used to create down sample post-processes in order to get
  53390. * the average luminance of the final image for HDR
  53391. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53392. */
  53393. luminanceDownSamplePostProcesses: PostProcess[];
  53394. /**
  53395. * Post-process used to create a HDR effect (light adaptation)
  53396. */
  53397. hdrPostProcess: Nullable<PostProcess>;
  53398. /**
  53399. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53400. */
  53401. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53402. /**
  53403. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53404. */
  53405. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53406. /**
  53407. * Post-process used to merge the final HDR post-process and the real scene color
  53408. */
  53409. hdrFinalPostProcess: Nullable<PostProcess>;
  53410. /**
  53411. * Post-process used to create a lens flare effect
  53412. */
  53413. lensFlarePostProcess: Nullable<PostProcess>;
  53414. /**
  53415. * Post-process that merges the result of the lens flare post-process and the real scene color
  53416. */
  53417. lensFlareComposePostProcess: Nullable<PostProcess>;
  53418. /**
  53419. * Post-process used to create a motion blur effect
  53420. */
  53421. motionBlurPostProcess: Nullable<PostProcess>;
  53422. /**
  53423. * Post-process used to create a depth of field effect
  53424. */
  53425. depthOfFieldPostProcess: Nullable<PostProcess>;
  53426. /**
  53427. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53428. */
  53429. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53430. /**
  53431. * Represents the brightness threshold in order to configure the illuminated surfaces
  53432. */
  53433. brightThreshold: number;
  53434. /**
  53435. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53436. */
  53437. blurWidth: number;
  53438. /**
  53439. * Sets if the blur for highlighted surfaces must be only horizontal
  53440. */
  53441. horizontalBlur: boolean;
  53442. /**
  53443. * Sets the overall exposure used by the pipeline
  53444. */
  53445. exposure: number;
  53446. /**
  53447. * Texture used typically to simulate "dirty" on camera lens
  53448. */
  53449. lensTexture: Nullable<Texture>;
  53450. /**
  53451. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53452. */
  53453. volumetricLightCoefficient: number;
  53454. /**
  53455. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53456. */
  53457. volumetricLightPower: number;
  53458. /**
  53459. * Used the set the blur intensity to smooth the volumetric lights
  53460. */
  53461. volumetricLightBlurScale: number;
  53462. /**
  53463. * Light (spot or directional) used to generate the volumetric lights rays
  53464. * The source light must have a shadow generate so the pipeline can get its
  53465. * depth map
  53466. */
  53467. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53468. /**
  53469. * For eye adaptation, represents the minimum luminance the eye can see
  53470. */
  53471. hdrMinimumLuminance: number;
  53472. /**
  53473. * For eye adaptation, represents the decrease luminance speed
  53474. */
  53475. hdrDecreaseRate: number;
  53476. /**
  53477. * For eye adaptation, represents the increase luminance speed
  53478. */
  53479. hdrIncreaseRate: number;
  53480. /**
  53481. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53482. */
  53483. lensColorTexture: Nullable<Texture>;
  53484. /**
  53485. * The overall strengh for the lens flare effect
  53486. */
  53487. lensFlareStrength: number;
  53488. /**
  53489. * Dispersion coefficient for lens flare ghosts
  53490. */
  53491. lensFlareGhostDispersal: number;
  53492. /**
  53493. * Main lens flare halo width
  53494. */
  53495. lensFlareHaloWidth: number;
  53496. /**
  53497. * Based on the lens distortion effect, defines how much the lens flare result
  53498. * is distorted
  53499. */
  53500. lensFlareDistortionStrength: number;
  53501. /**
  53502. * Lens star texture must be used to simulate rays on the flares and is available
  53503. * in the documentation
  53504. */
  53505. lensStarTexture: Nullable<Texture>;
  53506. /**
  53507. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53508. * flare effect by taking account of the dirt texture
  53509. */
  53510. lensFlareDirtTexture: Nullable<Texture>;
  53511. /**
  53512. * Represents the focal length for the depth of field effect
  53513. */
  53514. depthOfFieldDistance: number;
  53515. /**
  53516. * Represents the blur intensity for the blurred part of the depth of field effect
  53517. */
  53518. depthOfFieldBlurWidth: number;
  53519. /**
  53520. * For motion blur, defines how much the image is blurred by the movement
  53521. */
  53522. motionStrength: number;
  53523. /**
  53524. * List of animations for the pipeline (IAnimatable implementation)
  53525. */
  53526. animations: Animation[];
  53527. /**
  53528. * Private members
  53529. */
  53530. private _scene;
  53531. private _currentDepthOfFieldSource;
  53532. private _basePostProcess;
  53533. private _hdrCurrentLuminance;
  53534. private _floatTextureType;
  53535. private _ratio;
  53536. private _bloomEnabled;
  53537. private _depthOfFieldEnabled;
  53538. private _vlsEnabled;
  53539. private _lensFlareEnabled;
  53540. private _hdrEnabled;
  53541. private _motionBlurEnabled;
  53542. private _fxaaEnabled;
  53543. private _motionBlurSamples;
  53544. private _volumetricLightStepsCount;
  53545. private _samples;
  53546. /**
  53547. * @ignore
  53548. * Specifies if the bloom pipeline is enabled
  53549. */
  53550. BloomEnabled: boolean;
  53551. /**
  53552. * @ignore
  53553. * Specifies if the depth of field pipeline is enabed
  53554. */
  53555. DepthOfFieldEnabled: boolean;
  53556. /**
  53557. * @ignore
  53558. * Specifies if the lens flare pipeline is enabed
  53559. */
  53560. LensFlareEnabled: boolean;
  53561. /**
  53562. * @ignore
  53563. * Specifies if the HDR pipeline is enabled
  53564. */
  53565. HDREnabled: boolean;
  53566. /**
  53567. * @ignore
  53568. * Specifies if the volumetric lights scattering effect is enabled
  53569. */
  53570. VLSEnabled: boolean;
  53571. /**
  53572. * @ignore
  53573. * Specifies if the motion blur effect is enabled
  53574. */
  53575. MotionBlurEnabled: boolean;
  53576. /**
  53577. * Specifies if anti-aliasing is enabled
  53578. */
  53579. fxaaEnabled: boolean;
  53580. /**
  53581. * Specifies the number of steps used to calculate the volumetric lights
  53582. * Typically in interval [50, 200]
  53583. */
  53584. volumetricLightStepsCount: number;
  53585. /**
  53586. * Specifies the number of samples used for the motion blur effect
  53587. * Typically in interval [16, 64]
  53588. */
  53589. motionBlurSamples: number;
  53590. /**
  53591. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53592. */
  53593. samples: number;
  53594. /**
  53595. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53596. * @constructor
  53597. * @param name The rendering pipeline name
  53598. * @param scene The scene linked to this pipeline
  53599. * @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)
  53600. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53601. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53602. */
  53603. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53604. private _buildPipeline;
  53605. private _createDownSampleX4PostProcess;
  53606. private _createBrightPassPostProcess;
  53607. private _createBlurPostProcesses;
  53608. private _createTextureAdderPostProcess;
  53609. private _createVolumetricLightPostProcess;
  53610. private _createLuminancePostProcesses;
  53611. private _createHdrPostProcess;
  53612. private _createLensFlarePostProcess;
  53613. private _createDepthOfFieldPostProcess;
  53614. private _createMotionBlurPostProcess;
  53615. private _getDepthTexture;
  53616. private _disposePostProcesses;
  53617. /**
  53618. * Dispose of the pipeline and stop all post processes
  53619. */
  53620. dispose(): void;
  53621. /**
  53622. * Serialize the rendering pipeline (Used when exporting)
  53623. * @returns the serialized object
  53624. */
  53625. serialize(): any;
  53626. /**
  53627. * Parse the serialized pipeline
  53628. * @param source Source pipeline.
  53629. * @param scene The scene to load the pipeline to.
  53630. * @param rootUrl The URL of the serialized pipeline.
  53631. * @returns An instantiated pipeline from the serialized object.
  53632. */
  53633. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53634. /**
  53635. * Luminance steps
  53636. */
  53637. static LuminanceSteps: number;
  53638. }
  53639. }
  53640. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53641. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53642. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53643. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53644. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53645. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53646. }
  53647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53648. import { Camera } from "babylonjs/Cameras/camera";
  53649. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53650. /**
  53651. * PostProcessRenderPipelineManager class
  53652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53653. */
  53654. export class PostProcessRenderPipelineManager {
  53655. private _renderPipelines;
  53656. /**
  53657. * Initializes a PostProcessRenderPipelineManager
  53658. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53659. */
  53660. constructor();
  53661. /**
  53662. * Gets the list of supported render pipelines
  53663. */
  53664. readonly supportedPipelines: PostProcessRenderPipeline[];
  53665. /**
  53666. * Adds a pipeline to the manager
  53667. * @param renderPipeline The pipeline to add
  53668. */
  53669. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53670. /**
  53671. * Attaches a camera to the pipeline
  53672. * @param renderPipelineName The name of the pipeline to attach to
  53673. * @param cameras the camera to attach
  53674. * @param unique if the camera can be attached multiple times to the pipeline
  53675. */
  53676. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53677. /**
  53678. * Detaches a camera from the pipeline
  53679. * @param renderPipelineName The name of the pipeline to detach from
  53680. * @param cameras the camera to detach
  53681. */
  53682. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53683. /**
  53684. * Enables an effect by name on a pipeline
  53685. * @param renderPipelineName the name of the pipeline to enable the effect in
  53686. * @param renderEffectName the name of the effect to enable
  53687. * @param cameras the cameras that the effect should be enabled on
  53688. */
  53689. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53690. /**
  53691. * Disables an effect by name on a pipeline
  53692. * @param renderPipelineName the name of the pipeline to disable the effect in
  53693. * @param renderEffectName the name of the effect to disable
  53694. * @param cameras the cameras that the effect should be disabled on
  53695. */
  53696. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53697. /**
  53698. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53699. */
  53700. update(): void;
  53701. /** @hidden */
  53702. _rebuild(): void;
  53703. /**
  53704. * Disposes of the manager and pipelines
  53705. */
  53706. dispose(): void;
  53707. }
  53708. }
  53709. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53710. import { ISceneComponent } from "babylonjs/sceneComponent";
  53711. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53712. import { Scene } from "babylonjs/scene";
  53713. module "babylonjs/scene" {
  53714. interface Scene {
  53715. /** @hidden (Backing field) */
  53716. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53717. /**
  53718. * Gets the postprocess render pipeline manager
  53719. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53720. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53721. */
  53722. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53723. }
  53724. }
  53725. /**
  53726. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53727. */
  53728. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53729. /**
  53730. * The component name helpfull to identify the component in the list of scene components.
  53731. */
  53732. readonly name: string;
  53733. /**
  53734. * The scene the component belongs to.
  53735. */
  53736. scene: Scene;
  53737. /**
  53738. * Creates a new instance of the component for the given scene
  53739. * @param scene Defines the scene to register the component in
  53740. */
  53741. constructor(scene: Scene);
  53742. /**
  53743. * Registers the component in a given scene
  53744. */
  53745. register(): void;
  53746. /**
  53747. * Rebuilds the elements related to this component in case of
  53748. * context lost for instance.
  53749. */
  53750. rebuild(): void;
  53751. /**
  53752. * Disposes the component and the associated ressources
  53753. */
  53754. dispose(): void;
  53755. private _gatherRenderTargets;
  53756. }
  53757. }
  53758. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53759. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53760. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53761. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53762. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53763. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53764. }
  53765. declare module "babylonjs/Shaders/tonemap.fragment" {
  53766. /** @hidden */
  53767. export var tonemapPixelShader: {
  53768. name: string;
  53769. shader: string;
  53770. };
  53771. }
  53772. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53773. import { Camera } from "babylonjs/Cameras/camera";
  53774. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53775. import "babylonjs/Shaders/tonemap.fragment";
  53776. import { Engine } from "babylonjs/Engines/engine";
  53777. /** Defines operator used for tonemapping */
  53778. export enum TonemappingOperator {
  53779. /** Hable */
  53780. Hable = 0,
  53781. /** Reinhard */
  53782. Reinhard = 1,
  53783. /** HejiDawson */
  53784. HejiDawson = 2,
  53785. /** Photographic */
  53786. Photographic = 3
  53787. }
  53788. /**
  53789. * Defines a post process to apply tone mapping
  53790. */
  53791. export class TonemapPostProcess extends PostProcess {
  53792. private _operator;
  53793. /** Defines the required exposure adjustement */
  53794. exposureAdjustment: number;
  53795. /**
  53796. * Creates a new TonemapPostProcess
  53797. * @param name defines the name of the postprocess
  53798. * @param _operator defines the operator to use
  53799. * @param exposureAdjustment defines the required exposure adjustement
  53800. * @param camera defines the camera to use (can be null)
  53801. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53802. * @param engine defines the hosting engine (can be ignore if camera is set)
  53803. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53804. */
  53805. constructor(name: string, _operator: TonemappingOperator,
  53806. /** Defines the required exposure adjustement */
  53807. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53808. }
  53809. }
  53810. declare module "babylonjs/Shaders/depth.vertex" {
  53811. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53812. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53813. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53814. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53815. /** @hidden */
  53816. export var depthVertexShader: {
  53817. name: string;
  53818. shader: string;
  53819. };
  53820. }
  53821. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53822. /** @hidden */
  53823. export var volumetricLightScatteringPixelShader: {
  53824. name: string;
  53825. shader: string;
  53826. };
  53827. }
  53828. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53829. /** @hidden */
  53830. export var volumetricLightScatteringPassPixelShader: {
  53831. name: string;
  53832. shader: string;
  53833. };
  53834. }
  53835. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53836. import { Vector3 } from "babylonjs/Maths/math";
  53837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53838. import { Mesh } from "babylonjs/Meshes/mesh";
  53839. import { Camera } from "babylonjs/Cameras/camera";
  53840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53842. import { Scene } from "babylonjs/scene";
  53843. import "babylonjs/Meshes/Builders/planeBuilder";
  53844. import "babylonjs/Shaders/depth.vertex";
  53845. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53846. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53847. import { Engine } from "babylonjs/Engines/engine";
  53848. /**
  53849. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53850. */
  53851. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53852. private _volumetricLightScatteringPass;
  53853. private _volumetricLightScatteringRTT;
  53854. private _viewPort;
  53855. private _screenCoordinates;
  53856. private _cachedDefines;
  53857. /**
  53858. * If not undefined, the mesh position is computed from the attached node position
  53859. */
  53860. attachedNode: {
  53861. position: Vector3;
  53862. };
  53863. /**
  53864. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53865. */
  53866. customMeshPosition: Vector3;
  53867. /**
  53868. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53869. */
  53870. useCustomMeshPosition: boolean;
  53871. /**
  53872. * If the post-process should inverse the light scattering direction
  53873. */
  53874. invert: boolean;
  53875. /**
  53876. * The internal mesh used by the post-process
  53877. */
  53878. mesh: Mesh;
  53879. /**
  53880. * @hidden
  53881. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53882. */
  53883. useDiffuseColor: boolean;
  53884. /**
  53885. * Array containing the excluded meshes not rendered in the internal pass
  53886. */
  53887. excludedMeshes: AbstractMesh[];
  53888. /**
  53889. * Controls the overall intensity of the post-process
  53890. */
  53891. exposure: number;
  53892. /**
  53893. * Dissipates each sample's contribution in range [0, 1]
  53894. */
  53895. decay: number;
  53896. /**
  53897. * Controls the overall intensity of each sample
  53898. */
  53899. weight: number;
  53900. /**
  53901. * Controls the density of each sample
  53902. */
  53903. density: number;
  53904. /**
  53905. * @constructor
  53906. * @param name The post-process name
  53907. * @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)
  53908. * @param camera The camera that the post-process will be attached to
  53909. * @param mesh The mesh used to create the light scattering
  53910. * @param samples The post-process quality, default 100
  53911. * @param samplingModeThe post-process filtering mode
  53912. * @param engine The babylon engine
  53913. * @param reusable If the post-process is reusable
  53914. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53915. */
  53916. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53917. /**
  53918. * Returns the string "VolumetricLightScatteringPostProcess"
  53919. * @returns "VolumetricLightScatteringPostProcess"
  53920. */
  53921. getClassName(): string;
  53922. private _isReady;
  53923. /**
  53924. * Sets the new light position for light scattering effect
  53925. * @param position The new custom light position
  53926. */
  53927. setCustomMeshPosition(position: Vector3): void;
  53928. /**
  53929. * Returns the light position for light scattering effect
  53930. * @return Vector3 The custom light position
  53931. */
  53932. getCustomMeshPosition(): Vector3;
  53933. /**
  53934. * Disposes the internal assets and detaches the post-process from the camera
  53935. */
  53936. dispose(camera: Camera): void;
  53937. /**
  53938. * Returns the render target texture used by the post-process
  53939. * @return the render target texture used by the post-process
  53940. */
  53941. getPass(): RenderTargetTexture;
  53942. private _meshExcluded;
  53943. private _createPass;
  53944. private _updateMeshScreenCoordinates;
  53945. /**
  53946. * Creates a default mesh for the Volumeric Light Scattering post-process
  53947. * @param name The mesh name
  53948. * @param scene The scene where to create the mesh
  53949. * @return the default mesh
  53950. */
  53951. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53952. }
  53953. }
  53954. declare module "babylonjs/PostProcesses/index" {
  53955. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53956. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53957. export * from "babylonjs/PostProcesses/bloomEffect";
  53958. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53959. export * from "babylonjs/PostProcesses/blurPostProcess";
  53960. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53961. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53962. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53963. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53964. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53965. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53966. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53967. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53968. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53969. export * from "babylonjs/PostProcesses/filterPostProcess";
  53970. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53971. export * from "babylonjs/PostProcesses/grainPostProcess";
  53972. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53973. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53974. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53975. export * from "babylonjs/PostProcesses/passPostProcess";
  53976. export * from "babylonjs/PostProcesses/postProcess";
  53977. export * from "babylonjs/PostProcesses/postProcessManager";
  53978. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53979. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53980. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53981. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53982. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53983. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53984. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53985. }
  53986. declare module "babylonjs/Probes/index" {
  53987. export * from "babylonjs/Probes/reflectionProbe";
  53988. }
  53989. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53990. import { Scene } from "babylonjs/scene";
  53991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53992. import { Color3 } from "babylonjs/Maths/math";
  53993. import { SmartArray } from "babylonjs/Misc/smartArray";
  53994. import { ISceneComponent } from "babylonjs/sceneComponent";
  53995. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53996. import "babylonjs/Meshes/Builders/boxBuilder";
  53997. import "babylonjs/Shaders/color.fragment";
  53998. import "babylonjs/Shaders/color.vertex";
  53999. module "babylonjs/scene" {
  54000. interface Scene {
  54001. /** @hidden (Backing field) */
  54002. _boundingBoxRenderer: BoundingBoxRenderer;
  54003. /** @hidden (Backing field) */
  54004. _forceShowBoundingBoxes: boolean;
  54005. /**
  54006. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54007. */
  54008. forceShowBoundingBoxes: boolean;
  54009. /**
  54010. * Gets the bounding box renderer associated with the scene
  54011. * @returns a BoundingBoxRenderer
  54012. */
  54013. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54014. }
  54015. }
  54016. module "babylonjs/Meshes/abstractMesh" {
  54017. interface AbstractMesh {
  54018. /** @hidden (Backing field) */
  54019. _showBoundingBox: boolean;
  54020. /**
  54021. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54022. */
  54023. showBoundingBox: boolean;
  54024. }
  54025. }
  54026. /**
  54027. * Component responsible of rendering the bounding box of the meshes in a scene.
  54028. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54029. */
  54030. export class BoundingBoxRenderer implements ISceneComponent {
  54031. /**
  54032. * The component name helpfull to identify the component in the list of scene components.
  54033. */
  54034. readonly name: string;
  54035. /**
  54036. * The scene the component belongs to.
  54037. */
  54038. scene: Scene;
  54039. /**
  54040. * Color of the bounding box lines placed in front of an object
  54041. */
  54042. frontColor: Color3;
  54043. /**
  54044. * Color of the bounding box lines placed behind an object
  54045. */
  54046. backColor: Color3;
  54047. /**
  54048. * Defines if the renderer should show the back lines or not
  54049. */
  54050. showBackLines: boolean;
  54051. /**
  54052. * @hidden
  54053. */
  54054. renderList: SmartArray<BoundingBox>;
  54055. private _colorShader;
  54056. private _vertexBuffers;
  54057. private _indexBuffer;
  54058. /**
  54059. * Instantiates a new bounding box renderer in a scene.
  54060. * @param scene the scene the renderer renders in
  54061. */
  54062. constructor(scene: Scene);
  54063. /**
  54064. * Registers the component in a given scene
  54065. */
  54066. register(): void;
  54067. private _evaluateSubMesh;
  54068. private _activeMesh;
  54069. private _prepareRessources;
  54070. private _createIndexBuffer;
  54071. /**
  54072. * Rebuilds the elements related to this component in case of
  54073. * context lost for instance.
  54074. */
  54075. rebuild(): void;
  54076. /**
  54077. * @hidden
  54078. */
  54079. reset(): void;
  54080. /**
  54081. * Render the bounding boxes of a specific rendering group
  54082. * @param renderingGroupId defines the rendering group to render
  54083. */
  54084. render(renderingGroupId: number): void;
  54085. /**
  54086. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54087. * @param mesh Define the mesh to render the occlusion bounding box for
  54088. */
  54089. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54090. /**
  54091. * Dispose and release the resources attached to this renderer.
  54092. */
  54093. dispose(): void;
  54094. }
  54095. }
  54096. declare module "babylonjs/Shaders/depth.fragment" {
  54097. /** @hidden */
  54098. export var depthPixelShader: {
  54099. name: string;
  54100. shader: string;
  54101. };
  54102. }
  54103. declare module "babylonjs/Rendering/depthRenderer" {
  54104. import { Nullable } from "babylonjs/types";
  54105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54106. import { Scene } from "babylonjs/scene";
  54107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54108. import { Camera } from "babylonjs/Cameras/camera";
  54109. import "babylonjs/Shaders/depth.fragment";
  54110. import "babylonjs/Shaders/depth.vertex";
  54111. /**
  54112. * This represents a depth renderer in Babylon.
  54113. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54114. */
  54115. export class DepthRenderer {
  54116. private _scene;
  54117. private _depthMap;
  54118. private _effect;
  54119. private _cachedDefines;
  54120. private _camera;
  54121. /**
  54122. * Specifiess that the depth renderer will only be used within
  54123. * the camera it is created for.
  54124. * This can help forcing its rendering during the camera processing.
  54125. */
  54126. useOnlyInActiveCamera: boolean;
  54127. /** @hidden */
  54128. static _SceneComponentInitialization: (scene: Scene) => void;
  54129. /**
  54130. * Instantiates a depth renderer
  54131. * @param scene The scene the renderer belongs to
  54132. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54133. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54134. */
  54135. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54136. /**
  54137. * Creates the depth rendering effect and checks if the effect is ready.
  54138. * @param subMesh The submesh to be used to render the depth map of
  54139. * @param useInstances If multiple world instances should be used
  54140. * @returns if the depth renderer is ready to render the depth map
  54141. */
  54142. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54143. /**
  54144. * Gets the texture which the depth map will be written to.
  54145. * @returns The depth map texture
  54146. */
  54147. getDepthMap(): RenderTargetTexture;
  54148. /**
  54149. * Disposes of the depth renderer.
  54150. */
  54151. dispose(): void;
  54152. }
  54153. }
  54154. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54155. import { Nullable } from "babylonjs/types";
  54156. import { Scene } from "babylonjs/scene";
  54157. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54158. import { Camera } from "babylonjs/Cameras/camera";
  54159. import { ISceneComponent } from "babylonjs/sceneComponent";
  54160. module "babylonjs/scene" {
  54161. interface Scene {
  54162. /** @hidden (Backing field) */
  54163. _depthRenderer: {
  54164. [id: string]: DepthRenderer;
  54165. };
  54166. /**
  54167. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54168. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54169. * @returns the created depth renderer
  54170. */
  54171. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54172. /**
  54173. * Disables a depth renderer for a given camera
  54174. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54175. */
  54176. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54177. }
  54178. }
  54179. /**
  54180. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54181. * in several rendering techniques.
  54182. */
  54183. export class DepthRendererSceneComponent implements ISceneComponent {
  54184. /**
  54185. * The component name helpfull to identify the component in the list of scene components.
  54186. */
  54187. readonly name: string;
  54188. /**
  54189. * The scene the component belongs to.
  54190. */
  54191. scene: Scene;
  54192. /**
  54193. * Creates a new instance of the component for the given scene
  54194. * @param scene Defines the scene to register the component in
  54195. */
  54196. constructor(scene: Scene);
  54197. /**
  54198. * Registers the component in a given scene
  54199. */
  54200. register(): void;
  54201. /**
  54202. * Rebuilds the elements related to this component in case of
  54203. * context lost for instance.
  54204. */
  54205. rebuild(): void;
  54206. /**
  54207. * Disposes the component and the associated ressources
  54208. */
  54209. dispose(): void;
  54210. private _gatherRenderTargets;
  54211. private _gatherActiveCameraRenderTargets;
  54212. }
  54213. }
  54214. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54215. import { Nullable } from "babylonjs/types";
  54216. import { Scene } from "babylonjs/scene";
  54217. import { ISceneComponent } from "babylonjs/sceneComponent";
  54218. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54219. module "babylonjs/scene" {
  54220. interface Scene {
  54221. /** @hidden (Backing field) */
  54222. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54223. /**
  54224. * Gets or Sets the current geometry buffer associated to the scene.
  54225. */
  54226. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54227. /**
  54228. * Enables a GeometryBufferRender and associates it with the scene
  54229. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54230. * @returns the GeometryBufferRenderer
  54231. */
  54232. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54233. /**
  54234. * Disables the GeometryBufferRender associated with the scene
  54235. */
  54236. disableGeometryBufferRenderer(): void;
  54237. }
  54238. }
  54239. /**
  54240. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54241. * in several rendering techniques.
  54242. */
  54243. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54244. /**
  54245. * The component name helpful to identify the component in the list of scene components.
  54246. */
  54247. readonly name: string;
  54248. /**
  54249. * The scene the component belongs to.
  54250. */
  54251. scene: Scene;
  54252. /**
  54253. * Creates a new instance of the component for the given scene
  54254. * @param scene Defines the scene to register the component in
  54255. */
  54256. constructor(scene: Scene);
  54257. /**
  54258. * Registers the component in a given scene
  54259. */
  54260. register(): void;
  54261. /**
  54262. * Rebuilds the elements related to this component in case of
  54263. * context lost for instance.
  54264. */
  54265. rebuild(): void;
  54266. /**
  54267. * Disposes the component and the associated ressources
  54268. */
  54269. dispose(): void;
  54270. private _gatherRenderTargets;
  54271. }
  54272. }
  54273. declare module "babylonjs/Shaders/outline.fragment" {
  54274. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54275. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54276. /** @hidden */
  54277. export var outlinePixelShader: {
  54278. name: string;
  54279. shader: string;
  54280. };
  54281. }
  54282. declare module "babylonjs/Shaders/outline.vertex" {
  54283. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54284. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54285. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54286. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54287. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54288. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54289. /** @hidden */
  54290. export var outlineVertexShader: {
  54291. name: string;
  54292. shader: string;
  54293. };
  54294. }
  54295. declare module "babylonjs/Rendering/outlineRenderer" {
  54296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54297. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54298. import { Scene } from "babylonjs/scene";
  54299. import { ISceneComponent } from "babylonjs/sceneComponent";
  54300. import "babylonjs/Shaders/outline.fragment";
  54301. import "babylonjs/Shaders/outline.vertex";
  54302. module "babylonjs/scene" {
  54303. interface Scene {
  54304. /** @hidden */
  54305. _outlineRenderer: OutlineRenderer;
  54306. /**
  54307. * Gets the outline renderer associated with the scene
  54308. * @returns a OutlineRenderer
  54309. */
  54310. getOutlineRenderer(): OutlineRenderer;
  54311. }
  54312. }
  54313. module "babylonjs/Meshes/abstractMesh" {
  54314. interface AbstractMesh {
  54315. /** @hidden (Backing field) */
  54316. _renderOutline: boolean;
  54317. /**
  54318. * Gets or sets a boolean indicating if the outline must be rendered as well
  54319. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54320. */
  54321. renderOutline: boolean;
  54322. /** @hidden (Backing field) */
  54323. _renderOverlay: boolean;
  54324. /**
  54325. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54326. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54327. */
  54328. renderOverlay: boolean;
  54329. }
  54330. }
  54331. /**
  54332. * This class is responsible to draw bothe outline/overlay of meshes.
  54333. * It should not be used directly but through the available method on mesh.
  54334. */
  54335. export class OutlineRenderer implements ISceneComponent {
  54336. /**
  54337. * The name of the component. Each component must have a unique name.
  54338. */
  54339. name: string;
  54340. /**
  54341. * The scene the component belongs to.
  54342. */
  54343. scene: Scene;
  54344. /**
  54345. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54346. */
  54347. zOffset: number;
  54348. private _engine;
  54349. private _effect;
  54350. private _cachedDefines;
  54351. private _savedDepthWrite;
  54352. /**
  54353. * Instantiates a new outline renderer. (There could be only one per scene).
  54354. * @param scene Defines the scene it belongs to
  54355. */
  54356. constructor(scene: Scene);
  54357. /**
  54358. * Register the component to one instance of a scene.
  54359. */
  54360. register(): void;
  54361. /**
  54362. * Rebuilds the elements related to this component in case of
  54363. * context lost for instance.
  54364. */
  54365. rebuild(): void;
  54366. /**
  54367. * Disposes the component and the associated ressources.
  54368. */
  54369. dispose(): void;
  54370. /**
  54371. * Renders the outline in the canvas.
  54372. * @param subMesh Defines the sumesh to render
  54373. * @param batch Defines the batch of meshes in case of instances
  54374. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54375. */
  54376. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54377. /**
  54378. * Returns whether or not the outline renderer is ready for a given submesh.
  54379. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54380. * @param subMesh Defines the submesh to check readyness for
  54381. * @param useInstances Defines wheter wee are trying to render instances or not
  54382. * @returns true if ready otherwise false
  54383. */
  54384. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54385. private _beforeRenderingMesh;
  54386. private _afterRenderingMesh;
  54387. }
  54388. }
  54389. declare module "babylonjs/Rendering/index" {
  54390. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54391. export * from "babylonjs/Rendering/depthRenderer";
  54392. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54393. export * from "babylonjs/Rendering/edgesRenderer";
  54394. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54395. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54396. export * from "babylonjs/Rendering/outlineRenderer";
  54397. export * from "babylonjs/Rendering/renderingGroup";
  54398. export * from "babylonjs/Rendering/renderingManager";
  54399. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54400. }
  54401. declare module "babylonjs/Sprites/index" {
  54402. export * from "babylonjs/Sprites/sprite";
  54403. export * from "babylonjs/Sprites/spriteManager";
  54404. export * from "babylonjs/Sprites/spriteSceneComponent";
  54405. }
  54406. declare module "babylonjs/Misc/assetsManager" {
  54407. import { Scene } from "babylonjs/scene";
  54408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54409. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54410. import { Skeleton } from "babylonjs/Bones/skeleton";
  54411. import { Observable } from "babylonjs/Misc/observable";
  54412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54413. import { Texture } from "babylonjs/Materials/Textures/texture";
  54414. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54415. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54416. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54417. /**
  54418. * Defines the list of states available for a task inside a AssetsManager
  54419. */
  54420. export enum AssetTaskState {
  54421. /**
  54422. * Initialization
  54423. */
  54424. INIT = 0,
  54425. /**
  54426. * Running
  54427. */
  54428. RUNNING = 1,
  54429. /**
  54430. * Done
  54431. */
  54432. DONE = 2,
  54433. /**
  54434. * Error
  54435. */
  54436. ERROR = 3
  54437. }
  54438. /**
  54439. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54440. */
  54441. export abstract class AbstractAssetTask {
  54442. /**
  54443. * Task name
  54444. */ name: string;
  54445. /**
  54446. * Callback called when the task is successful
  54447. */
  54448. onSuccess: (task: any) => void;
  54449. /**
  54450. * Callback called when the task is not successful
  54451. */
  54452. onError: (task: any, message?: string, exception?: any) => void;
  54453. /**
  54454. * Creates a new AssetsManager
  54455. * @param name defines the name of the task
  54456. */
  54457. constructor(
  54458. /**
  54459. * Task name
  54460. */ name: string);
  54461. private _isCompleted;
  54462. private _taskState;
  54463. private _errorObject;
  54464. /**
  54465. * Get if the task is completed
  54466. */
  54467. readonly isCompleted: boolean;
  54468. /**
  54469. * Gets the current state of the task
  54470. */
  54471. readonly taskState: AssetTaskState;
  54472. /**
  54473. * Gets the current error object (if task is in error)
  54474. */
  54475. readonly errorObject: {
  54476. message?: string;
  54477. exception?: any;
  54478. };
  54479. /**
  54480. * Internal only
  54481. * @hidden
  54482. */
  54483. _setErrorObject(message?: string, exception?: any): void;
  54484. /**
  54485. * Execute the current task
  54486. * @param scene defines the scene where you want your assets to be loaded
  54487. * @param onSuccess is a callback called when the task is successfully executed
  54488. * @param onError is a callback called if an error occurs
  54489. */
  54490. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54491. /**
  54492. * Execute the current task
  54493. * @param scene defines the scene where you want your assets to be loaded
  54494. * @param onSuccess is a callback called when the task is successfully executed
  54495. * @param onError is a callback called if an error occurs
  54496. */
  54497. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54498. /**
  54499. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54500. * This can be used with failed tasks that have the reason for failure fixed.
  54501. */
  54502. reset(): void;
  54503. private onErrorCallback;
  54504. private onDoneCallback;
  54505. }
  54506. /**
  54507. * Define the interface used by progress events raised during assets loading
  54508. */
  54509. export interface IAssetsProgressEvent {
  54510. /**
  54511. * Defines the number of remaining tasks to process
  54512. */
  54513. remainingCount: number;
  54514. /**
  54515. * Defines the total number of tasks
  54516. */
  54517. totalCount: number;
  54518. /**
  54519. * Defines the task that was just processed
  54520. */
  54521. task: AbstractAssetTask;
  54522. }
  54523. /**
  54524. * Class used to share progress information about assets loading
  54525. */
  54526. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54527. /**
  54528. * Defines the number of remaining tasks to process
  54529. */
  54530. remainingCount: number;
  54531. /**
  54532. * Defines the total number of tasks
  54533. */
  54534. totalCount: number;
  54535. /**
  54536. * Defines the task that was just processed
  54537. */
  54538. task: AbstractAssetTask;
  54539. /**
  54540. * Creates a AssetsProgressEvent
  54541. * @param remainingCount defines the number of remaining tasks to process
  54542. * @param totalCount defines the total number of tasks
  54543. * @param task defines the task that was just processed
  54544. */
  54545. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54546. }
  54547. /**
  54548. * Define a task used by AssetsManager to load meshes
  54549. */
  54550. export class MeshAssetTask extends AbstractAssetTask {
  54551. /**
  54552. * Defines the name of the task
  54553. */
  54554. name: string;
  54555. /**
  54556. * Defines the list of mesh's names you want to load
  54557. */
  54558. meshesNames: any;
  54559. /**
  54560. * Defines the root url to use as a base to load your meshes and associated resources
  54561. */
  54562. rootUrl: string;
  54563. /**
  54564. * Defines the filename of the scene to load from
  54565. */
  54566. sceneFilename: string;
  54567. /**
  54568. * Gets the list of loaded meshes
  54569. */
  54570. loadedMeshes: Array<AbstractMesh>;
  54571. /**
  54572. * Gets the list of loaded particle systems
  54573. */
  54574. loadedParticleSystems: Array<IParticleSystem>;
  54575. /**
  54576. * Gets the list of loaded skeletons
  54577. */
  54578. loadedSkeletons: Array<Skeleton>;
  54579. /**
  54580. * Gets the list of loaded animation groups
  54581. */
  54582. loadedAnimationGroups: Array<AnimationGroup>;
  54583. /**
  54584. * Callback called when the task is successful
  54585. */
  54586. onSuccess: (task: MeshAssetTask) => void;
  54587. /**
  54588. * Callback called when the task is successful
  54589. */
  54590. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54591. /**
  54592. * Creates a new MeshAssetTask
  54593. * @param name defines the name of the task
  54594. * @param meshesNames defines the list of mesh's names you want to load
  54595. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54596. * @param sceneFilename defines the filename of the scene to load from
  54597. */
  54598. constructor(
  54599. /**
  54600. * Defines the name of the task
  54601. */
  54602. name: string,
  54603. /**
  54604. * Defines the list of mesh's names you want to load
  54605. */
  54606. meshesNames: any,
  54607. /**
  54608. * Defines the root url to use as a base to load your meshes and associated resources
  54609. */
  54610. rootUrl: string,
  54611. /**
  54612. * Defines the filename of the scene to load from
  54613. */
  54614. sceneFilename: string);
  54615. /**
  54616. * Execute the current task
  54617. * @param scene defines the scene where you want your assets to be loaded
  54618. * @param onSuccess is a callback called when the task is successfully executed
  54619. * @param onError is a callback called if an error occurs
  54620. */
  54621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54622. }
  54623. /**
  54624. * Define a task used by AssetsManager to load text content
  54625. */
  54626. export class TextFileAssetTask extends AbstractAssetTask {
  54627. /**
  54628. * Defines the name of the task
  54629. */
  54630. name: string;
  54631. /**
  54632. * Defines the location of the file to load
  54633. */
  54634. url: string;
  54635. /**
  54636. * Gets the loaded text string
  54637. */
  54638. text: string;
  54639. /**
  54640. * Callback called when the task is successful
  54641. */
  54642. onSuccess: (task: TextFileAssetTask) => void;
  54643. /**
  54644. * Callback called when the task is successful
  54645. */
  54646. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54647. /**
  54648. * Creates a new TextFileAssetTask object
  54649. * @param name defines the name of the task
  54650. * @param url defines the location of the file to load
  54651. */
  54652. constructor(
  54653. /**
  54654. * Defines the name of the task
  54655. */
  54656. name: string,
  54657. /**
  54658. * Defines the location of the file to load
  54659. */
  54660. url: string);
  54661. /**
  54662. * Execute the current task
  54663. * @param scene defines the scene where you want your assets to be loaded
  54664. * @param onSuccess is a callback called when the task is successfully executed
  54665. * @param onError is a callback called if an error occurs
  54666. */
  54667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54668. }
  54669. /**
  54670. * Define a task used by AssetsManager to load binary data
  54671. */
  54672. export class BinaryFileAssetTask extends AbstractAssetTask {
  54673. /**
  54674. * Defines the name of the task
  54675. */
  54676. name: string;
  54677. /**
  54678. * Defines the location of the file to load
  54679. */
  54680. url: string;
  54681. /**
  54682. * Gets the lodaded data (as an array buffer)
  54683. */
  54684. data: ArrayBuffer;
  54685. /**
  54686. * Callback called when the task is successful
  54687. */
  54688. onSuccess: (task: BinaryFileAssetTask) => void;
  54689. /**
  54690. * Callback called when the task is successful
  54691. */
  54692. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54693. /**
  54694. * Creates a new BinaryFileAssetTask object
  54695. * @param name defines the name of the new task
  54696. * @param url defines the location of the file to load
  54697. */
  54698. constructor(
  54699. /**
  54700. * Defines the name of the task
  54701. */
  54702. name: string,
  54703. /**
  54704. * Defines the location of the file to load
  54705. */
  54706. url: string);
  54707. /**
  54708. * Execute the current task
  54709. * @param scene defines the scene where you want your assets to be loaded
  54710. * @param onSuccess is a callback called when the task is successfully executed
  54711. * @param onError is a callback called if an error occurs
  54712. */
  54713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54714. }
  54715. /**
  54716. * Define a task used by AssetsManager to load images
  54717. */
  54718. export class ImageAssetTask extends AbstractAssetTask {
  54719. /**
  54720. * Defines the name of the task
  54721. */
  54722. name: string;
  54723. /**
  54724. * Defines the location of the image to load
  54725. */
  54726. url: string;
  54727. /**
  54728. * Gets the loaded images
  54729. */
  54730. image: HTMLImageElement;
  54731. /**
  54732. * Callback called when the task is successful
  54733. */
  54734. onSuccess: (task: ImageAssetTask) => void;
  54735. /**
  54736. * Callback called when the task is successful
  54737. */
  54738. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54739. /**
  54740. * Creates a new ImageAssetTask
  54741. * @param name defines the name of the task
  54742. * @param url defines the location of the image to load
  54743. */
  54744. constructor(
  54745. /**
  54746. * Defines the name of the task
  54747. */
  54748. name: string,
  54749. /**
  54750. * Defines the location of the image to load
  54751. */
  54752. url: string);
  54753. /**
  54754. * Execute the current task
  54755. * @param scene defines the scene where you want your assets to be loaded
  54756. * @param onSuccess is a callback called when the task is successfully executed
  54757. * @param onError is a callback called if an error occurs
  54758. */
  54759. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54760. }
  54761. /**
  54762. * Defines the interface used by texture loading tasks
  54763. */
  54764. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54765. /**
  54766. * Gets the loaded texture
  54767. */
  54768. texture: TEX;
  54769. }
  54770. /**
  54771. * Define a task used by AssetsManager to load 2D textures
  54772. */
  54773. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54774. /**
  54775. * Defines the name of the task
  54776. */
  54777. name: string;
  54778. /**
  54779. * Defines the location of the file to load
  54780. */
  54781. url: string;
  54782. /**
  54783. * Defines if mipmap should not be generated (default is false)
  54784. */
  54785. noMipmap?: boolean | undefined;
  54786. /**
  54787. * Defines if texture must be inverted on Y axis (default is false)
  54788. */
  54789. invertY?: boolean | undefined;
  54790. /**
  54791. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54792. */
  54793. samplingMode: number;
  54794. /**
  54795. * Gets the loaded texture
  54796. */
  54797. texture: Texture;
  54798. /**
  54799. * Callback called when the task is successful
  54800. */
  54801. onSuccess: (task: TextureAssetTask) => void;
  54802. /**
  54803. * Callback called when the task is successful
  54804. */
  54805. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54806. /**
  54807. * Creates a new TextureAssetTask object
  54808. * @param name defines the name of the task
  54809. * @param url defines the location of the file to load
  54810. * @param noMipmap defines if mipmap should not be generated (default is false)
  54811. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54812. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54813. */
  54814. constructor(
  54815. /**
  54816. * Defines the name of the task
  54817. */
  54818. name: string,
  54819. /**
  54820. * Defines the location of the file to load
  54821. */
  54822. url: string,
  54823. /**
  54824. * Defines if mipmap should not be generated (default is false)
  54825. */
  54826. noMipmap?: boolean | undefined,
  54827. /**
  54828. * Defines if texture must be inverted on Y axis (default is false)
  54829. */
  54830. invertY?: boolean | undefined,
  54831. /**
  54832. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54833. */
  54834. samplingMode?: number);
  54835. /**
  54836. * Execute the current task
  54837. * @param scene defines the scene where you want your assets to be loaded
  54838. * @param onSuccess is a callback called when the task is successfully executed
  54839. * @param onError is a callback called if an error occurs
  54840. */
  54841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54842. }
  54843. /**
  54844. * Define a task used by AssetsManager to load cube textures
  54845. */
  54846. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54847. /**
  54848. * Defines the name of the task
  54849. */
  54850. name: string;
  54851. /**
  54852. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54853. */
  54854. url: string;
  54855. /**
  54856. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54857. */
  54858. extensions?: string[] | undefined;
  54859. /**
  54860. * Defines if mipmaps should not be generated (default is false)
  54861. */
  54862. noMipmap?: boolean | undefined;
  54863. /**
  54864. * Defines the explicit list of files (undefined by default)
  54865. */
  54866. files?: string[] | undefined;
  54867. /**
  54868. * Gets the loaded texture
  54869. */
  54870. texture: CubeTexture;
  54871. /**
  54872. * Callback called when the task is successful
  54873. */
  54874. onSuccess: (task: CubeTextureAssetTask) => void;
  54875. /**
  54876. * Callback called when the task is successful
  54877. */
  54878. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54879. /**
  54880. * Creates a new CubeTextureAssetTask
  54881. * @param name defines the name of the task
  54882. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54883. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54884. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54885. * @param files defines the explicit list of files (undefined by default)
  54886. */
  54887. constructor(
  54888. /**
  54889. * Defines the name of the task
  54890. */
  54891. name: string,
  54892. /**
  54893. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54894. */
  54895. url: string,
  54896. /**
  54897. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54898. */
  54899. extensions?: string[] | undefined,
  54900. /**
  54901. * Defines if mipmaps should not be generated (default is false)
  54902. */
  54903. noMipmap?: boolean | undefined,
  54904. /**
  54905. * Defines the explicit list of files (undefined by default)
  54906. */
  54907. files?: string[] | undefined);
  54908. /**
  54909. * Execute the current task
  54910. * @param scene defines the scene where you want your assets to be loaded
  54911. * @param onSuccess is a callback called when the task is successfully executed
  54912. * @param onError is a callback called if an error occurs
  54913. */
  54914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54915. }
  54916. /**
  54917. * Define a task used by AssetsManager to load HDR cube textures
  54918. */
  54919. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54920. /**
  54921. * Defines the name of the task
  54922. */
  54923. name: string;
  54924. /**
  54925. * Defines the location of the file to load
  54926. */
  54927. url: string;
  54928. /**
  54929. * Defines the desired size (the more it increases the longer the generation will be)
  54930. */
  54931. size: number;
  54932. /**
  54933. * Defines if mipmaps should not be generated (default is false)
  54934. */
  54935. noMipmap: boolean;
  54936. /**
  54937. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54938. */
  54939. generateHarmonics: boolean;
  54940. /**
  54941. * 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)
  54942. */
  54943. gammaSpace: boolean;
  54944. /**
  54945. * Internal Use Only
  54946. */
  54947. reserved: boolean;
  54948. /**
  54949. * Gets the loaded texture
  54950. */
  54951. texture: HDRCubeTexture;
  54952. /**
  54953. * Callback called when the task is successful
  54954. */
  54955. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54956. /**
  54957. * Callback called when the task is successful
  54958. */
  54959. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54960. /**
  54961. * Creates a new HDRCubeTextureAssetTask object
  54962. * @param name defines the name of the task
  54963. * @param url defines the location of the file to load
  54964. * @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.
  54965. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54966. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54967. * @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)
  54968. * @param reserved Internal use only
  54969. */
  54970. constructor(
  54971. /**
  54972. * Defines the name of the task
  54973. */
  54974. name: string,
  54975. /**
  54976. * Defines the location of the file to load
  54977. */
  54978. url: string,
  54979. /**
  54980. * Defines the desired size (the more it increases the longer the generation will be)
  54981. */
  54982. size: number,
  54983. /**
  54984. * Defines if mipmaps should not be generated (default is false)
  54985. */
  54986. noMipmap?: boolean,
  54987. /**
  54988. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54989. */
  54990. generateHarmonics?: boolean,
  54991. /**
  54992. * 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)
  54993. */
  54994. gammaSpace?: boolean,
  54995. /**
  54996. * Internal Use Only
  54997. */
  54998. reserved?: boolean);
  54999. /**
  55000. * Execute the current task
  55001. * @param scene defines the scene where you want your assets to be loaded
  55002. * @param onSuccess is a callback called when the task is successfully executed
  55003. * @param onError is a callback called if an error occurs
  55004. */
  55005. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55006. }
  55007. /**
  55008. * This class can be used to easily import assets into a scene
  55009. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55010. */
  55011. export class AssetsManager {
  55012. private _scene;
  55013. private _isLoading;
  55014. protected _tasks: AbstractAssetTask[];
  55015. protected _waitingTasksCount: number;
  55016. protected _totalTasksCount: number;
  55017. /**
  55018. * Callback called when all tasks are processed
  55019. */
  55020. onFinish: (tasks: AbstractAssetTask[]) => void;
  55021. /**
  55022. * Callback called when a task is successful
  55023. */
  55024. onTaskSuccess: (task: AbstractAssetTask) => void;
  55025. /**
  55026. * Callback called when a task had an error
  55027. */
  55028. onTaskError: (task: AbstractAssetTask) => void;
  55029. /**
  55030. * Callback called when a task is done (whatever the result is)
  55031. */
  55032. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55033. /**
  55034. * Observable called when all tasks are processed
  55035. */
  55036. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55037. /**
  55038. * Observable called when a task had an error
  55039. */
  55040. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55041. /**
  55042. * Observable called when a task is successful
  55043. */
  55044. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55045. /**
  55046. * Observable called when a task is done (whatever the result is)
  55047. */
  55048. onProgressObservable: Observable<IAssetsProgressEvent>;
  55049. /**
  55050. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55051. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55052. */
  55053. useDefaultLoadingScreen: boolean;
  55054. /**
  55055. * Creates a new AssetsManager
  55056. * @param scene defines the scene to work on
  55057. */
  55058. constructor(scene: Scene);
  55059. /**
  55060. * Add a MeshAssetTask to the list of active tasks
  55061. * @param taskName defines the name of the new task
  55062. * @param meshesNames defines the name of meshes to load
  55063. * @param rootUrl defines the root url to use to locate files
  55064. * @param sceneFilename defines the filename of the scene file
  55065. * @returns a new MeshAssetTask object
  55066. */
  55067. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55068. /**
  55069. * Add a TextFileAssetTask to the list of active tasks
  55070. * @param taskName defines the name of the new task
  55071. * @param url defines the url of the file to load
  55072. * @returns a new TextFileAssetTask object
  55073. */
  55074. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55075. /**
  55076. * Add a BinaryFileAssetTask to the list of active tasks
  55077. * @param taskName defines the name of the new task
  55078. * @param url defines the url of the file to load
  55079. * @returns a new BinaryFileAssetTask object
  55080. */
  55081. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55082. /**
  55083. * Add a ImageAssetTask to the list of active tasks
  55084. * @param taskName defines the name of the new task
  55085. * @param url defines the url of the file to load
  55086. * @returns a new ImageAssetTask object
  55087. */
  55088. addImageTask(taskName: string, url: string): ImageAssetTask;
  55089. /**
  55090. * Add a TextureAssetTask to the list of active tasks
  55091. * @param taskName defines the name of the new task
  55092. * @param url defines the url of the file to load
  55093. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55094. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55095. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55096. * @returns a new TextureAssetTask object
  55097. */
  55098. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55099. /**
  55100. * Add a CubeTextureAssetTask to the list of active tasks
  55101. * @param taskName defines the name of the new task
  55102. * @param url defines the url of the file to load
  55103. * @param extensions defines the extension to use to load the cube map (can be null)
  55104. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55105. * @param files defines the list of files to load (can be null)
  55106. * @returns a new CubeTextureAssetTask object
  55107. */
  55108. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55109. /**
  55110. *
  55111. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55112. * @param taskName defines the name of the new task
  55113. * @param url defines the url of the file to load
  55114. * @param size defines the size you want for the cubemap (can be null)
  55115. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55116. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55117. * @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)
  55118. * @param reserved Internal use only
  55119. * @returns a new HDRCubeTextureAssetTask object
  55120. */
  55121. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55122. /**
  55123. * Remove a task from the assets manager.
  55124. * @param task the task to remove
  55125. */
  55126. removeTask(task: AbstractAssetTask): void;
  55127. private _decreaseWaitingTasksCount;
  55128. private _runTask;
  55129. /**
  55130. * Reset the AssetsManager and remove all tasks
  55131. * @return the current instance of the AssetsManager
  55132. */
  55133. reset(): AssetsManager;
  55134. /**
  55135. * Start the loading process
  55136. * @return the current instance of the AssetsManager
  55137. */
  55138. load(): AssetsManager;
  55139. }
  55140. }
  55141. declare module "babylonjs/Misc/deferred" {
  55142. /**
  55143. * Wrapper class for promise with external resolve and reject.
  55144. */
  55145. export class Deferred<T> {
  55146. /**
  55147. * The promise associated with this deferred object.
  55148. */
  55149. readonly promise: Promise<T>;
  55150. private _resolve;
  55151. private _reject;
  55152. /**
  55153. * The resolve method of the promise associated with this deferred object.
  55154. */
  55155. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55156. /**
  55157. * The reject method of the promise associated with this deferred object.
  55158. */
  55159. readonly reject: (reason?: any) => void;
  55160. /**
  55161. * Constructor for this deferred object.
  55162. */
  55163. constructor();
  55164. }
  55165. }
  55166. declare module "babylonjs/Misc/filesInput" {
  55167. import { Engine } from "babylonjs/Engines/engine";
  55168. import { Scene } from "babylonjs/scene";
  55169. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55170. /**
  55171. * Class used to help managing file picking and drag'n'drop
  55172. */
  55173. export class FilesInput {
  55174. /**
  55175. * List of files ready to be loaded
  55176. */
  55177. static readonly FilesToLoad: {
  55178. [key: string]: File;
  55179. };
  55180. /**
  55181. * Callback called when a file is processed
  55182. */
  55183. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55184. private _engine;
  55185. private _currentScene;
  55186. private _sceneLoadedCallback;
  55187. private _progressCallback;
  55188. private _additionalRenderLoopLogicCallback;
  55189. private _textureLoadingCallback;
  55190. private _startingProcessingFilesCallback;
  55191. private _onReloadCallback;
  55192. private _errorCallback;
  55193. private _elementToMonitor;
  55194. private _sceneFileToLoad;
  55195. private _filesToLoad;
  55196. /**
  55197. * Creates a new FilesInput
  55198. * @param engine defines the rendering engine
  55199. * @param scene defines the hosting scene
  55200. * @param sceneLoadedCallback callback called when scene is loaded
  55201. * @param progressCallback callback called to track progress
  55202. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55203. * @param textureLoadingCallback callback called when a texture is loading
  55204. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55205. * @param onReloadCallback callback called when a reload is requested
  55206. * @param errorCallback callback call if an error occurs
  55207. */
  55208. 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);
  55209. private _dragEnterHandler;
  55210. private _dragOverHandler;
  55211. private _dropHandler;
  55212. /**
  55213. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55214. * @param elementToMonitor defines the DOM element to track
  55215. */
  55216. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55217. /**
  55218. * Release all associated resources
  55219. */
  55220. dispose(): void;
  55221. private renderFunction;
  55222. private drag;
  55223. private drop;
  55224. private _traverseFolder;
  55225. private _processFiles;
  55226. /**
  55227. * Load files from a drop event
  55228. * @param event defines the drop event to use as source
  55229. */
  55230. loadFiles(event: any): void;
  55231. private _processReload;
  55232. /**
  55233. * Reload the current scene from the loaded files
  55234. */
  55235. reload(): void;
  55236. }
  55237. }
  55238. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55239. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55240. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55241. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55242. }
  55243. declare module "babylonjs/Misc/sceneOptimizer" {
  55244. import { Scene, IDisposable } from "babylonjs/scene";
  55245. import { Observable } from "babylonjs/Misc/observable";
  55246. /**
  55247. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55249. */
  55250. export class SceneOptimization {
  55251. /**
  55252. * Defines the priority of this optimization (0 by default which means first in the list)
  55253. */
  55254. priority: number;
  55255. /**
  55256. * Gets a string describing the action executed by the current optimization
  55257. * @returns description string
  55258. */
  55259. getDescription(): string;
  55260. /**
  55261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55262. * @param scene defines the current scene where to apply this optimization
  55263. * @param optimizer defines the current optimizer
  55264. * @returns true if everything that can be done was applied
  55265. */
  55266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55267. /**
  55268. * Creates the SceneOptimization object
  55269. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55270. * @param desc defines the description associated with the optimization
  55271. */
  55272. constructor(
  55273. /**
  55274. * Defines the priority of this optimization (0 by default which means first in the list)
  55275. */
  55276. priority?: number);
  55277. }
  55278. /**
  55279. * Defines an optimization used to reduce the size of render target textures
  55280. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55281. */
  55282. export class TextureOptimization extends SceneOptimization {
  55283. /**
  55284. * Defines the priority of this optimization (0 by default which means first in the list)
  55285. */
  55286. priority: number;
  55287. /**
  55288. * 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
  55289. */
  55290. maximumSize: number;
  55291. /**
  55292. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55293. */
  55294. step: number;
  55295. /**
  55296. * Gets a string describing the action executed by the current optimization
  55297. * @returns description string
  55298. */
  55299. getDescription(): string;
  55300. /**
  55301. * Creates the TextureOptimization object
  55302. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55303. * @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
  55304. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55305. */
  55306. constructor(
  55307. /**
  55308. * Defines the priority of this optimization (0 by default which means first in the list)
  55309. */
  55310. priority?: number,
  55311. /**
  55312. * 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
  55313. */
  55314. maximumSize?: number,
  55315. /**
  55316. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55317. */
  55318. step?: number);
  55319. /**
  55320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55321. * @param scene defines the current scene where to apply this optimization
  55322. * @param optimizer defines the current optimizer
  55323. * @returns true if everything that can be done was applied
  55324. */
  55325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55326. }
  55327. /**
  55328. * Defines an optimization used to increase or decrease the rendering resolution
  55329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55330. */
  55331. export class HardwareScalingOptimization extends SceneOptimization {
  55332. /**
  55333. * Defines the priority of this optimization (0 by default which means first in the list)
  55334. */
  55335. priority: number;
  55336. /**
  55337. * Defines the maximum scale to use (2 by default)
  55338. */
  55339. maximumScale: number;
  55340. /**
  55341. * Defines the step to use between two passes (0.5 by default)
  55342. */
  55343. step: number;
  55344. private _currentScale;
  55345. private _directionOffset;
  55346. /**
  55347. * Gets a string describing the action executed by the current optimization
  55348. * @return description string
  55349. */
  55350. getDescription(): string;
  55351. /**
  55352. * Creates the HardwareScalingOptimization object
  55353. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55354. * @param maximumScale defines the maximum scale to use (2 by default)
  55355. * @param step defines the step to use between two passes (0.5 by default)
  55356. */
  55357. constructor(
  55358. /**
  55359. * Defines the priority of this optimization (0 by default which means first in the list)
  55360. */
  55361. priority?: number,
  55362. /**
  55363. * Defines the maximum scale to use (2 by default)
  55364. */
  55365. maximumScale?: number,
  55366. /**
  55367. * Defines the step to use between two passes (0.5 by default)
  55368. */
  55369. step?: number);
  55370. /**
  55371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55372. * @param scene defines the current scene where to apply this optimization
  55373. * @param optimizer defines the current optimizer
  55374. * @returns true if everything that can be done was applied
  55375. */
  55376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55377. }
  55378. /**
  55379. * Defines an optimization used to remove shadows
  55380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55381. */
  55382. export class ShadowsOptimization extends SceneOptimization {
  55383. /**
  55384. * Gets a string describing the action executed by the current optimization
  55385. * @return description string
  55386. */
  55387. getDescription(): string;
  55388. /**
  55389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55390. * @param scene defines the current scene where to apply this optimization
  55391. * @param optimizer defines the current optimizer
  55392. * @returns true if everything that can be done was applied
  55393. */
  55394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55395. }
  55396. /**
  55397. * Defines an optimization used to turn post-processes off
  55398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55399. */
  55400. export class PostProcessesOptimization extends SceneOptimization {
  55401. /**
  55402. * Gets a string describing the action executed by the current optimization
  55403. * @return description string
  55404. */
  55405. getDescription(): string;
  55406. /**
  55407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55408. * @param scene defines the current scene where to apply this optimization
  55409. * @param optimizer defines the current optimizer
  55410. * @returns true if everything that can be done was applied
  55411. */
  55412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55413. }
  55414. /**
  55415. * Defines an optimization used to turn lens flares off
  55416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55417. */
  55418. export class LensFlaresOptimization extends SceneOptimization {
  55419. /**
  55420. * Gets a string describing the action executed by the current optimization
  55421. * @return description string
  55422. */
  55423. getDescription(): string;
  55424. /**
  55425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55426. * @param scene defines the current scene where to apply this optimization
  55427. * @param optimizer defines the current optimizer
  55428. * @returns true if everything that can be done was applied
  55429. */
  55430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55431. }
  55432. /**
  55433. * Defines an optimization based on user defined callback.
  55434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55435. */
  55436. export class CustomOptimization extends SceneOptimization {
  55437. /**
  55438. * Callback called to apply the custom optimization.
  55439. */
  55440. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55441. /**
  55442. * Callback called to get custom description
  55443. */
  55444. onGetDescription: () => string;
  55445. /**
  55446. * Gets a string describing the action executed by the current optimization
  55447. * @returns description string
  55448. */
  55449. getDescription(): string;
  55450. /**
  55451. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55452. * @param scene defines the current scene where to apply this optimization
  55453. * @param optimizer defines the current optimizer
  55454. * @returns true if everything that can be done was applied
  55455. */
  55456. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55457. }
  55458. /**
  55459. * Defines an optimization used to turn particles off
  55460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55461. */
  55462. export class ParticlesOptimization extends SceneOptimization {
  55463. /**
  55464. * Gets a string describing the action executed by the current optimization
  55465. * @return description string
  55466. */
  55467. getDescription(): string;
  55468. /**
  55469. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55470. * @param scene defines the current scene where to apply this optimization
  55471. * @param optimizer defines the current optimizer
  55472. * @returns true if everything that can be done was applied
  55473. */
  55474. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55475. }
  55476. /**
  55477. * Defines an optimization used to turn render targets off
  55478. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55479. */
  55480. export class RenderTargetsOptimization extends SceneOptimization {
  55481. /**
  55482. * Gets a string describing the action executed by the current optimization
  55483. * @return description string
  55484. */
  55485. getDescription(): string;
  55486. /**
  55487. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55488. * @param scene defines the current scene where to apply this optimization
  55489. * @param optimizer defines the current optimizer
  55490. * @returns true if everything that can be done was applied
  55491. */
  55492. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55493. }
  55494. /**
  55495. * Defines an optimization used to merge meshes with compatible materials
  55496. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55497. */
  55498. export class MergeMeshesOptimization extends SceneOptimization {
  55499. private static _UpdateSelectionTree;
  55500. /**
  55501. * Gets or sets a boolean which defines if optimization octree has to be updated
  55502. */
  55503. /**
  55504. * Gets or sets a boolean which defines if optimization octree has to be updated
  55505. */
  55506. static UpdateSelectionTree: boolean;
  55507. /**
  55508. * Gets a string describing the action executed by the current optimization
  55509. * @return description string
  55510. */
  55511. getDescription(): string;
  55512. private _canBeMerged;
  55513. /**
  55514. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55515. * @param scene defines the current scene where to apply this optimization
  55516. * @param optimizer defines the current optimizer
  55517. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55518. * @returns true if everything that can be done was applied
  55519. */
  55520. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55521. }
  55522. /**
  55523. * Defines a list of options used by SceneOptimizer
  55524. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55525. */
  55526. export class SceneOptimizerOptions {
  55527. /**
  55528. * Defines the target frame rate to reach (60 by default)
  55529. */
  55530. targetFrameRate: number;
  55531. /**
  55532. * Defines the interval between two checkes (2000ms by default)
  55533. */
  55534. trackerDuration: number;
  55535. /**
  55536. * Gets the list of optimizations to apply
  55537. */
  55538. optimizations: SceneOptimization[];
  55539. /**
  55540. * Creates a new list of options used by SceneOptimizer
  55541. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55542. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55543. */
  55544. constructor(
  55545. /**
  55546. * Defines the target frame rate to reach (60 by default)
  55547. */
  55548. targetFrameRate?: number,
  55549. /**
  55550. * Defines the interval between two checkes (2000ms by default)
  55551. */
  55552. trackerDuration?: number);
  55553. /**
  55554. * Add a new optimization
  55555. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55556. * @returns the current SceneOptimizerOptions
  55557. */
  55558. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55559. /**
  55560. * Add a new custom optimization
  55561. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55562. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55563. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55564. * @returns the current SceneOptimizerOptions
  55565. */
  55566. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55567. /**
  55568. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55569. * @param targetFrameRate defines the target frame rate (60 by default)
  55570. * @returns a SceneOptimizerOptions object
  55571. */
  55572. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55573. /**
  55574. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55575. * @param targetFrameRate defines the target frame rate (60 by default)
  55576. * @returns a SceneOptimizerOptions object
  55577. */
  55578. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55579. /**
  55580. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55581. * @param targetFrameRate defines the target frame rate (60 by default)
  55582. * @returns a SceneOptimizerOptions object
  55583. */
  55584. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55585. }
  55586. /**
  55587. * Class used to run optimizations in order to reach a target frame rate
  55588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55589. */
  55590. export class SceneOptimizer implements IDisposable {
  55591. private _isRunning;
  55592. private _options;
  55593. private _scene;
  55594. private _currentPriorityLevel;
  55595. private _targetFrameRate;
  55596. private _trackerDuration;
  55597. private _currentFrameRate;
  55598. private _sceneDisposeObserver;
  55599. private _improvementMode;
  55600. /**
  55601. * Defines an observable called when the optimizer reaches the target frame rate
  55602. */
  55603. onSuccessObservable: Observable<SceneOptimizer>;
  55604. /**
  55605. * Defines an observable called when the optimizer enables an optimization
  55606. */
  55607. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55608. /**
  55609. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55610. */
  55611. onFailureObservable: Observable<SceneOptimizer>;
  55612. /**
  55613. * Gets a boolean indicating if the optimizer is in improvement mode
  55614. */
  55615. readonly isInImprovementMode: boolean;
  55616. /**
  55617. * Gets the current priority level (0 at start)
  55618. */
  55619. readonly currentPriorityLevel: number;
  55620. /**
  55621. * Gets the current frame rate checked by the SceneOptimizer
  55622. */
  55623. readonly currentFrameRate: number;
  55624. /**
  55625. * Gets or sets the current target frame rate (60 by default)
  55626. */
  55627. /**
  55628. * Gets or sets the current target frame rate (60 by default)
  55629. */
  55630. targetFrameRate: number;
  55631. /**
  55632. * Gets or sets the current interval between two checks (every 2000ms by default)
  55633. */
  55634. /**
  55635. * Gets or sets the current interval between two checks (every 2000ms by default)
  55636. */
  55637. trackerDuration: number;
  55638. /**
  55639. * Gets the list of active optimizations
  55640. */
  55641. readonly optimizations: SceneOptimization[];
  55642. /**
  55643. * Creates a new SceneOptimizer
  55644. * @param scene defines the scene to work on
  55645. * @param options defines the options to use with the SceneOptimizer
  55646. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55647. * @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)
  55648. */
  55649. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55650. /**
  55651. * Stops the current optimizer
  55652. */
  55653. stop(): void;
  55654. /**
  55655. * Reset the optimizer to initial step (current priority level = 0)
  55656. */
  55657. reset(): void;
  55658. /**
  55659. * Start the optimizer. By default it will try to reach a specific framerate
  55660. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55661. */
  55662. start(): void;
  55663. private _checkCurrentState;
  55664. /**
  55665. * Release all resources
  55666. */
  55667. dispose(): void;
  55668. /**
  55669. * Helper function to create a SceneOptimizer with one single line of code
  55670. * @param scene defines the scene to work on
  55671. * @param options defines the options to use with the SceneOptimizer
  55672. * @param onSuccess defines a callback to call on success
  55673. * @param onFailure defines a callback to call on failure
  55674. * @returns the new SceneOptimizer object
  55675. */
  55676. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55677. }
  55678. }
  55679. declare module "babylonjs/Misc/sceneSerializer" {
  55680. import { Scene } from "babylonjs/scene";
  55681. /**
  55682. * Class used to serialize a scene into a string
  55683. */
  55684. export class SceneSerializer {
  55685. /**
  55686. * Clear cache used by a previous serialization
  55687. */
  55688. static ClearCache(): void;
  55689. /**
  55690. * Serialize a scene into a JSON compatible object
  55691. * @param scene defines the scene to serialize
  55692. * @returns a JSON compatible object
  55693. */
  55694. static Serialize(scene: Scene): any;
  55695. /**
  55696. * Serialize a mesh into a JSON compatible object
  55697. * @param toSerialize defines the mesh to serialize
  55698. * @param withParents defines if parents must be serialized as well
  55699. * @param withChildren defines if children must be serialized as well
  55700. * @returns a JSON compatible object
  55701. */
  55702. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55703. }
  55704. }
  55705. declare module "babylonjs/Misc/videoRecorder" {
  55706. import { Nullable } from "babylonjs/types";
  55707. import { Engine } from "babylonjs/Engines/engine";
  55708. /**
  55709. * This represents the different options avilable for the video capture.
  55710. */
  55711. export interface VideoRecorderOptions {
  55712. /** Defines the mime type of the video */
  55713. mimeType: string;
  55714. /** Defines the video the video should be recorded at */
  55715. fps: number;
  55716. /** Defines the chunk size for the recording data */
  55717. recordChunckSize: number;
  55718. }
  55719. /**
  55720. * This can helps recording videos from BabylonJS.
  55721. * This is based on the available WebRTC functionalities of the browser.
  55722. *
  55723. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55724. */
  55725. export class VideoRecorder {
  55726. private static readonly _defaultOptions;
  55727. /**
  55728. * Returns wehther or not the VideoRecorder is available in your browser.
  55729. * @param engine Defines the Babylon Engine to check the support for
  55730. * @returns true if supported otherwise false
  55731. */
  55732. static IsSupported(engine: Engine): boolean;
  55733. private readonly _options;
  55734. private _canvas;
  55735. private _mediaRecorder;
  55736. private _recordedChunks;
  55737. private _fileName;
  55738. private _resolve;
  55739. private _reject;
  55740. /**
  55741. * True wether a recording is already in progress.
  55742. */
  55743. readonly isRecording: boolean;
  55744. /**
  55745. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55746. * a video file.
  55747. * @param engine Defines the BabylonJS Engine you wish to record
  55748. * @param options Defines options that can be used to customized the capture
  55749. */
  55750. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55751. /**
  55752. * Stops the current recording before the default capture timeout passed in the startRecording
  55753. * functions.
  55754. */
  55755. stopRecording(): void;
  55756. /**
  55757. * Starts recording the canvas for a max duration specified in parameters.
  55758. * @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.
  55759. * @param maxDuration Defines the maximum recording time in seconds.
  55760. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55761. * @return a promise callback at the end of the recording with the video data in Blob.
  55762. */
  55763. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55764. /**
  55765. * Releases internal resources used during the recording.
  55766. */
  55767. dispose(): void;
  55768. private _handleDataAvailable;
  55769. private _handleError;
  55770. private _handleStop;
  55771. }
  55772. }
  55773. declare module "babylonjs/Misc/workerPool" {
  55774. import { IDisposable } from "babylonjs/scene";
  55775. /**
  55776. * Helper class to push actions to a pool of workers.
  55777. */
  55778. export class WorkerPool implements IDisposable {
  55779. private _workerInfos;
  55780. private _pendingActions;
  55781. /**
  55782. * Constructor
  55783. * @param workers Array of workers to use for actions
  55784. */
  55785. constructor(workers: Array<Worker>);
  55786. /**
  55787. * Terminates all workers and clears any pending actions.
  55788. */
  55789. dispose(): void;
  55790. /**
  55791. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55792. * pended until a worker has completed its action.
  55793. * @param action The action to perform. Call onComplete when the action is complete.
  55794. */
  55795. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55796. private _execute;
  55797. }
  55798. }
  55799. declare module "babylonjs/Misc/screenshotTools" {
  55800. import { Camera } from "babylonjs/Cameras/camera";
  55801. import { Engine } from "babylonjs/Engines/engine";
  55802. /**
  55803. * Class containing a set of static utilities functions for screenshots
  55804. */
  55805. export class ScreenshotTools {
  55806. /**
  55807. * Captures a screenshot of the current rendering
  55808. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55809. * @param engine defines the rendering engine
  55810. * @param camera defines the source camera
  55811. * @param size This parameter can be set to a single number or to an object with the
  55812. * following (optional) properties: precision, width, height. If a single number is passed,
  55813. * it will be used for both width and height. If an object is passed, the screenshot size
  55814. * will be derived from the parameters. The precision property is a multiplier allowing
  55815. * rendering at a higher or lower resolution
  55816. * @param successCallback defines the callback receives a single parameter which contains the
  55817. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55818. * src parameter of an <img> to display it
  55819. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55820. * Check your browser for supported MIME types
  55821. */
  55822. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55823. /**
  55824. * Generates an image screenshot from the specified camera.
  55825. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55826. * @param engine The engine to use for rendering
  55827. * @param camera The camera to use for rendering
  55828. * @param size This parameter can be set to a single number or to an object with the
  55829. * following (optional) properties: precision, width, height. If a single number is passed,
  55830. * it will be used for both width and height. If an object is passed, the screenshot size
  55831. * will be derived from the parameters. The precision property is a multiplier allowing
  55832. * rendering at a higher or lower resolution
  55833. * @param successCallback The callback receives a single parameter which contains the
  55834. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55835. * src parameter of an <img> to display it
  55836. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55837. * Check your browser for supported MIME types
  55838. * @param samples Texture samples (default: 1)
  55839. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55840. * @param fileName A name for for the downloaded file.
  55841. */
  55842. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55843. }
  55844. }
  55845. declare module "babylonjs/Misc/index" {
  55846. export * from "babylonjs/Misc/andOrNotEvaluator";
  55847. export * from "babylonjs/Misc/assetsManager";
  55848. export * from "babylonjs/Misc/dds";
  55849. export * from "babylonjs/Misc/decorators";
  55850. export * from "babylonjs/Misc/deferred";
  55851. export * from "babylonjs/Misc/environmentTextureTools";
  55852. export * from "babylonjs/Misc/filesInput";
  55853. export * from "babylonjs/Misc/HighDynamicRange/index";
  55854. export * from "babylonjs/Misc/khronosTextureContainer";
  55855. export * from "babylonjs/Misc/observable";
  55856. export * from "babylonjs/Misc/performanceMonitor";
  55857. export * from "babylonjs/Misc/promise";
  55858. export * from "babylonjs/Misc/sceneOptimizer";
  55859. export * from "babylonjs/Misc/sceneSerializer";
  55860. export * from "babylonjs/Misc/smartArray";
  55861. export * from "babylonjs/Misc/stringDictionary";
  55862. export * from "babylonjs/Misc/tags";
  55863. export * from "babylonjs/Misc/textureTools";
  55864. export * from "babylonjs/Misc/tga";
  55865. export * from "babylonjs/Misc/tools";
  55866. export * from "babylonjs/Misc/videoRecorder";
  55867. export * from "babylonjs/Misc/virtualJoystick";
  55868. export * from "babylonjs/Misc/workerPool";
  55869. export * from "babylonjs/Misc/logger";
  55870. export * from "babylonjs/Misc/typeStore";
  55871. export * from "babylonjs/Misc/filesInputStore";
  55872. export * from "babylonjs/Misc/deepCopier";
  55873. export * from "babylonjs/Misc/pivotTools";
  55874. export * from "babylonjs/Misc/precisionDate";
  55875. export * from "babylonjs/Misc/screenshotTools";
  55876. export * from "babylonjs/Misc/typeStore";
  55877. }
  55878. declare module "babylonjs/index" {
  55879. export * from "babylonjs/abstractScene";
  55880. export * from "babylonjs/Actions/index";
  55881. export * from "babylonjs/Animations/index";
  55882. export * from "babylonjs/assetContainer";
  55883. export * from "babylonjs/Audio/index";
  55884. export * from "babylonjs/Behaviors/index";
  55885. export * from "babylonjs/Bones/index";
  55886. export * from "babylonjs/Cameras/index";
  55887. export * from "babylonjs/Collisions/index";
  55888. export * from "babylonjs/Culling/index";
  55889. export * from "babylonjs/Debug/index";
  55890. export * from "babylonjs/Engines/index";
  55891. export * from "babylonjs/Events/index";
  55892. export * from "babylonjs/Gamepads/index";
  55893. export * from "babylonjs/Gizmos/index";
  55894. export * from "babylonjs/Helpers/index";
  55895. export * from "babylonjs/Instrumentation/index";
  55896. export * from "babylonjs/Layers/index";
  55897. export * from "babylonjs/LensFlares/index";
  55898. export * from "babylonjs/Lights/index";
  55899. export * from "babylonjs/Loading/index";
  55900. export * from "babylonjs/Materials/index";
  55901. export * from "babylonjs/Maths/index";
  55902. export * from "babylonjs/Meshes/index";
  55903. export * from "babylonjs/Morph/index";
  55904. export * from "babylonjs/node";
  55905. export * from "babylonjs/Offline/index";
  55906. export * from "babylonjs/Particles/index";
  55907. export * from "babylonjs/Physics/index";
  55908. export * from "babylonjs/PostProcesses/index";
  55909. export * from "babylonjs/Probes/index";
  55910. export * from "babylonjs/Rendering/index";
  55911. export * from "babylonjs/scene";
  55912. export * from "babylonjs/sceneComponent";
  55913. export * from "babylonjs/Sprites/index";
  55914. export * from "babylonjs/States/index";
  55915. export * from "babylonjs/Misc/index";
  55916. export * from "babylonjs/types";
  55917. }
  55918. declare module "babylonjs/Animations/pathCursor" {
  55919. import { Path2, Vector3 } from "babylonjs/Maths/math";
  55920. /**
  55921. * A cursor which tracks a point on a path
  55922. */
  55923. export class PathCursor {
  55924. private path;
  55925. /**
  55926. * Stores path cursor callbacks for when an onchange event is triggered
  55927. */
  55928. private _onchange;
  55929. /**
  55930. * The value of the path cursor
  55931. */
  55932. value: number;
  55933. /**
  55934. * The animation array of the path cursor
  55935. */
  55936. animations: Animation[];
  55937. /**
  55938. * Initializes the path cursor
  55939. * @param path The path to track
  55940. */
  55941. constructor(path: Path2);
  55942. /**
  55943. * Gets the cursor point on the path
  55944. * @returns A point on the path cursor at the cursor location
  55945. */
  55946. getPoint(): Vector3;
  55947. /**
  55948. * Moves the cursor ahead by the step amount
  55949. * @param step The amount to move the cursor forward
  55950. * @returns This path cursor
  55951. */
  55952. moveAhead(step?: number): PathCursor;
  55953. /**
  55954. * Moves the cursor behind by the step amount
  55955. * @param step The amount to move the cursor back
  55956. * @returns This path cursor
  55957. */
  55958. moveBack(step?: number): PathCursor;
  55959. /**
  55960. * Moves the cursor by the step amount
  55961. * If the step amount is greater than one, an exception is thrown
  55962. * @param step The amount to move the cursor
  55963. * @returns This path cursor
  55964. */
  55965. move(step: number): PathCursor;
  55966. /**
  55967. * Ensures that the value is limited between zero and one
  55968. * @returns This path cursor
  55969. */
  55970. private ensureLimits;
  55971. /**
  55972. * Runs onchange callbacks on change (used by the animation engine)
  55973. * @returns This path cursor
  55974. */
  55975. private raiseOnChange;
  55976. /**
  55977. * Executes a function on change
  55978. * @param f A path cursor onchange callback
  55979. * @returns This path cursor
  55980. */
  55981. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55982. }
  55983. }
  55984. declare module "babylonjs/Legacy/legacy" {
  55985. export * from "babylonjs/index";
  55986. }
  55987. declare module "babylonjs/Shaders/blur.fragment" {
  55988. /** @hidden */
  55989. export var blurPixelShader: {
  55990. name: string;
  55991. shader: string;
  55992. };
  55993. }
  55994. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55995. /** @hidden */
  55996. export var bones300Declaration: {
  55997. name: string;
  55998. shader: string;
  55999. };
  56000. }
  56001. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56002. /** @hidden */
  56003. export var instances300Declaration: {
  56004. name: string;
  56005. shader: string;
  56006. };
  56007. }
  56008. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56009. /** @hidden */
  56010. export var pointCloudVertexDeclaration: {
  56011. name: string;
  56012. shader: string;
  56013. };
  56014. }
  56015. // Mixins
  56016. interface Window {
  56017. mozIndexedDB: IDBFactory;
  56018. webkitIndexedDB: IDBFactory;
  56019. msIndexedDB: IDBFactory;
  56020. webkitURL: typeof URL;
  56021. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56022. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56023. WebGLRenderingContext: WebGLRenderingContext;
  56024. MSGesture: MSGesture;
  56025. CANNON: any;
  56026. AudioContext: AudioContext;
  56027. webkitAudioContext: AudioContext;
  56028. PointerEvent: any;
  56029. Math: Math;
  56030. Uint8Array: Uint8ArrayConstructor;
  56031. Float32Array: Float32ArrayConstructor;
  56032. mozURL: typeof URL;
  56033. msURL: typeof URL;
  56034. VRFrameData: any; // WebVR, from specs 1.1
  56035. DracoDecoderModule: any;
  56036. setImmediate(handler: (...args: any[]) => void): number;
  56037. }
  56038. interface Document {
  56039. mozCancelFullScreen(): void;
  56040. msCancelFullScreen(): void;
  56041. webkitCancelFullScreen(): void;
  56042. requestPointerLock(): void;
  56043. exitPointerLock(): void;
  56044. mozFullScreen: boolean;
  56045. msIsFullScreen: boolean;
  56046. readonly webkitIsFullScreen: boolean;
  56047. readonly pointerLockElement: Element;
  56048. mozPointerLockElement: HTMLElement;
  56049. msPointerLockElement: HTMLElement;
  56050. webkitPointerLockElement: HTMLElement;
  56051. }
  56052. interface HTMLCanvasElement {
  56053. requestPointerLock(): void;
  56054. msRequestPointerLock?(): void;
  56055. mozRequestPointerLock?(): void;
  56056. webkitRequestPointerLock?(): void;
  56057. /** Track wether a record is in progress */
  56058. isRecording: boolean;
  56059. /** Capture Stream method defined by some browsers */
  56060. captureStream(fps?: number): MediaStream;
  56061. }
  56062. interface CanvasRenderingContext2D {
  56063. msImageSmoothingEnabled: boolean;
  56064. }
  56065. interface MouseEvent {
  56066. mozMovementX: number;
  56067. mozMovementY: number;
  56068. webkitMovementX: number;
  56069. webkitMovementY: number;
  56070. msMovementX: number;
  56071. msMovementY: number;
  56072. }
  56073. interface Navigator {
  56074. mozGetVRDevices: (any: any) => any;
  56075. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56076. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56077. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56078. webkitGetGamepads(): Gamepad[];
  56079. msGetGamepads(): Gamepad[];
  56080. webkitGamepads(): Gamepad[];
  56081. }
  56082. interface HTMLVideoElement {
  56083. mozSrcObject: any;
  56084. }
  56085. interface Math {
  56086. fround(x: number): number;
  56087. imul(a: number, b: number): number;
  56088. }
  56089. interface WebGLProgram {
  56090. context?: WebGLRenderingContext;
  56091. vertexShader?: WebGLShader;
  56092. fragmentShader?: WebGLShader;
  56093. isParallelCompiled: boolean;
  56094. onCompiled?: () => void;
  56095. }
  56096. interface WebGLRenderingContext {
  56097. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56098. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56099. vertexAttribDivisor(index: number, divisor: number): void;
  56100. createVertexArray(): any;
  56101. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56102. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56103. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56104. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56105. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56106. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56107. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56108. // Queries
  56109. createQuery(): WebGLQuery;
  56110. deleteQuery(query: WebGLQuery): void;
  56111. beginQuery(target: number, query: WebGLQuery): void;
  56112. endQuery(target: number): void;
  56113. getQueryParameter(query: WebGLQuery, pname: number): any;
  56114. getQuery(target: number, pname: number): any;
  56115. MAX_SAMPLES: number;
  56116. RGBA8: number;
  56117. READ_FRAMEBUFFER: number;
  56118. DRAW_FRAMEBUFFER: number;
  56119. UNIFORM_BUFFER: number;
  56120. HALF_FLOAT_OES: number;
  56121. RGBA16F: number;
  56122. RGBA32F: number;
  56123. R32F: number;
  56124. RG32F: number;
  56125. RGB32F: number;
  56126. R16F: number;
  56127. RG16F: number;
  56128. RGB16F: number;
  56129. RED: number;
  56130. RG: number;
  56131. R8: number;
  56132. RG8: number;
  56133. UNSIGNED_INT_24_8: number;
  56134. DEPTH24_STENCIL8: number;
  56135. /* Multiple Render Targets */
  56136. drawBuffers(buffers: number[]): void;
  56137. readBuffer(src: number): void;
  56138. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56139. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56140. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56141. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56142. // Occlusion Query
  56143. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56144. ANY_SAMPLES_PASSED: number;
  56145. QUERY_RESULT_AVAILABLE: number;
  56146. QUERY_RESULT: number;
  56147. }
  56148. interface WebGLBuffer {
  56149. references: number;
  56150. capacity: number;
  56151. is32Bits: boolean;
  56152. }
  56153. interface WebGLProgram {
  56154. transformFeedback?: WebGLTransformFeedback | null;
  56155. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56156. }
  56157. interface EXT_disjoint_timer_query {
  56158. QUERY_COUNTER_BITS_EXT: number;
  56159. TIME_ELAPSED_EXT: number;
  56160. TIMESTAMP_EXT: number;
  56161. GPU_DISJOINT_EXT: number;
  56162. QUERY_RESULT_EXT: number;
  56163. QUERY_RESULT_AVAILABLE_EXT: number;
  56164. queryCounterEXT(query: WebGLQuery, target: number): void;
  56165. createQueryEXT(): WebGLQuery;
  56166. beginQueryEXT(target: number, query: WebGLQuery): void;
  56167. endQueryEXT(target: number): void;
  56168. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56169. deleteQueryEXT(query: WebGLQuery): void;
  56170. }
  56171. interface WebGLUniformLocation {
  56172. _currentState: any;
  56173. }
  56174. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56175. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56176. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56177. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56178. interface WebGLRenderingContext {
  56179. readonly RASTERIZER_DISCARD: number;
  56180. readonly DEPTH_COMPONENT24: number;
  56181. readonly TEXTURE_3D: number;
  56182. readonly TEXTURE_2D_ARRAY: number;
  56183. readonly TEXTURE_COMPARE_FUNC: number;
  56184. readonly TEXTURE_COMPARE_MODE: number;
  56185. readonly COMPARE_REF_TO_TEXTURE: number;
  56186. readonly TEXTURE_WRAP_R: number;
  56187. readonly HALF_FLOAT: number;
  56188. readonly RGB8: number;
  56189. readonly RED_INTEGER: number;
  56190. readonly RG_INTEGER: number;
  56191. readonly RGB_INTEGER: number;
  56192. readonly RGBA_INTEGER: number;
  56193. readonly R8_SNORM: number;
  56194. readonly RG8_SNORM: number;
  56195. readonly RGB8_SNORM: number;
  56196. readonly RGBA8_SNORM: number;
  56197. readonly R8I: number;
  56198. readonly RG8I: number;
  56199. readonly RGB8I: number;
  56200. readonly RGBA8I: number;
  56201. readonly R8UI: number;
  56202. readonly RG8UI: number;
  56203. readonly RGB8UI: number;
  56204. readonly RGBA8UI: number;
  56205. readonly R16I: number;
  56206. readonly RG16I: number;
  56207. readonly RGB16I: number;
  56208. readonly RGBA16I: number;
  56209. readonly R16UI: number;
  56210. readonly RG16UI: number;
  56211. readonly RGB16UI: number;
  56212. readonly RGBA16UI: number;
  56213. readonly R32I: number;
  56214. readonly RG32I: number;
  56215. readonly RGB32I: number;
  56216. readonly RGBA32I: number;
  56217. readonly R32UI: number;
  56218. readonly RG32UI: number;
  56219. readonly RGB32UI: number;
  56220. readonly RGBA32UI: number;
  56221. readonly RGB10_A2UI: number;
  56222. readonly R11F_G11F_B10F: number;
  56223. readonly RGB9_E5: number;
  56224. readonly RGB10_A2: number;
  56225. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56226. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56227. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56228. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56229. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56230. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56231. 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;
  56232. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56233. readonly TRANSFORM_FEEDBACK: number;
  56234. readonly INTERLEAVED_ATTRIBS: number;
  56235. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56236. createTransformFeedback(): WebGLTransformFeedback;
  56237. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56238. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56239. beginTransformFeedback(primitiveMode: number): void;
  56240. endTransformFeedback(): void;
  56241. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56242. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56243. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56244. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56245. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56246. }
  56247. interface ImageBitmap {
  56248. readonly width: number;
  56249. readonly height: number;
  56250. close(): void;
  56251. }
  56252. interface WebGLQuery extends WebGLObject {
  56253. }
  56254. declare var WebGLQuery: {
  56255. prototype: WebGLQuery;
  56256. new(): WebGLQuery;
  56257. };
  56258. interface WebGLSampler extends WebGLObject {
  56259. }
  56260. declare var WebGLSampler: {
  56261. prototype: WebGLSampler;
  56262. new(): WebGLSampler;
  56263. };
  56264. interface WebGLSync extends WebGLObject {
  56265. }
  56266. declare var WebGLSync: {
  56267. prototype: WebGLSync;
  56268. new(): WebGLSync;
  56269. };
  56270. interface WebGLTransformFeedback extends WebGLObject {
  56271. }
  56272. declare var WebGLTransformFeedback: {
  56273. prototype: WebGLTransformFeedback;
  56274. new(): WebGLTransformFeedback;
  56275. };
  56276. interface WebGLVertexArrayObject extends WebGLObject {
  56277. }
  56278. declare var WebGLVertexArrayObject: {
  56279. prototype: WebGLVertexArrayObject;
  56280. new(): WebGLVertexArrayObject;
  56281. };
  56282. // Type definitions for WebVR API
  56283. // Project: https://w3c.github.io/webvr/
  56284. // Definitions by: six a <https://github.com/lostfictions>
  56285. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56286. interface VRDisplay extends EventTarget {
  56287. /**
  56288. * Dictionary of capabilities describing the VRDisplay.
  56289. */
  56290. readonly capabilities: VRDisplayCapabilities;
  56291. /**
  56292. * z-depth defining the far plane of the eye view frustum
  56293. * enables mapping of values in the render target depth
  56294. * attachment to scene coordinates. Initially set to 10000.0.
  56295. */
  56296. depthFar: number;
  56297. /**
  56298. * z-depth defining the near plane of the eye view frustum
  56299. * enables mapping of values in the render target depth
  56300. * attachment to scene coordinates. Initially set to 0.01.
  56301. */
  56302. depthNear: number;
  56303. /**
  56304. * An identifier for this distinct VRDisplay. Used as an
  56305. * association point in the Gamepad API.
  56306. */
  56307. readonly displayId: number;
  56308. /**
  56309. * A display name, a user-readable name identifying it.
  56310. */
  56311. readonly displayName: string;
  56312. readonly isConnected: boolean;
  56313. readonly isPresenting: boolean;
  56314. /**
  56315. * If this VRDisplay supports room-scale experiences, the optional
  56316. * stage attribute contains details on the room-scale parameters.
  56317. */
  56318. readonly stageParameters: VRStageParameters | null;
  56319. /**
  56320. * Passing the value returned by `requestAnimationFrame` to
  56321. * `cancelAnimationFrame` will unregister the callback.
  56322. * @param handle Define the hanle of the request to cancel
  56323. */
  56324. cancelAnimationFrame(handle: number): void;
  56325. /**
  56326. * Stops presenting to the VRDisplay.
  56327. * @returns a promise to know when it stopped
  56328. */
  56329. exitPresent(): Promise<void>;
  56330. /**
  56331. * Return the current VREyeParameters for the given eye.
  56332. * @param whichEye Define the eye we want the parameter for
  56333. * @returns the eye parameters
  56334. */
  56335. getEyeParameters(whichEye: string): VREyeParameters;
  56336. /**
  56337. * Populates the passed VRFrameData with the information required to render
  56338. * the current frame.
  56339. * @param frameData Define the data structure to populate
  56340. * @returns true if ok otherwise false
  56341. */
  56342. getFrameData(frameData: VRFrameData): boolean;
  56343. /**
  56344. * Get the layers currently being presented.
  56345. * @returns the list of VR layers
  56346. */
  56347. getLayers(): VRLayer[];
  56348. /**
  56349. * Return a VRPose containing the future predicted pose of the VRDisplay
  56350. * when the current frame will be presented. The value returned will not
  56351. * change until JavaScript has returned control to the browser.
  56352. *
  56353. * The VRPose will contain the position, orientation, velocity,
  56354. * and acceleration of each of these properties.
  56355. * @returns the pose object
  56356. */
  56357. getPose(): VRPose;
  56358. /**
  56359. * Return the current instantaneous pose of the VRDisplay, with no
  56360. * prediction applied.
  56361. * @returns the current instantaneous pose
  56362. */
  56363. getImmediatePose(): VRPose;
  56364. /**
  56365. * The callback passed to `requestAnimationFrame` will be called
  56366. * any time a new frame should be rendered. When the VRDisplay is
  56367. * presenting the callback will be called at the native refresh
  56368. * rate of the HMD. When not presenting this function acts
  56369. * identically to how window.requestAnimationFrame acts. Content should
  56370. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56371. * asynchronously from other displays and at differing refresh rates.
  56372. * @param callback Define the eaction to run next frame
  56373. * @returns the request handle it
  56374. */
  56375. requestAnimationFrame(callback: FrameRequestCallback): number;
  56376. /**
  56377. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56378. * Repeat calls while already presenting will update the VRLayers being displayed.
  56379. * @param layers Define the list of layer to present
  56380. * @returns a promise to know when the request has been fulfilled
  56381. */
  56382. requestPresent(layers: VRLayer[]): Promise<void>;
  56383. /**
  56384. * Reset the pose for this display, treating its current position and
  56385. * orientation as the "origin/zero" values. VRPose.position,
  56386. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56387. * updated when calling resetPose(). This should be called in only
  56388. * sitting-space experiences.
  56389. */
  56390. resetPose(): void;
  56391. /**
  56392. * The VRLayer provided to the VRDisplay will be captured and presented
  56393. * in the HMD. Calling this function has the same effect on the source
  56394. * canvas as any other operation that uses its source image, and canvases
  56395. * created without preserveDrawingBuffer set to true will be cleared.
  56396. * @param pose Define the pose to submit
  56397. */
  56398. submitFrame(pose?: VRPose): void;
  56399. }
  56400. declare var VRDisplay: {
  56401. prototype: VRDisplay;
  56402. new(): VRDisplay;
  56403. };
  56404. interface VRLayer {
  56405. leftBounds?: number[] | Float32Array | null;
  56406. rightBounds?: number[] | Float32Array | null;
  56407. source?: HTMLCanvasElement | null;
  56408. }
  56409. interface VRDisplayCapabilities {
  56410. readonly canPresent: boolean;
  56411. readonly hasExternalDisplay: boolean;
  56412. readonly hasOrientation: boolean;
  56413. readonly hasPosition: boolean;
  56414. readonly maxLayers: number;
  56415. }
  56416. interface VREyeParameters {
  56417. /** @deprecated */
  56418. readonly fieldOfView: VRFieldOfView;
  56419. readonly offset: Float32Array;
  56420. readonly renderHeight: number;
  56421. readonly renderWidth: number;
  56422. }
  56423. interface VRFieldOfView {
  56424. readonly downDegrees: number;
  56425. readonly leftDegrees: number;
  56426. readonly rightDegrees: number;
  56427. readonly upDegrees: number;
  56428. }
  56429. interface VRFrameData {
  56430. readonly leftProjectionMatrix: Float32Array;
  56431. readonly leftViewMatrix: Float32Array;
  56432. readonly pose: VRPose;
  56433. readonly rightProjectionMatrix: Float32Array;
  56434. readonly rightViewMatrix: Float32Array;
  56435. readonly timestamp: number;
  56436. }
  56437. interface VRPose {
  56438. readonly angularAcceleration: Float32Array | null;
  56439. readonly angularVelocity: Float32Array | null;
  56440. readonly linearAcceleration: Float32Array | null;
  56441. readonly linearVelocity: Float32Array | null;
  56442. readonly orientation: Float32Array | null;
  56443. readonly position: Float32Array | null;
  56444. readonly timestamp: number;
  56445. }
  56446. interface VRStageParameters {
  56447. sittingToStandingTransform?: Float32Array;
  56448. sizeX?: number;
  56449. sizeY?: number;
  56450. }
  56451. interface Navigator {
  56452. getVRDisplays(): Promise<VRDisplay[]>;
  56453. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56454. }
  56455. interface Window {
  56456. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56457. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56458. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56459. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56460. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56461. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56462. }
  56463. interface Gamepad {
  56464. readonly displayId: number;
  56465. }
  56466. interface XRDevice {
  56467. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56468. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56469. }
  56470. interface XRSession {
  56471. getInputSources(): Array<any>;
  56472. baseLayer: XRWebGLLayer;
  56473. requestFrameOfReference(type: string): Promise<void>;
  56474. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56475. end(): Promise<void>;
  56476. requestAnimationFrame: Function;
  56477. addEventListener: Function;
  56478. }
  56479. interface XRSessionCreationOptions {
  56480. outputContext?: WebGLRenderingContext | null;
  56481. immersive?: boolean;
  56482. environmentIntegration?: boolean;
  56483. }
  56484. interface XRLayer {
  56485. getViewport: Function;
  56486. framebufferWidth: number;
  56487. framebufferHeight: number;
  56488. }
  56489. interface XRView {
  56490. projectionMatrix: Float32Array;
  56491. }
  56492. interface XRFrame {
  56493. getDevicePose: Function;
  56494. getInputPose: Function;
  56495. views: Array<XRView>;
  56496. baseLayer: XRLayer;
  56497. }
  56498. interface XRFrameOfReference {
  56499. }
  56500. interface XRWebGLLayer extends XRLayer {
  56501. framebuffer: WebGLFramebuffer;
  56502. }
  56503. declare var XRWebGLLayer: {
  56504. prototype: XRWebGLLayer;
  56505. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56506. };
  56507. declare module "babylonjs" {
  56508. export * from "babylonjs/Legacy/legacy";
  56509. }
  56510. declare module BABYLON {
  56511. /** Alias type for value that can be null */
  56512. export type Nullable<T> = T | null;
  56513. /**
  56514. * Alias type for number that are floats
  56515. * @ignorenaming
  56516. */
  56517. export type float = number;
  56518. /**
  56519. * Alias type for number that are doubles.
  56520. * @ignorenaming
  56521. */
  56522. export type double = number;
  56523. /**
  56524. * Alias type for number that are integer
  56525. * @ignorenaming
  56526. */
  56527. export type int = number;
  56528. /** Alias type for number array or Float32Array */
  56529. export type FloatArray = number[] | Float32Array;
  56530. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56531. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56532. /**
  56533. * Alias for types that can be used by a Buffer or VertexBuffer.
  56534. */
  56535. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56536. /**
  56537. * Alias type for primitive types
  56538. * @ignorenaming
  56539. */
  56540. type Primitive = undefined | null | boolean | string | number | Function;
  56541. /**
  56542. * Type modifier to make all the properties of an object Readonly
  56543. */
  56544. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56545. /**
  56546. * Type modifier to make all the properties of an object Readonly recursively
  56547. */
  56548. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56549. /** @hidden */
  56550. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56551. }
  56552. /** @hidden */
  56553. /** @hidden */
  56554. type DeepImmutableObject<T> = {
  56555. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56556. };
  56557. }
  56558. declare module BABYLON {
  56559. /**
  56560. * Class containing a set of static utilities functions for arrays.
  56561. */
  56562. export class ArrayTools {
  56563. /**
  56564. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56565. * @param size the number of element to construct and put in the array
  56566. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56567. * @returns a new array filled with new objects
  56568. */
  56569. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56570. }
  56571. }
  56572. declare module BABYLON {
  56573. /**
  56574. * Scalar computation library
  56575. */
  56576. export class Scalar {
  56577. /**
  56578. * Two pi constants convenient for computation.
  56579. */
  56580. static TwoPi: number;
  56581. /**
  56582. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56583. * @param a number
  56584. * @param b number
  56585. * @param epsilon (default = 1.401298E-45)
  56586. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56587. */
  56588. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56589. /**
  56590. * Returns a string : the upper case translation of the number i to hexadecimal.
  56591. * @param i number
  56592. * @returns the upper case translation of the number i to hexadecimal.
  56593. */
  56594. static ToHex(i: number): string;
  56595. /**
  56596. * Returns -1 if value is negative and +1 is value is positive.
  56597. * @param value the value
  56598. * @returns the value itself if it's equal to zero.
  56599. */
  56600. static Sign(value: number): number;
  56601. /**
  56602. * Returns the value itself if it's between min and max.
  56603. * Returns min if the value is lower than min.
  56604. * Returns max if the value is greater than max.
  56605. * @param value the value to clmap
  56606. * @param min the min value to clamp to (default: 0)
  56607. * @param max the max value to clamp to (default: 1)
  56608. * @returns the clamped value
  56609. */
  56610. static Clamp(value: number, min?: number, max?: number): number;
  56611. /**
  56612. * the log2 of value.
  56613. * @param value the value to compute log2 of
  56614. * @returns the log2 of value.
  56615. */
  56616. static Log2(value: number): number;
  56617. /**
  56618. * Loops the value, so that it is never larger than length and never smaller than 0.
  56619. *
  56620. * This is similar to the modulo operator but it works with floating point numbers.
  56621. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56622. * With t = 5 and length = 2.5, the result would be 0.0.
  56623. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56624. * @param value the value
  56625. * @param length the length
  56626. * @returns the looped value
  56627. */
  56628. static Repeat(value: number, length: number): number;
  56629. /**
  56630. * Normalize the value between 0.0 and 1.0 using min and max values
  56631. * @param value value to normalize
  56632. * @param min max to normalize between
  56633. * @param max min to normalize between
  56634. * @returns the normalized value
  56635. */
  56636. static Normalize(value: number, min: number, max: number): number;
  56637. /**
  56638. * Denormalize the value from 0.0 and 1.0 using min and max values
  56639. * @param normalized value to denormalize
  56640. * @param min max to denormalize between
  56641. * @param max min to denormalize between
  56642. * @returns the denormalized value
  56643. */
  56644. static Denormalize(normalized: number, min: number, max: number): number;
  56645. /**
  56646. * Calculates the shortest difference between two given angles given in degrees.
  56647. * @param current current angle in degrees
  56648. * @param target target angle in degrees
  56649. * @returns the delta
  56650. */
  56651. static DeltaAngle(current: number, target: number): number;
  56652. /**
  56653. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56654. * @param tx value
  56655. * @param length length
  56656. * @returns The returned value will move back and forth between 0 and length
  56657. */
  56658. static PingPong(tx: number, length: number): number;
  56659. /**
  56660. * Interpolates between min and max with smoothing at the limits.
  56661. *
  56662. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56663. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56664. * @param from from
  56665. * @param to to
  56666. * @param tx value
  56667. * @returns the smooth stepped value
  56668. */
  56669. static SmoothStep(from: number, to: number, tx: number): number;
  56670. /**
  56671. * Moves a value current towards target.
  56672. *
  56673. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56674. * Negative values of maxDelta pushes the value away from target.
  56675. * @param current current value
  56676. * @param target target value
  56677. * @param maxDelta max distance to move
  56678. * @returns resulting value
  56679. */
  56680. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56681. /**
  56682. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56683. *
  56684. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56685. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56686. * @param current current value
  56687. * @param target target value
  56688. * @param maxDelta max distance to move
  56689. * @returns resulting angle
  56690. */
  56691. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56692. /**
  56693. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56694. * @param start start value
  56695. * @param end target value
  56696. * @param amount amount to lerp between
  56697. * @returns the lerped value
  56698. */
  56699. static Lerp(start: number, end: number, amount: number): number;
  56700. /**
  56701. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56702. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56703. * @param start start value
  56704. * @param end target value
  56705. * @param amount amount to lerp between
  56706. * @returns the lerped value
  56707. */
  56708. static LerpAngle(start: number, end: number, amount: number): number;
  56709. /**
  56710. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56711. * @param a start value
  56712. * @param b target value
  56713. * @param value value between a and b
  56714. * @returns the inverseLerp value
  56715. */
  56716. static InverseLerp(a: number, b: number, value: number): number;
  56717. /**
  56718. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56719. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56720. * @param value1 spline value
  56721. * @param tangent1 spline value
  56722. * @param value2 spline value
  56723. * @param tangent2 spline value
  56724. * @param amount input value
  56725. * @returns hermite result
  56726. */
  56727. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56728. /**
  56729. * Returns a random float number between and min and max values
  56730. * @param min min value of random
  56731. * @param max max value of random
  56732. * @returns random value
  56733. */
  56734. static RandomRange(min: number, max: number): number;
  56735. /**
  56736. * This function returns percentage of a number in a given range.
  56737. *
  56738. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56739. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56740. * @param number to convert to percentage
  56741. * @param min min range
  56742. * @param max max range
  56743. * @returns the percentage
  56744. */
  56745. static RangeToPercent(number: number, min: number, max: number): number;
  56746. /**
  56747. * This function returns number that corresponds to the percentage in a given range.
  56748. *
  56749. * PercentToRange(0.34,0,100) will return 34.
  56750. * @param percent to convert to number
  56751. * @param min min range
  56752. * @param max max range
  56753. * @returns the number
  56754. */
  56755. static PercentToRange(percent: number, min: number, max: number): number;
  56756. /**
  56757. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56758. * @param angle The angle to normalize in radian.
  56759. * @return The converted angle.
  56760. */
  56761. static NormalizeRadians(angle: number): number;
  56762. }
  56763. }
  56764. declare module BABYLON {
  56765. /**
  56766. * Constant used to convert a value to gamma space
  56767. * @ignorenaming
  56768. */
  56769. export const ToGammaSpace: number;
  56770. /**
  56771. * Constant used to convert a value to linear space
  56772. * @ignorenaming
  56773. */
  56774. export const ToLinearSpace = 2.2;
  56775. /**
  56776. * Constant used to define the minimal number value in Babylon.js
  56777. * @ignorenaming
  56778. */
  56779. export const Epsilon = 0.001;
  56780. /**
  56781. * Class used to hold a RBG color
  56782. */
  56783. export class Color3 {
  56784. /**
  56785. * Defines the red component (between 0 and 1, default is 0)
  56786. */
  56787. r: number;
  56788. /**
  56789. * Defines the green component (between 0 and 1, default is 0)
  56790. */
  56791. g: number;
  56792. /**
  56793. * Defines the blue component (between 0 and 1, default is 0)
  56794. */
  56795. b: number;
  56796. /**
  56797. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56798. * @param r defines the red component (between 0 and 1, default is 0)
  56799. * @param g defines the green component (between 0 and 1, default is 0)
  56800. * @param b defines the blue component (between 0 and 1, default is 0)
  56801. */
  56802. constructor(
  56803. /**
  56804. * Defines the red component (between 0 and 1, default is 0)
  56805. */
  56806. r?: number,
  56807. /**
  56808. * Defines the green component (between 0 and 1, default is 0)
  56809. */
  56810. g?: number,
  56811. /**
  56812. * Defines the blue component (between 0 and 1, default is 0)
  56813. */
  56814. b?: number);
  56815. /**
  56816. * Creates a string with the Color3 current values
  56817. * @returns the string representation of the Color3 object
  56818. */
  56819. toString(): string;
  56820. /**
  56821. * Returns the string "Color3"
  56822. * @returns "Color3"
  56823. */
  56824. getClassName(): string;
  56825. /**
  56826. * Compute the Color3 hash code
  56827. * @returns an unique number that can be used to hash Color3 objects
  56828. */
  56829. getHashCode(): number;
  56830. /**
  56831. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56832. * @param array defines the array where to store the r,g,b components
  56833. * @param index defines an optional index in the target array to define where to start storing values
  56834. * @returns the current Color3 object
  56835. */
  56836. toArray(array: FloatArray, index?: number): Color3;
  56837. /**
  56838. * Returns a new Color4 object from the current Color3 and the given alpha
  56839. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56840. * @returns a new Color4 object
  56841. */
  56842. toColor4(alpha?: number): Color4;
  56843. /**
  56844. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56845. * @returns the new array
  56846. */
  56847. asArray(): number[];
  56848. /**
  56849. * Returns the luminance value
  56850. * @returns a float value
  56851. */
  56852. toLuminance(): number;
  56853. /**
  56854. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56855. * @param otherColor defines the second operand
  56856. * @returns the new Color3 object
  56857. */
  56858. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56859. /**
  56860. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56861. * @param otherColor defines the second operand
  56862. * @param result defines the Color3 object where to store the result
  56863. * @returns the current Color3
  56864. */
  56865. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56866. /**
  56867. * Determines equality between Color3 objects
  56868. * @param otherColor defines the second operand
  56869. * @returns true if the rgb values are equal to the given ones
  56870. */
  56871. equals(otherColor: DeepImmutable<Color3>): boolean;
  56872. /**
  56873. * Determines equality between the current Color3 object and a set of r,b,g values
  56874. * @param r defines the red component to check
  56875. * @param g defines the green component to check
  56876. * @param b defines the blue component to check
  56877. * @returns true if the rgb values are equal to the given ones
  56878. */
  56879. equalsFloats(r: number, g: number, b: number): boolean;
  56880. /**
  56881. * Multiplies in place each rgb value by scale
  56882. * @param scale defines the scaling factor
  56883. * @returns the updated Color3
  56884. */
  56885. scale(scale: number): Color3;
  56886. /**
  56887. * Multiplies the rgb values by scale and stores the result into "result"
  56888. * @param scale defines the scaling factor
  56889. * @param result defines the Color3 object where to store the result
  56890. * @returns the unmodified current Color3
  56891. */
  56892. scaleToRef(scale: number, result: Color3): Color3;
  56893. /**
  56894. * Scale the current Color3 values by a factor and add the result to a given Color3
  56895. * @param scale defines the scale factor
  56896. * @param result defines color to store the result into
  56897. * @returns the unmodified current Color3
  56898. */
  56899. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56900. /**
  56901. * Clamps the rgb values by the min and max values and stores the result into "result"
  56902. * @param min defines minimum clamping value (default is 0)
  56903. * @param max defines maximum clamping value (default is 1)
  56904. * @param result defines color to store the result into
  56905. * @returns the original Color3
  56906. */
  56907. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56908. /**
  56909. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56910. * @param otherColor defines the second operand
  56911. * @returns the new Color3
  56912. */
  56913. add(otherColor: DeepImmutable<Color3>): Color3;
  56914. /**
  56915. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56916. * @param otherColor defines the second operand
  56917. * @param result defines Color3 object to store the result into
  56918. * @returns the unmodified current Color3
  56919. */
  56920. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56921. /**
  56922. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56923. * @param otherColor defines the second operand
  56924. * @returns the new Color3
  56925. */
  56926. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56927. /**
  56928. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56929. * @param otherColor defines the second operand
  56930. * @param result defines Color3 object to store the result into
  56931. * @returns the unmodified current Color3
  56932. */
  56933. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56934. /**
  56935. * Copy the current object
  56936. * @returns a new Color3 copied the current one
  56937. */
  56938. clone(): Color3;
  56939. /**
  56940. * Copies the rgb values from the source in the current Color3
  56941. * @param source defines the source Color3 object
  56942. * @returns the updated Color3 object
  56943. */
  56944. copyFrom(source: DeepImmutable<Color3>): Color3;
  56945. /**
  56946. * Updates the Color3 rgb values from the given floats
  56947. * @param r defines the red component to read from
  56948. * @param g defines the green component to read from
  56949. * @param b defines the blue component to read from
  56950. * @returns the current Color3 object
  56951. */
  56952. copyFromFloats(r: number, g: number, b: number): Color3;
  56953. /**
  56954. * Updates the Color3 rgb values from the given floats
  56955. * @param r defines the red component to read from
  56956. * @param g defines the green component to read from
  56957. * @param b defines the blue component to read from
  56958. * @returns the current Color3 object
  56959. */
  56960. set(r: number, g: number, b: number): Color3;
  56961. /**
  56962. * Compute the Color3 hexadecimal code as a string
  56963. * @returns a string containing the hexadecimal representation of the Color3 object
  56964. */
  56965. toHexString(): string;
  56966. /**
  56967. * Computes a new Color3 converted from the current one to linear space
  56968. * @returns a new Color3 object
  56969. */
  56970. toLinearSpace(): Color3;
  56971. /**
  56972. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56973. * @param convertedColor defines the Color3 object where to store the linear space version
  56974. * @returns the unmodified Color3
  56975. */
  56976. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56977. /**
  56978. * Computes a new Color3 converted from the current one to gamma space
  56979. * @returns a new Color3 object
  56980. */
  56981. toGammaSpace(): Color3;
  56982. /**
  56983. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56984. * @param convertedColor defines the Color3 object where to store the gamma space version
  56985. * @returns the unmodified Color3
  56986. */
  56987. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56988. private static _BlackReadOnly;
  56989. /**
  56990. * Creates a new Color3 from the string containing valid hexadecimal values
  56991. * @param hex defines a string containing valid hexadecimal values
  56992. * @returns a new Color3 object
  56993. */
  56994. static FromHexString(hex: string): Color3;
  56995. /**
  56996. * Creates a new Vector3 from the starting index of the given array
  56997. * @param array defines the source array
  56998. * @param offset defines an offset in the source array
  56999. * @returns a new Color3 object
  57000. */
  57001. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57002. /**
  57003. * Creates a new Color3 from integer values (< 256)
  57004. * @param r defines the red component to read from (value between 0 and 255)
  57005. * @param g defines the green component to read from (value between 0 and 255)
  57006. * @param b defines the blue component to read from (value between 0 and 255)
  57007. * @returns a new Color3 object
  57008. */
  57009. static FromInts(r: number, g: number, b: number): Color3;
  57010. /**
  57011. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57012. * @param start defines the start Color3 value
  57013. * @param end defines the end Color3 value
  57014. * @param amount defines the gradient value between start and end
  57015. * @returns a new Color3 object
  57016. */
  57017. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57018. /**
  57019. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57020. * @param left defines the start value
  57021. * @param right defines the end value
  57022. * @param amount defines the gradient factor
  57023. * @param result defines the Color3 object where to store the result
  57024. */
  57025. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57026. /**
  57027. * Returns a Color3 value containing a red color
  57028. * @returns a new Color3 object
  57029. */
  57030. static Red(): Color3;
  57031. /**
  57032. * Returns a Color3 value containing a green color
  57033. * @returns a new Color3 object
  57034. */
  57035. static Green(): Color3;
  57036. /**
  57037. * Returns a Color3 value containing a blue color
  57038. * @returns a new Color3 object
  57039. */
  57040. static Blue(): Color3;
  57041. /**
  57042. * Returns a Color3 value containing a black color
  57043. * @returns a new Color3 object
  57044. */
  57045. static Black(): Color3;
  57046. /**
  57047. * Gets a Color3 value containing a black color that must not be updated
  57048. */
  57049. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57050. /**
  57051. * Returns a Color3 value containing a white color
  57052. * @returns a new Color3 object
  57053. */
  57054. static White(): Color3;
  57055. /**
  57056. * Returns a Color3 value containing a purple color
  57057. * @returns a new Color3 object
  57058. */
  57059. static Purple(): Color3;
  57060. /**
  57061. * Returns a Color3 value containing a magenta color
  57062. * @returns a new Color3 object
  57063. */
  57064. static Magenta(): Color3;
  57065. /**
  57066. * Returns a Color3 value containing a yellow color
  57067. * @returns a new Color3 object
  57068. */
  57069. static Yellow(): Color3;
  57070. /**
  57071. * Returns a Color3 value containing a gray color
  57072. * @returns a new Color3 object
  57073. */
  57074. static Gray(): Color3;
  57075. /**
  57076. * Returns a Color3 value containing a teal color
  57077. * @returns a new Color3 object
  57078. */
  57079. static Teal(): Color3;
  57080. /**
  57081. * Returns a Color3 value containing a random color
  57082. * @returns a new Color3 object
  57083. */
  57084. static Random(): Color3;
  57085. }
  57086. /**
  57087. * Class used to hold a RBGA color
  57088. */
  57089. export class Color4 {
  57090. /**
  57091. * Defines the red component (between 0 and 1, default is 0)
  57092. */
  57093. r: number;
  57094. /**
  57095. * Defines the green component (between 0 and 1, default is 0)
  57096. */
  57097. g: number;
  57098. /**
  57099. * Defines the blue component (between 0 and 1, default is 0)
  57100. */
  57101. b: number;
  57102. /**
  57103. * Defines the alpha component (between 0 and 1, default is 1)
  57104. */
  57105. a: number;
  57106. /**
  57107. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57108. * @param r defines the red component (between 0 and 1, default is 0)
  57109. * @param g defines the green component (between 0 and 1, default is 0)
  57110. * @param b defines the blue component (between 0 and 1, default is 0)
  57111. * @param a defines the alpha component (between 0 and 1, default is 1)
  57112. */
  57113. constructor(
  57114. /**
  57115. * Defines the red component (between 0 and 1, default is 0)
  57116. */
  57117. r?: number,
  57118. /**
  57119. * Defines the green component (between 0 and 1, default is 0)
  57120. */
  57121. g?: number,
  57122. /**
  57123. * Defines the blue component (between 0 and 1, default is 0)
  57124. */
  57125. b?: number,
  57126. /**
  57127. * Defines the alpha component (between 0 and 1, default is 1)
  57128. */
  57129. a?: number);
  57130. /**
  57131. * Adds in place the given Color4 values to the current Color4 object
  57132. * @param right defines the second operand
  57133. * @returns the current updated Color4 object
  57134. */
  57135. addInPlace(right: DeepImmutable<Color4>): Color4;
  57136. /**
  57137. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57138. * @returns the new array
  57139. */
  57140. asArray(): number[];
  57141. /**
  57142. * Stores from the starting index in the given array the Color4 successive values
  57143. * @param array defines the array where to store the r,g,b components
  57144. * @param index defines an optional index in the target array to define where to start storing values
  57145. * @returns the current Color4 object
  57146. */
  57147. toArray(array: number[], index?: number): Color4;
  57148. /**
  57149. * Determines equality between Color4 objects
  57150. * @param otherColor defines the second operand
  57151. * @returns true if the rgba values are equal to the given ones
  57152. */
  57153. equals(otherColor: DeepImmutable<Color4>): boolean;
  57154. /**
  57155. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57156. * @param right defines the second operand
  57157. * @returns a new Color4 object
  57158. */
  57159. add(right: DeepImmutable<Color4>): Color4;
  57160. /**
  57161. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57162. * @param right defines the second operand
  57163. * @returns a new Color4 object
  57164. */
  57165. subtract(right: DeepImmutable<Color4>): Color4;
  57166. /**
  57167. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57168. * @param right defines the second operand
  57169. * @param result defines the Color4 object where to store the result
  57170. * @returns the current Color4 object
  57171. */
  57172. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57173. /**
  57174. * Creates a new Color4 with the current Color4 values multiplied by scale
  57175. * @param scale defines the scaling factor to apply
  57176. * @returns a new Color4 object
  57177. */
  57178. scale(scale: number): Color4;
  57179. /**
  57180. * Multiplies the current Color4 values by scale and stores the result in "result"
  57181. * @param scale defines the scaling factor to apply
  57182. * @param result defines the Color4 object where to store the result
  57183. * @returns the current unmodified Color4
  57184. */
  57185. scaleToRef(scale: number, result: Color4): Color4;
  57186. /**
  57187. * Scale the current Color4 values by a factor and add the result to a given Color4
  57188. * @param scale defines the scale factor
  57189. * @param result defines the Color4 object where to store the result
  57190. * @returns the unmodified current Color4
  57191. */
  57192. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57193. /**
  57194. * Clamps the rgb values by the min and max values and stores the result into "result"
  57195. * @param min defines minimum clamping value (default is 0)
  57196. * @param max defines maximum clamping value (default is 1)
  57197. * @param result defines color to store the result into.
  57198. * @returns the cuurent Color4
  57199. */
  57200. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57201. /**
  57202. * Multipy an Color4 value by another and return a new Color4 object
  57203. * @param color defines the Color4 value to multiply by
  57204. * @returns a new Color4 object
  57205. */
  57206. multiply(color: Color4): Color4;
  57207. /**
  57208. * Multipy a Color4 value by another and push the result in a reference value
  57209. * @param color defines the Color4 value to multiply by
  57210. * @param result defines the Color4 to fill the result in
  57211. * @returns the result Color4
  57212. */
  57213. multiplyToRef(color: Color4, result: Color4): Color4;
  57214. /**
  57215. * Creates a string with the Color4 current values
  57216. * @returns the string representation of the Color4 object
  57217. */
  57218. toString(): string;
  57219. /**
  57220. * Returns the string "Color4"
  57221. * @returns "Color4"
  57222. */
  57223. getClassName(): string;
  57224. /**
  57225. * Compute the Color4 hash code
  57226. * @returns an unique number that can be used to hash Color4 objects
  57227. */
  57228. getHashCode(): number;
  57229. /**
  57230. * Creates a new Color4 copied from the current one
  57231. * @returns a new Color4 object
  57232. */
  57233. clone(): Color4;
  57234. /**
  57235. * Copies the given Color4 values into the current one
  57236. * @param source defines the source Color4 object
  57237. * @returns the current updated Color4 object
  57238. */
  57239. copyFrom(source: Color4): Color4;
  57240. /**
  57241. * Copies the given float values into the current one
  57242. * @param r defines the red component to read from
  57243. * @param g defines the green component to read from
  57244. * @param b defines the blue component to read from
  57245. * @param a defines the alpha component to read from
  57246. * @returns the current updated Color4 object
  57247. */
  57248. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57249. /**
  57250. * Copies the given float values into the current one
  57251. * @param r defines the red component to read from
  57252. * @param g defines the green component to read from
  57253. * @param b defines the blue component to read from
  57254. * @param a defines the alpha component to read from
  57255. * @returns the current updated Color4 object
  57256. */
  57257. set(r: number, g: number, b: number, a: number): Color4;
  57258. /**
  57259. * Compute the Color4 hexadecimal code as a string
  57260. * @returns a string containing the hexadecimal representation of the Color4 object
  57261. */
  57262. toHexString(): string;
  57263. /**
  57264. * Computes a new Color4 converted from the current one to linear space
  57265. * @returns a new Color4 object
  57266. */
  57267. toLinearSpace(): Color4;
  57268. /**
  57269. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57270. * @param convertedColor defines the Color4 object where to store the linear space version
  57271. * @returns the unmodified Color4
  57272. */
  57273. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57274. /**
  57275. * Computes a new Color4 converted from the current one to gamma space
  57276. * @returns a new Color4 object
  57277. */
  57278. toGammaSpace(): Color4;
  57279. /**
  57280. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57281. * @param convertedColor defines the Color4 object where to store the gamma space version
  57282. * @returns the unmodified Color4
  57283. */
  57284. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57285. /**
  57286. * Creates a new Color4 from the string containing valid hexadecimal values
  57287. * @param hex defines a string containing valid hexadecimal values
  57288. * @returns a new Color4 object
  57289. */
  57290. static FromHexString(hex: string): Color4;
  57291. /**
  57292. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57293. * @param left defines the start value
  57294. * @param right defines the end value
  57295. * @param amount defines the gradient factor
  57296. * @returns a new Color4 object
  57297. */
  57298. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57299. /**
  57300. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57301. * @param left defines the start value
  57302. * @param right defines the end value
  57303. * @param amount defines the gradient factor
  57304. * @param result defines the Color4 object where to store data
  57305. */
  57306. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57307. /**
  57308. * Creates a new Color4 from a Color3 and an alpha value
  57309. * @param color3 defines the source Color3 to read from
  57310. * @param alpha defines the alpha component (1.0 by default)
  57311. * @returns a new Color4 object
  57312. */
  57313. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57314. /**
  57315. * Creates a new Color4 from the starting index element of the given array
  57316. * @param array defines the source array to read from
  57317. * @param offset defines the offset in the source array
  57318. * @returns a new Color4 object
  57319. */
  57320. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57321. /**
  57322. * Creates a new Color3 from integer values (< 256)
  57323. * @param r defines the red component to read from (value between 0 and 255)
  57324. * @param g defines the green component to read from (value between 0 and 255)
  57325. * @param b defines the blue component to read from (value between 0 and 255)
  57326. * @param a defines the alpha component to read from (value between 0 and 255)
  57327. * @returns a new Color3 object
  57328. */
  57329. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57330. /**
  57331. * Check the content of a given array and convert it to an array containing RGBA data
  57332. * If the original array was already containing count * 4 values then it is returned directly
  57333. * @param colors defines the array to check
  57334. * @param count defines the number of RGBA data to expect
  57335. * @returns an array containing count * 4 values (RGBA)
  57336. */
  57337. static CheckColors4(colors: number[], count: number): number[];
  57338. }
  57339. /**
  57340. * Class representing a vector containing 2 coordinates
  57341. */
  57342. export class Vector2 {
  57343. /** defines the first coordinate */
  57344. x: number;
  57345. /** defines the second coordinate */
  57346. y: number;
  57347. /**
  57348. * Creates a new Vector2 from the given x and y coordinates
  57349. * @param x defines the first coordinate
  57350. * @param y defines the second coordinate
  57351. */
  57352. constructor(
  57353. /** defines the first coordinate */
  57354. x?: number,
  57355. /** defines the second coordinate */
  57356. y?: number);
  57357. /**
  57358. * Gets a string with the Vector2 coordinates
  57359. * @returns a string with the Vector2 coordinates
  57360. */
  57361. toString(): string;
  57362. /**
  57363. * Gets class name
  57364. * @returns the string "Vector2"
  57365. */
  57366. getClassName(): string;
  57367. /**
  57368. * Gets current vector hash code
  57369. * @returns the Vector2 hash code as a number
  57370. */
  57371. getHashCode(): number;
  57372. /**
  57373. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57374. * @param array defines the source array
  57375. * @param index defines the offset in source array
  57376. * @returns the current Vector2
  57377. */
  57378. toArray(array: FloatArray, index?: number): Vector2;
  57379. /**
  57380. * Copy the current vector to an array
  57381. * @returns a new array with 2 elements: the Vector2 coordinates.
  57382. */
  57383. asArray(): number[];
  57384. /**
  57385. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57386. * @param source defines the source Vector2
  57387. * @returns the current updated Vector2
  57388. */
  57389. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57390. /**
  57391. * Sets the Vector2 coordinates with the given floats
  57392. * @param x defines the first coordinate
  57393. * @param y defines the second coordinate
  57394. * @returns the current updated Vector2
  57395. */
  57396. copyFromFloats(x: number, y: number): Vector2;
  57397. /**
  57398. * Sets the Vector2 coordinates with the given floats
  57399. * @param x defines the first coordinate
  57400. * @param y defines the second coordinate
  57401. * @returns the current updated Vector2
  57402. */
  57403. set(x: number, y: number): Vector2;
  57404. /**
  57405. * Add another vector with the current one
  57406. * @param otherVector defines the other vector
  57407. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57408. */
  57409. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57410. /**
  57411. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57412. * @param otherVector defines the other vector
  57413. * @param result defines the target vector
  57414. * @returns the unmodified current Vector2
  57415. */
  57416. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57417. /**
  57418. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57419. * @param otherVector defines the other vector
  57420. * @returns the current updated Vector2
  57421. */
  57422. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57423. /**
  57424. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57425. * @param otherVector defines the other vector
  57426. * @returns a new Vector2
  57427. */
  57428. addVector3(otherVector: Vector3): Vector2;
  57429. /**
  57430. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57431. * @param otherVector defines the other vector
  57432. * @returns a new Vector2
  57433. */
  57434. subtract(otherVector: Vector2): Vector2;
  57435. /**
  57436. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57437. * @param otherVector defines the other vector
  57438. * @param result defines the target vector
  57439. * @returns the unmodified current Vector2
  57440. */
  57441. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57442. /**
  57443. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57444. * @param otherVector defines the other vector
  57445. * @returns the current updated Vector2
  57446. */
  57447. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57448. /**
  57449. * Multiplies in place the current Vector2 coordinates by the given ones
  57450. * @param otherVector defines the other vector
  57451. * @returns the current updated Vector2
  57452. */
  57453. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57454. /**
  57455. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57456. * @param otherVector defines the other vector
  57457. * @returns a new Vector2
  57458. */
  57459. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57460. /**
  57461. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57462. * @param otherVector defines the other vector
  57463. * @param result defines the target vector
  57464. * @returns the unmodified current Vector2
  57465. */
  57466. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57467. /**
  57468. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57469. * @param x defines the first coordinate
  57470. * @param y defines the second coordinate
  57471. * @returns a new Vector2
  57472. */
  57473. multiplyByFloats(x: number, y: number): Vector2;
  57474. /**
  57475. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57476. * @param otherVector defines the other vector
  57477. * @returns a new Vector2
  57478. */
  57479. divide(otherVector: Vector2): Vector2;
  57480. /**
  57481. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57482. * @param otherVector defines the other vector
  57483. * @param result defines the target vector
  57484. * @returns the unmodified current Vector2
  57485. */
  57486. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57487. /**
  57488. * Divides the current Vector2 coordinates by the given ones
  57489. * @param otherVector defines the other vector
  57490. * @returns the current updated Vector2
  57491. */
  57492. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57493. /**
  57494. * Gets a new Vector2 with current Vector2 negated coordinates
  57495. * @returns a new Vector2
  57496. */
  57497. negate(): Vector2;
  57498. /**
  57499. * Multiply the Vector2 coordinates by scale
  57500. * @param scale defines the scaling factor
  57501. * @returns the current updated Vector2
  57502. */
  57503. scaleInPlace(scale: number): Vector2;
  57504. /**
  57505. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57506. * @param scale defines the scaling factor
  57507. * @returns a new Vector2
  57508. */
  57509. scale(scale: number): Vector2;
  57510. /**
  57511. * Scale the current Vector2 values by a factor to a given Vector2
  57512. * @param scale defines the scale factor
  57513. * @param result defines the Vector2 object where to store the result
  57514. * @returns the unmodified current Vector2
  57515. */
  57516. scaleToRef(scale: number, result: Vector2): Vector2;
  57517. /**
  57518. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57519. * @param scale defines the scale factor
  57520. * @param result defines the Vector2 object where to store the result
  57521. * @returns the unmodified current Vector2
  57522. */
  57523. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57524. /**
  57525. * Gets a boolean if two vectors are equals
  57526. * @param otherVector defines the other vector
  57527. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57528. */
  57529. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57530. /**
  57531. * Gets a boolean if two vectors are equals (using an epsilon value)
  57532. * @param otherVector defines the other vector
  57533. * @param epsilon defines the minimal distance to consider equality
  57534. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57535. */
  57536. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57537. /**
  57538. * Gets a new Vector2 from current Vector2 floored values
  57539. * @returns a new Vector2
  57540. */
  57541. floor(): Vector2;
  57542. /**
  57543. * Gets a new Vector2 from current Vector2 floored values
  57544. * @returns a new Vector2
  57545. */
  57546. fract(): Vector2;
  57547. /**
  57548. * Gets the length of the vector
  57549. * @returns the vector length (float)
  57550. */
  57551. length(): number;
  57552. /**
  57553. * Gets the vector squared length
  57554. * @returns the vector squared length (float)
  57555. */
  57556. lengthSquared(): number;
  57557. /**
  57558. * Normalize the vector
  57559. * @returns the current updated Vector2
  57560. */
  57561. normalize(): Vector2;
  57562. /**
  57563. * Gets a new Vector2 copied from the Vector2
  57564. * @returns a new Vector2
  57565. */
  57566. clone(): Vector2;
  57567. /**
  57568. * Gets a new Vector2(0, 0)
  57569. * @returns a new Vector2
  57570. */
  57571. static Zero(): Vector2;
  57572. /**
  57573. * Gets a new Vector2(1, 1)
  57574. * @returns a new Vector2
  57575. */
  57576. static One(): Vector2;
  57577. /**
  57578. * Gets a new Vector2 set from the given index element of the given array
  57579. * @param array defines the data source
  57580. * @param offset defines the offset in the data source
  57581. * @returns a new Vector2
  57582. */
  57583. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57584. /**
  57585. * Sets "result" from the given index element of the given array
  57586. * @param array defines the data source
  57587. * @param offset defines the offset in the data source
  57588. * @param result defines the target vector
  57589. */
  57590. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57591. /**
  57592. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57593. * @param value1 defines 1st point of control
  57594. * @param value2 defines 2nd point of control
  57595. * @param value3 defines 3rd point of control
  57596. * @param value4 defines 4th point of control
  57597. * @param amount defines the interpolation factor
  57598. * @returns a new Vector2
  57599. */
  57600. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57601. /**
  57602. * 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".
  57603. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57604. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57605. * @param value defines the value to clamp
  57606. * @param min defines the lower limit
  57607. * @param max defines the upper limit
  57608. * @returns a new Vector2
  57609. */
  57610. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57611. /**
  57612. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57613. * @param value1 defines the 1st control point
  57614. * @param tangent1 defines the outgoing tangent
  57615. * @param value2 defines the 2nd control point
  57616. * @param tangent2 defines the incoming tangent
  57617. * @param amount defines the interpolation factor
  57618. * @returns a new Vector2
  57619. */
  57620. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57621. /**
  57622. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57623. * @param start defines the start vector
  57624. * @param end defines the end vector
  57625. * @param amount defines the interpolation factor
  57626. * @returns a new Vector2
  57627. */
  57628. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57629. /**
  57630. * Gets the dot product of the vector "left" and the vector "right"
  57631. * @param left defines first vector
  57632. * @param right defines second vector
  57633. * @returns the dot product (float)
  57634. */
  57635. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57636. /**
  57637. * Returns a new Vector2 equal to the normalized given vector
  57638. * @param vector defines the vector to normalize
  57639. * @returns a new Vector2
  57640. */
  57641. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57642. /**
  57643. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57644. * @param left defines 1st vector
  57645. * @param right defines 2nd vector
  57646. * @returns a new Vector2
  57647. */
  57648. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57649. /**
  57650. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57651. * @param left defines 1st vector
  57652. * @param right defines 2nd vector
  57653. * @returns a new Vector2
  57654. */
  57655. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57656. /**
  57657. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57658. * @param vector defines the vector to transform
  57659. * @param transformation defines the matrix to apply
  57660. * @returns a new Vector2
  57661. */
  57662. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57663. /**
  57664. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57665. * @param vector defines the vector to transform
  57666. * @param transformation defines the matrix to apply
  57667. * @param result defines the target vector
  57668. */
  57669. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57670. /**
  57671. * Determines if a given vector is included in a triangle
  57672. * @param p defines the vector to test
  57673. * @param p0 defines 1st triangle point
  57674. * @param p1 defines 2nd triangle point
  57675. * @param p2 defines 3rd triangle point
  57676. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57677. */
  57678. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57679. /**
  57680. * Gets the distance between the vectors "value1" and "value2"
  57681. * @param value1 defines first vector
  57682. * @param value2 defines second vector
  57683. * @returns the distance between vectors
  57684. */
  57685. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57686. /**
  57687. * Returns the squared distance between the vectors "value1" and "value2"
  57688. * @param value1 defines first vector
  57689. * @param value2 defines second vector
  57690. * @returns the squared distance between vectors
  57691. */
  57692. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57693. /**
  57694. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57695. * @param value1 defines first vector
  57696. * @param value2 defines second vector
  57697. * @returns a new Vector2
  57698. */
  57699. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57700. /**
  57701. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57702. * @param p defines the middle point
  57703. * @param segA defines one point of the segment
  57704. * @param segB defines the other point of the segment
  57705. * @returns the shortest distance
  57706. */
  57707. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57708. }
  57709. /**
  57710. * Classed used to store (x,y,z) vector representation
  57711. * A Vector3 is the main object used in 3D geometry
  57712. * It can represent etiher the coordinates of a point the space, either a direction
  57713. * Reminder: js uses a left handed forward facing system
  57714. */
  57715. export class Vector3 {
  57716. /**
  57717. * Defines the first coordinates (on X axis)
  57718. */
  57719. x: number;
  57720. /**
  57721. * Defines the second coordinates (on Y axis)
  57722. */
  57723. y: number;
  57724. /**
  57725. * Defines the third coordinates (on Z axis)
  57726. */
  57727. z: number;
  57728. private static _UpReadOnly;
  57729. /**
  57730. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57731. * @param x defines the first coordinates (on X axis)
  57732. * @param y defines the second coordinates (on Y axis)
  57733. * @param z defines the third coordinates (on Z axis)
  57734. */
  57735. constructor(
  57736. /**
  57737. * Defines the first coordinates (on X axis)
  57738. */
  57739. x?: number,
  57740. /**
  57741. * Defines the second coordinates (on Y axis)
  57742. */
  57743. y?: number,
  57744. /**
  57745. * Defines the third coordinates (on Z axis)
  57746. */
  57747. z?: number);
  57748. /**
  57749. * Creates a string representation of the Vector3
  57750. * @returns a string with the Vector3 coordinates.
  57751. */
  57752. toString(): string;
  57753. /**
  57754. * Gets the class name
  57755. * @returns the string "Vector3"
  57756. */
  57757. getClassName(): string;
  57758. /**
  57759. * Creates the Vector3 hash code
  57760. * @returns a number which tends to be unique between Vector3 instances
  57761. */
  57762. getHashCode(): number;
  57763. /**
  57764. * Creates an array containing three elements : the coordinates of the Vector3
  57765. * @returns a new array of numbers
  57766. */
  57767. asArray(): number[];
  57768. /**
  57769. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57770. * @param array defines the destination array
  57771. * @param index defines the offset in the destination array
  57772. * @returns the current Vector3
  57773. */
  57774. toArray(array: FloatArray, index?: number): Vector3;
  57775. /**
  57776. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57777. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57778. */
  57779. toQuaternion(): Quaternion;
  57780. /**
  57781. * Adds the given vector to the current Vector3
  57782. * @param otherVector defines the second operand
  57783. * @returns the current updated Vector3
  57784. */
  57785. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57786. /**
  57787. * Adds the given coordinates to the current Vector3
  57788. * @param x defines the x coordinate of the operand
  57789. * @param y defines the y coordinate of the operand
  57790. * @param z defines the z coordinate of the operand
  57791. * @returns the current updated Vector3
  57792. */
  57793. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57794. /**
  57795. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57796. * @param otherVector defines the second operand
  57797. * @returns the resulting Vector3
  57798. */
  57799. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57800. /**
  57801. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57802. * @param otherVector defines the second operand
  57803. * @param result defines the Vector3 object where to store the result
  57804. * @returns the current Vector3
  57805. */
  57806. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57807. /**
  57808. * Subtract the given vector from the current Vector3
  57809. * @param otherVector defines the second operand
  57810. * @returns the current updated Vector3
  57811. */
  57812. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57813. /**
  57814. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57815. * @param otherVector defines the second operand
  57816. * @returns the resulting Vector3
  57817. */
  57818. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57819. /**
  57820. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57821. * @param otherVector defines the second operand
  57822. * @param result defines the Vector3 object where to store the result
  57823. * @returns the current Vector3
  57824. */
  57825. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57826. /**
  57827. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57828. * @param x defines the x coordinate of the operand
  57829. * @param y defines the y coordinate of the operand
  57830. * @param z defines the z coordinate of the operand
  57831. * @returns the resulting Vector3
  57832. */
  57833. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57834. /**
  57835. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57836. * @param x defines the x coordinate of the operand
  57837. * @param y defines the y coordinate of the operand
  57838. * @param z defines the z coordinate of the operand
  57839. * @param result defines the Vector3 object where to store the result
  57840. * @returns the current Vector3
  57841. */
  57842. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57843. /**
  57844. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57845. * @returns a new Vector3
  57846. */
  57847. negate(): Vector3;
  57848. /**
  57849. * Multiplies the Vector3 coordinates by the float "scale"
  57850. * @param scale defines the multiplier factor
  57851. * @returns the current updated Vector3
  57852. */
  57853. scaleInPlace(scale: number): Vector3;
  57854. /**
  57855. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57856. * @param scale defines the multiplier factor
  57857. * @returns a new Vector3
  57858. */
  57859. scale(scale: number): Vector3;
  57860. /**
  57861. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57862. * @param scale defines the multiplier factor
  57863. * @param result defines the Vector3 object where to store the result
  57864. * @returns the current Vector3
  57865. */
  57866. scaleToRef(scale: number, result: Vector3): Vector3;
  57867. /**
  57868. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57869. * @param scale defines the scale factor
  57870. * @param result defines the Vector3 object where to store the result
  57871. * @returns the unmodified current Vector3
  57872. */
  57873. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57874. /**
  57875. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57876. * @param otherVector defines the second operand
  57877. * @returns true if both vectors are equals
  57878. */
  57879. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57880. /**
  57881. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57882. * @param otherVector defines the second operand
  57883. * @param epsilon defines the minimal distance to define values as equals
  57884. * @returns true if both vectors are distant less than epsilon
  57885. */
  57886. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57887. /**
  57888. * Returns true if the current Vector3 coordinates equals the given floats
  57889. * @param x defines the x coordinate of the operand
  57890. * @param y defines the y coordinate of the operand
  57891. * @param z defines the z coordinate of the operand
  57892. * @returns true if both vectors are equals
  57893. */
  57894. equalsToFloats(x: number, y: number, z: number): boolean;
  57895. /**
  57896. * Multiplies the current Vector3 coordinates by the given ones
  57897. * @param otherVector defines the second operand
  57898. * @returns the current updated Vector3
  57899. */
  57900. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57901. /**
  57902. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57903. * @param otherVector defines the second operand
  57904. * @returns the new Vector3
  57905. */
  57906. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57907. /**
  57908. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57909. * @param otherVector defines the second operand
  57910. * @param result defines the Vector3 object where to store the result
  57911. * @returns the current Vector3
  57912. */
  57913. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57914. /**
  57915. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57916. * @param x defines the x coordinate of the operand
  57917. * @param y defines the y coordinate of the operand
  57918. * @param z defines the z coordinate of the operand
  57919. * @returns the new Vector3
  57920. */
  57921. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57922. /**
  57923. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57924. * @param otherVector defines the second operand
  57925. * @returns the new Vector3
  57926. */
  57927. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57928. /**
  57929. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57930. * @param otherVector defines the second operand
  57931. * @param result defines the Vector3 object where to store the result
  57932. * @returns the current Vector3
  57933. */
  57934. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57935. /**
  57936. * Divides the current Vector3 coordinates by the given ones.
  57937. * @param otherVector defines the second operand
  57938. * @returns the current updated Vector3
  57939. */
  57940. divideInPlace(otherVector: Vector3): Vector3;
  57941. /**
  57942. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57943. * @param other defines the second operand
  57944. * @returns the current updated Vector3
  57945. */
  57946. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57947. /**
  57948. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57949. * @param other defines the second operand
  57950. * @returns the current updated Vector3
  57951. */
  57952. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57953. /**
  57954. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57955. * @param x defines the x coordinate of the operand
  57956. * @param y defines the y coordinate of the operand
  57957. * @param z defines the z coordinate of the operand
  57958. * @returns the current updated Vector3
  57959. */
  57960. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57961. /**
  57962. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57963. * @param x defines the x coordinate of the operand
  57964. * @param y defines the y coordinate of the operand
  57965. * @param z defines the z coordinate of the operand
  57966. * @returns the current updated Vector3
  57967. */
  57968. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57969. /**
  57970. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57971. * Check if is non uniform within a certain amount of decimal places to account for this
  57972. * @param epsilon the amount the values can differ
  57973. * @returns if the the vector is non uniform to a certain number of decimal places
  57974. */
  57975. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57976. /**
  57977. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57978. */
  57979. readonly isNonUniform: boolean;
  57980. /**
  57981. * Gets a new Vector3 from current Vector3 floored values
  57982. * @returns a new Vector3
  57983. */
  57984. floor(): Vector3;
  57985. /**
  57986. * Gets a new Vector3 from current Vector3 floored values
  57987. * @returns a new Vector3
  57988. */
  57989. fract(): Vector3;
  57990. /**
  57991. * Gets the length of the Vector3
  57992. * @returns the length of the Vecto3
  57993. */
  57994. length(): number;
  57995. /**
  57996. * Gets the squared length of the Vector3
  57997. * @returns squared length of the Vector3
  57998. */
  57999. lengthSquared(): number;
  58000. /**
  58001. * Normalize the current Vector3.
  58002. * Please note that this is an in place operation.
  58003. * @returns the current updated Vector3
  58004. */
  58005. normalize(): Vector3;
  58006. /**
  58007. * Reorders the x y z properties of the vector in place
  58008. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58009. * @returns the current updated vector
  58010. */
  58011. reorderInPlace(order: string): this;
  58012. /**
  58013. * Rotates the vector around 0,0,0 by a quaternion
  58014. * @param quaternion the rotation quaternion
  58015. * @param result vector to store the result
  58016. * @returns the resulting vector
  58017. */
  58018. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58019. /**
  58020. * Rotates a vector around a given point
  58021. * @param quaternion the rotation quaternion
  58022. * @param point the point to rotate around
  58023. * @param result vector to store the result
  58024. * @returns the resulting vector
  58025. */
  58026. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58027. /**
  58028. * Normalize the current Vector3 with the given input length.
  58029. * Please note that this is an in place operation.
  58030. * @param len the length of the vector
  58031. * @returns the current updated Vector3
  58032. */
  58033. normalizeFromLength(len: number): Vector3;
  58034. /**
  58035. * Normalize the current Vector3 to a new vector
  58036. * @returns the new Vector3
  58037. */
  58038. normalizeToNew(): Vector3;
  58039. /**
  58040. * Normalize the current Vector3 to the reference
  58041. * @param reference define the Vector3 to update
  58042. * @returns the updated Vector3
  58043. */
  58044. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58045. /**
  58046. * Creates a new Vector3 copied from the current Vector3
  58047. * @returns the new Vector3
  58048. */
  58049. clone(): Vector3;
  58050. /**
  58051. * Copies the given vector coordinates to the current Vector3 ones
  58052. * @param source defines the source Vector3
  58053. * @returns the current updated Vector3
  58054. */
  58055. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58056. /**
  58057. * Copies the given floats to the current Vector3 coordinates
  58058. * @param x defines the x coordinate of the operand
  58059. * @param y defines the y coordinate of the operand
  58060. * @param z defines the z coordinate of the operand
  58061. * @returns the current updated Vector3
  58062. */
  58063. copyFromFloats(x: number, y: number, z: number): Vector3;
  58064. /**
  58065. * Copies the given floats to the current Vector3 coordinates
  58066. * @param x defines the x coordinate of the operand
  58067. * @param y defines the y coordinate of the operand
  58068. * @param z defines the z coordinate of the operand
  58069. * @returns the current updated Vector3
  58070. */
  58071. set(x: number, y: number, z: number): Vector3;
  58072. /**
  58073. * Copies the given float to the current Vector3 coordinates
  58074. * @param v defines the x, y and z coordinates of the operand
  58075. * @returns the current updated Vector3
  58076. */
  58077. setAll(v: number): Vector3;
  58078. /**
  58079. * Get the clip factor between two vectors
  58080. * @param vector0 defines the first operand
  58081. * @param vector1 defines the second operand
  58082. * @param axis defines the axis to use
  58083. * @param size defines the size along the axis
  58084. * @returns the clip factor
  58085. */
  58086. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58087. /**
  58088. * Get angle between two vectors
  58089. * @param vector0 angle between vector0 and vector1
  58090. * @param vector1 angle between vector0 and vector1
  58091. * @param normal direction of the normal
  58092. * @return the angle between vector0 and vector1
  58093. */
  58094. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58095. /**
  58096. * Returns a new Vector3 set from the index "offset" of the given array
  58097. * @param array defines the source array
  58098. * @param offset defines the offset in the source array
  58099. * @returns the new Vector3
  58100. */
  58101. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58102. /**
  58103. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58104. * This function is deprecated. Use FromArray instead
  58105. * @param array defines the source array
  58106. * @param offset defines the offset in the source array
  58107. * @returns the new Vector3
  58108. */
  58109. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58110. /**
  58111. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58112. * @param array defines the source array
  58113. * @param offset defines the offset in the source array
  58114. * @param result defines the Vector3 where to store the result
  58115. */
  58116. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58117. /**
  58118. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58119. * This function is deprecated. Use FromArrayToRef instead.
  58120. * @param array defines the source array
  58121. * @param offset defines the offset in the source array
  58122. * @param result defines the Vector3 where to store the result
  58123. */
  58124. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58125. /**
  58126. * Sets the given vector "result" with the given floats.
  58127. * @param x defines the x coordinate of the source
  58128. * @param y defines the y coordinate of the source
  58129. * @param z defines the z coordinate of the source
  58130. * @param result defines the Vector3 where to store the result
  58131. */
  58132. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58133. /**
  58134. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58135. * @returns a new empty Vector3
  58136. */
  58137. static Zero(): Vector3;
  58138. /**
  58139. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58140. * @returns a new unit Vector3
  58141. */
  58142. static One(): Vector3;
  58143. /**
  58144. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58145. * @returns a new up Vector3
  58146. */
  58147. static Up(): Vector3;
  58148. /**
  58149. * Gets a up Vector3 that must not be updated
  58150. */
  58151. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58152. /**
  58153. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58154. * @returns a new down Vector3
  58155. */
  58156. static Down(): Vector3;
  58157. /**
  58158. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58159. * @returns a new forward Vector3
  58160. */
  58161. static Forward(): Vector3;
  58162. /**
  58163. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58164. * @returns a new forward Vector3
  58165. */
  58166. static Backward(): Vector3;
  58167. /**
  58168. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58169. * @returns a new right Vector3
  58170. */
  58171. static Right(): Vector3;
  58172. /**
  58173. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58174. * @returns a new left Vector3
  58175. */
  58176. static Left(): Vector3;
  58177. /**
  58178. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58179. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58180. * @param vector defines the Vector3 to transform
  58181. * @param transformation defines the transformation matrix
  58182. * @returns the transformed Vector3
  58183. */
  58184. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58185. /**
  58186. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58187. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58188. * @param vector defines the Vector3 to transform
  58189. * @param transformation defines the transformation matrix
  58190. * @param result defines the Vector3 where to store the result
  58191. */
  58192. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58193. /**
  58194. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58195. * This method computes tranformed coordinates only, not transformed direction vectors
  58196. * @param x define the x coordinate of the source vector
  58197. * @param y define the y coordinate of the source vector
  58198. * @param z define the z coordinate of the source vector
  58199. * @param transformation defines the transformation matrix
  58200. * @param result defines the Vector3 where to store the result
  58201. */
  58202. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58203. /**
  58204. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58205. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58206. * @param vector defines the Vector3 to transform
  58207. * @param transformation defines the transformation matrix
  58208. * @returns the new Vector3
  58209. */
  58210. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58211. /**
  58212. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58213. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58214. * @param vector defines the Vector3 to transform
  58215. * @param transformation defines the transformation matrix
  58216. * @param result defines the Vector3 where to store the result
  58217. */
  58218. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58219. /**
  58220. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58221. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58222. * @param x define the x coordinate of the source vector
  58223. * @param y define the y coordinate of the source vector
  58224. * @param z define the z coordinate of the source vector
  58225. * @param transformation defines the transformation matrix
  58226. * @param result defines the Vector3 where to store the result
  58227. */
  58228. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58229. /**
  58230. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58231. * @param value1 defines the first control point
  58232. * @param value2 defines the second control point
  58233. * @param value3 defines the third control point
  58234. * @param value4 defines the fourth control point
  58235. * @param amount defines the amount on the spline to use
  58236. * @returns the new Vector3
  58237. */
  58238. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58239. /**
  58240. * 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"
  58241. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58242. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58243. * @param value defines the current value
  58244. * @param min defines the lower range value
  58245. * @param max defines the upper range value
  58246. * @returns the new Vector3
  58247. */
  58248. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58249. /**
  58250. * 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"
  58251. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58252. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58253. * @param value defines the current value
  58254. * @param min defines the lower range value
  58255. * @param max defines the upper range value
  58256. * @param result defines the Vector3 where to store the result
  58257. */
  58258. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58259. /**
  58260. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58261. * @param value1 defines the first control point
  58262. * @param tangent1 defines the first tangent vector
  58263. * @param value2 defines the second control point
  58264. * @param tangent2 defines the second tangent vector
  58265. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58266. * @returns the new Vector3
  58267. */
  58268. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58269. /**
  58270. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58271. * @param start defines the start value
  58272. * @param end defines the end value
  58273. * @param amount max defines amount between both (between 0 and 1)
  58274. * @returns the new Vector3
  58275. */
  58276. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58277. /**
  58278. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58279. * @param start defines the start value
  58280. * @param end defines the end value
  58281. * @param amount max defines amount between both (between 0 and 1)
  58282. * @param result defines the Vector3 where to store the result
  58283. */
  58284. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58285. /**
  58286. * Returns the dot product (float) between the vectors "left" and "right"
  58287. * @param left defines the left operand
  58288. * @param right defines the right operand
  58289. * @returns the dot product
  58290. */
  58291. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58292. /**
  58293. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58294. * The cross product is then orthogonal to both "left" and "right"
  58295. * @param left defines the left operand
  58296. * @param right defines the right operand
  58297. * @returns the cross product
  58298. */
  58299. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58300. /**
  58301. * Sets the given vector "result" with the cross product of "left" and "right"
  58302. * The cross product is then orthogonal to both "left" and "right"
  58303. * @param left defines the left operand
  58304. * @param right defines the right operand
  58305. * @param result defines the Vector3 where to store the result
  58306. */
  58307. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58308. /**
  58309. * Returns a new Vector3 as the normalization of the given vector
  58310. * @param vector defines the Vector3 to normalize
  58311. * @returns the new Vector3
  58312. */
  58313. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58314. /**
  58315. * Sets the given vector "result" with the normalization of the given first vector
  58316. * @param vector defines the Vector3 to normalize
  58317. * @param result defines the Vector3 where to store the result
  58318. */
  58319. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58320. /**
  58321. * Project a Vector3 onto screen space
  58322. * @param vector defines the Vector3 to project
  58323. * @param world defines the world matrix to use
  58324. * @param transform defines the transform (view x projection) matrix to use
  58325. * @param viewport defines the screen viewport to use
  58326. * @returns the new Vector3
  58327. */
  58328. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58329. /** @hidden */
  58330. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58331. /**
  58332. * Unproject from screen space to object space
  58333. * @param source defines the screen space Vector3 to use
  58334. * @param viewportWidth defines the current width of the viewport
  58335. * @param viewportHeight defines the current height of the viewport
  58336. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58337. * @param transform defines the transform (view x projection) matrix to use
  58338. * @returns the new Vector3
  58339. */
  58340. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58341. /**
  58342. * Unproject from screen space to object space
  58343. * @param source defines the screen space Vector3 to use
  58344. * @param viewportWidth defines the current width of the viewport
  58345. * @param viewportHeight defines the current height of the viewport
  58346. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58347. * @param view defines the view matrix to use
  58348. * @param projection defines the projection matrix to use
  58349. * @returns the new Vector3
  58350. */
  58351. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58352. /**
  58353. * Unproject from screen space to object space
  58354. * @param source defines the screen space Vector3 to use
  58355. * @param viewportWidth defines the current width of the viewport
  58356. * @param viewportHeight defines the current height of the viewport
  58357. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58358. * @param view defines the view matrix to use
  58359. * @param projection defines the projection matrix to use
  58360. * @param result defines the Vector3 where to store the result
  58361. */
  58362. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58363. /**
  58364. * Unproject from screen space to object space
  58365. * @param sourceX defines the screen space x coordinate to use
  58366. * @param sourceY defines the screen space y coordinate to use
  58367. * @param sourceZ defines the screen space z coordinate to use
  58368. * @param viewportWidth defines the current width of the viewport
  58369. * @param viewportHeight defines the current height of the viewport
  58370. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58371. * @param view defines the view matrix to use
  58372. * @param projection defines the projection matrix to use
  58373. * @param result defines the Vector3 where to store the result
  58374. */
  58375. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58376. /**
  58377. * Gets the minimal coordinate values between two Vector3
  58378. * @param left defines the first operand
  58379. * @param right defines the second operand
  58380. * @returns the new Vector3
  58381. */
  58382. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58383. /**
  58384. * Gets the maximal coordinate values between two Vector3
  58385. * @param left defines the first operand
  58386. * @param right defines the second operand
  58387. * @returns the new Vector3
  58388. */
  58389. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58390. /**
  58391. * Returns the distance between the vectors "value1" and "value2"
  58392. * @param value1 defines the first operand
  58393. * @param value2 defines the second operand
  58394. * @returns the distance
  58395. */
  58396. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58397. /**
  58398. * Returns the squared distance between the vectors "value1" and "value2"
  58399. * @param value1 defines the first operand
  58400. * @param value2 defines the second operand
  58401. * @returns the squared distance
  58402. */
  58403. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58404. /**
  58405. * Returns a new Vector3 located at the center between "value1" and "value2"
  58406. * @param value1 defines the first operand
  58407. * @param value2 defines the second operand
  58408. * @returns the new Vector3
  58409. */
  58410. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58411. /**
  58412. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58413. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58414. * to something in order to rotate it from its local system to the given target system
  58415. * Note: axis1, axis2 and axis3 are normalized during this operation
  58416. * @param axis1 defines the first axis
  58417. * @param axis2 defines the second axis
  58418. * @param axis3 defines the third axis
  58419. * @returns a new Vector3
  58420. */
  58421. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58422. /**
  58423. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58424. * @param axis1 defines the first axis
  58425. * @param axis2 defines the second axis
  58426. * @param axis3 defines the third axis
  58427. * @param ref defines the Vector3 where to store the result
  58428. */
  58429. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58430. }
  58431. /**
  58432. * Vector4 class created for EulerAngle class conversion to Quaternion
  58433. */
  58434. export class Vector4 {
  58435. /** x value of the vector */
  58436. x: number;
  58437. /** y value of the vector */
  58438. y: number;
  58439. /** z value of the vector */
  58440. z: number;
  58441. /** w value of the vector */
  58442. w: number;
  58443. /**
  58444. * Creates a Vector4 object from the given floats.
  58445. * @param x x value of the vector
  58446. * @param y y value of the vector
  58447. * @param z z value of the vector
  58448. * @param w w value of the vector
  58449. */
  58450. constructor(
  58451. /** x value of the vector */
  58452. x: number,
  58453. /** y value of the vector */
  58454. y: number,
  58455. /** z value of the vector */
  58456. z: number,
  58457. /** w value of the vector */
  58458. w: number);
  58459. /**
  58460. * Returns the string with the Vector4 coordinates.
  58461. * @returns a string containing all the vector values
  58462. */
  58463. toString(): string;
  58464. /**
  58465. * Returns the string "Vector4".
  58466. * @returns "Vector4"
  58467. */
  58468. getClassName(): string;
  58469. /**
  58470. * Returns the Vector4 hash code.
  58471. * @returns a unique hash code
  58472. */
  58473. getHashCode(): number;
  58474. /**
  58475. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58476. * @returns the resulting array
  58477. */
  58478. asArray(): number[];
  58479. /**
  58480. * Populates the given array from the given index with the Vector4 coordinates.
  58481. * @param array array to populate
  58482. * @param index index of the array to start at (default: 0)
  58483. * @returns the Vector4.
  58484. */
  58485. toArray(array: FloatArray, index?: number): Vector4;
  58486. /**
  58487. * Adds the given vector to the current Vector4.
  58488. * @param otherVector the vector to add
  58489. * @returns the updated Vector4.
  58490. */
  58491. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58492. /**
  58493. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58494. * @param otherVector the vector to add
  58495. * @returns the resulting vector
  58496. */
  58497. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58498. /**
  58499. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58500. * @param otherVector the vector to add
  58501. * @param result the vector to store the result
  58502. * @returns the current Vector4.
  58503. */
  58504. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58505. /**
  58506. * Subtract in place the given vector from the current Vector4.
  58507. * @param otherVector the vector to subtract
  58508. * @returns the updated Vector4.
  58509. */
  58510. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58511. /**
  58512. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58513. * @param otherVector the vector to add
  58514. * @returns the new vector with the result
  58515. */
  58516. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58517. /**
  58518. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58519. * @param otherVector the vector to subtract
  58520. * @param result the vector to store the result
  58521. * @returns the current Vector4.
  58522. */
  58523. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58524. /**
  58525. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58526. */
  58527. /**
  58528. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58529. * @param x value to subtract
  58530. * @param y value to subtract
  58531. * @param z value to subtract
  58532. * @param w value to subtract
  58533. * @returns new vector containing the result
  58534. */
  58535. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58536. /**
  58537. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58538. * @param x value to subtract
  58539. * @param y value to subtract
  58540. * @param z value to subtract
  58541. * @param w value to subtract
  58542. * @param result the vector to store the result in
  58543. * @returns the current Vector4.
  58544. */
  58545. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58546. /**
  58547. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58548. * @returns a new vector with the negated values
  58549. */
  58550. negate(): Vector4;
  58551. /**
  58552. * Multiplies the current Vector4 coordinates by scale (float).
  58553. * @param scale the number to scale with
  58554. * @returns the updated Vector4.
  58555. */
  58556. scaleInPlace(scale: number): Vector4;
  58557. /**
  58558. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58559. * @param scale the number to scale with
  58560. * @returns a new vector with the result
  58561. */
  58562. scale(scale: number): Vector4;
  58563. /**
  58564. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58565. * @param scale the number to scale with
  58566. * @param result a vector to store the result in
  58567. * @returns the current Vector4.
  58568. */
  58569. scaleToRef(scale: number, result: Vector4): Vector4;
  58570. /**
  58571. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58572. * @param scale defines the scale factor
  58573. * @param result defines the Vector4 object where to store the result
  58574. * @returns the unmodified current Vector4
  58575. */
  58576. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58577. /**
  58578. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58579. * @param otherVector the vector to compare against
  58580. * @returns true if they are equal
  58581. */
  58582. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58583. /**
  58584. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58585. * @param otherVector vector to compare against
  58586. * @param epsilon (Default: very small number)
  58587. * @returns true if they are equal
  58588. */
  58589. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58590. /**
  58591. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58592. * @param x x value to compare against
  58593. * @param y y value to compare against
  58594. * @param z z value to compare against
  58595. * @param w w value to compare against
  58596. * @returns true if equal
  58597. */
  58598. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58599. /**
  58600. * Multiplies in place the current Vector4 by the given one.
  58601. * @param otherVector vector to multiple with
  58602. * @returns the updated Vector4.
  58603. */
  58604. multiplyInPlace(otherVector: Vector4): Vector4;
  58605. /**
  58606. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58607. * @param otherVector vector to multiple with
  58608. * @returns resulting new vector
  58609. */
  58610. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58611. /**
  58612. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58613. * @param otherVector vector to multiple with
  58614. * @param result vector to store the result
  58615. * @returns the current Vector4.
  58616. */
  58617. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58618. /**
  58619. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58620. * @param x x value multiply with
  58621. * @param y y value multiply with
  58622. * @param z z value multiply with
  58623. * @param w w value multiply with
  58624. * @returns resulting new vector
  58625. */
  58626. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58627. /**
  58628. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58629. * @param otherVector vector to devide with
  58630. * @returns resulting new vector
  58631. */
  58632. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58633. /**
  58634. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58635. * @param otherVector vector to devide with
  58636. * @param result vector to store the result
  58637. * @returns the current Vector4.
  58638. */
  58639. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58640. /**
  58641. * Divides the current Vector3 coordinates by the given ones.
  58642. * @param otherVector vector to devide with
  58643. * @returns the updated Vector3.
  58644. */
  58645. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58646. /**
  58647. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58648. * @param other defines the second operand
  58649. * @returns the current updated Vector4
  58650. */
  58651. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58652. /**
  58653. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58654. * @param other defines the second operand
  58655. * @returns the current updated Vector4
  58656. */
  58657. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58658. /**
  58659. * Gets a new Vector4 from current Vector4 floored values
  58660. * @returns a new Vector4
  58661. */
  58662. floor(): Vector4;
  58663. /**
  58664. * Gets a new Vector4 from current Vector3 floored values
  58665. * @returns a new Vector4
  58666. */
  58667. fract(): Vector4;
  58668. /**
  58669. * Returns the Vector4 length (float).
  58670. * @returns the length
  58671. */
  58672. length(): number;
  58673. /**
  58674. * Returns the Vector4 squared length (float).
  58675. * @returns the length squared
  58676. */
  58677. lengthSquared(): number;
  58678. /**
  58679. * Normalizes in place the Vector4.
  58680. * @returns the updated Vector4.
  58681. */
  58682. normalize(): Vector4;
  58683. /**
  58684. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58685. * @returns this converted to a new vector3
  58686. */
  58687. toVector3(): Vector3;
  58688. /**
  58689. * Returns a new Vector4 copied from the current one.
  58690. * @returns the new cloned vector
  58691. */
  58692. clone(): Vector4;
  58693. /**
  58694. * Updates the current Vector4 with the given one coordinates.
  58695. * @param source the source vector to copy from
  58696. * @returns the updated Vector4.
  58697. */
  58698. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58699. /**
  58700. * Updates the current Vector4 coordinates with the given floats.
  58701. * @param x float to copy from
  58702. * @param y float to copy from
  58703. * @param z float to copy from
  58704. * @param w float to copy from
  58705. * @returns the updated Vector4.
  58706. */
  58707. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58708. /**
  58709. * Updates the current Vector4 coordinates with the given floats.
  58710. * @param x float to set from
  58711. * @param y float to set from
  58712. * @param z float to set from
  58713. * @param w float to set from
  58714. * @returns the updated Vector4.
  58715. */
  58716. set(x: number, y: number, z: number, w: number): Vector4;
  58717. /**
  58718. * Copies the given float to the current Vector3 coordinates
  58719. * @param v defines the x, y, z and w coordinates of the operand
  58720. * @returns the current updated Vector3
  58721. */
  58722. setAll(v: number): Vector4;
  58723. /**
  58724. * Returns a new Vector4 set from the starting index of the given array.
  58725. * @param array the array to pull values from
  58726. * @param offset the offset into the array to start at
  58727. * @returns the new vector
  58728. */
  58729. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58730. /**
  58731. * Updates the given vector "result" from the starting index of the given array.
  58732. * @param array the array to pull values from
  58733. * @param offset the offset into the array to start at
  58734. * @param result the vector to store the result in
  58735. */
  58736. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58737. /**
  58738. * Updates the given vector "result" from the starting index of the given Float32Array.
  58739. * @param array the array to pull values from
  58740. * @param offset the offset into the array to start at
  58741. * @param result the vector to store the result in
  58742. */
  58743. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58744. /**
  58745. * Updates the given vector "result" coordinates from the given floats.
  58746. * @param x float to set from
  58747. * @param y float to set from
  58748. * @param z float to set from
  58749. * @param w float to set from
  58750. * @param result the vector to the floats in
  58751. */
  58752. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58753. /**
  58754. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58755. * @returns the new vector
  58756. */
  58757. static Zero(): Vector4;
  58758. /**
  58759. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58760. * @returns the new vector
  58761. */
  58762. static One(): Vector4;
  58763. /**
  58764. * Returns a new normalized Vector4 from the given one.
  58765. * @param vector the vector to normalize
  58766. * @returns the vector
  58767. */
  58768. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58769. /**
  58770. * Updates the given vector "result" from the normalization of the given one.
  58771. * @param vector the vector to normalize
  58772. * @param result the vector to store the result in
  58773. */
  58774. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58775. /**
  58776. * Returns a vector with the minimum values from the left and right vectors
  58777. * @param left left vector to minimize
  58778. * @param right right vector to minimize
  58779. * @returns a new vector with the minimum of the left and right vector values
  58780. */
  58781. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58782. /**
  58783. * Returns a vector with the maximum values from the left and right vectors
  58784. * @param left left vector to maximize
  58785. * @param right right vector to maximize
  58786. * @returns a new vector with the maximum of the left and right vector values
  58787. */
  58788. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58789. /**
  58790. * Returns the distance (float) between the vectors "value1" and "value2".
  58791. * @param value1 value to calulate the distance between
  58792. * @param value2 value to calulate the distance between
  58793. * @return the distance between the two vectors
  58794. */
  58795. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58796. /**
  58797. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58798. * @param value1 value to calulate the distance between
  58799. * @param value2 value to calulate the distance between
  58800. * @return the distance between the two vectors squared
  58801. */
  58802. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58803. /**
  58804. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58805. * @param value1 value to calulate the center between
  58806. * @param value2 value to calulate the center between
  58807. * @return the center between the two vectors
  58808. */
  58809. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58810. /**
  58811. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58812. * This methods computes transformed normalized direction vectors only.
  58813. * @param vector the vector to transform
  58814. * @param transformation the transformation matrix to apply
  58815. * @returns the new vector
  58816. */
  58817. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58818. /**
  58819. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58820. * This methods computes transformed normalized direction vectors only.
  58821. * @param vector the vector to transform
  58822. * @param transformation the transformation matrix to apply
  58823. * @param result the vector to store the result in
  58824. */
  58825. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58826. /**
  58827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58828. * This methods computes transformed normalized direction vectors only.
  58829. * @param x value to transform
  58830. * @param y value to transform
  58831. * @param z value to transform
  58832. * @param w value to transform
  58833. * @param transformation the transformation matrix to apply
  58834. * @param result the vector to store the results in
  58835. */
  58836. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58837. /**
  58838. * Creates a new Vector4 from a Vector3
  58839. * @param source defines the source data
  58840. * @param w defines the 4th component (default is 0)
  58841. * @returns a new Vector4
  58842. */
  58843. static FromVector3(source: Vector3, w?: number): Vector4;
  58844. }
  58845. /**
  58846. * Interface for the size containing width and height
  58847. */
  58848. export interface ISize {
  58849. /**
  58850. * Width
  58851. */
  58852. width: number;
  58853. /**
  58854. * Heighht
  58855. */
  58856. height: number;
  58857. }
  58858. /**
  58859. * Size containing widht and height
  58860. */
  58861. export class Size implements ISize {
  58862. /**
  58863. * Width
  58864. */
  58865. width: number;
  58866. /**
  58867. * Height
  58868. */
  58869. height: number;
  58870. /**
  58871. * Creates a Size object from the given width and height (floats).
  58872. * @param width width of the new size
  58873. * @param height height of the new size
  58874. */
  58875. constructor(width: number, height: number);
  58876. /**
  58877. * Returns a string with the Size width and height
  58878. * @returns a string with the Size width and height
  58879. */
  58880. toString(): string;
  58881. /**
  58882. * "Size"
  58883. * @returns the string "Size"
  58884. */
  58885. getClassName(): string;
  58886. /**
  58887. * Returns the Size hash code.
  58888. * @returns a hash code for a unique width and height
  58889. */
  58890. getHashCode(): number;
  58891. /**
  58892. * Updates the current size from the given one.
  58893. * @param src the given size
  58894. */
  58895. copyFrom(src: Size): void;
  58896. /**
  58897. * Updates in place the current Size from the given floats.
  58898. * @param width width of the new size
  58899. * @param height height of the new size
  58900. * @returns the updated Size.
  58901. */
  58902. copyFromFloats(width: number, height: number): Size;
  58903. /**
  58904. * Updates in place the current Size from the given floats.
  58905. * @param width width to set
  58906. * @param height height to set
  58907. * @returns the updated Size.
  58908. */
  58909. set(width: number, height: number): Size;
  58910. /**
  58911. * Multiplies the width and height by numbers
  58912. * @param w factor to multiple the width by
  58913. * @param h factor to multiple the height by
  58914. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58915. */
  58916. multiplyByFloats(w: number, h: number): Size;
  58917. /**
  58918. * Clones the size
  58919. * @returns a new Size copied from the given one.
  58920. */
  58921. clone(): Size;
  58922. /**
  58923. * True if the current Size and the given one width and height are strictly equal.
  58924. * @param other the other size to compare against
  58925. * @returns True if the current Size and the given one width and height are strictly equal.
  58926. */
  58927. equals(other: Size): boolean;
  58928. /**
  58929. * The surface of the Size : width * height (float).
  58930. */
  58931. readonly surface: number;
  58932. /**
  58933. * Create a new size of zero
  58934. * @returns a new Size set to (0.0, 0.0)
  58935. */
  58936. static Zero(): Size;
  58937. /**
  58938. * Sums the width and height of two sizes
  58939. * @param otherSize size to add to this size
  58940. * @returns a new Size set as the addition result of the current Size and the given one.
  58941. */
  58942. add(otherSize: Size): Size;
  58943. /**
  58944. * Subtracts the width and height of two
  58945. * @param otherSize size to subtract to this size
  58946. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58947. */
  58948. subtract(otherSize: Size): Size;
  58949. /**
  58950. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58951. * @param start starting size to lerp between
  58952. * @param end end size to lerp between
  58953. * @param amount amount to lerp between the start and end values
  58954. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58955. */
  58956. static Lerp(start: Size, end: Size, amount: number): Size;
  58957. }
  58958. /**
  58959. * Class used to store quaternion data
  58960. * @see https://en.wikipedia.org/wiki/Quaternion
  58961. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58962. */
  58963. export class Quaternion {
  58964. /** defines the first component (0 by default) */
  58965. x: number;
  58966. /** defines the second component (0 by default) */
  58967. y: number;
  58968. /** defines the third component (0 by default) */
  58969. z: number;
  58970. /** defines the fourth component (1.0 by default) */
  58971. w: number;
  58972. /**
  58973. * Creates a new Quaternion from the given floats
  58974. * @param x defines the first component (0 by default)
  58975. * @param y defines the second component (0 by default)
  58976. * @param z defines the third component (0 by default)
  58977. * @param w defines the fourth component (1.0 by default)
  58978. */
  58979. constructor(
  58980. /** defines the first component (0 by default) */
  58981. x?: number,
  58982. /** defines the second component (0 by default) */
  58983. y?: number,
  58984. /** defines the third component (0 by default) */
  58985. z?: number,
  58986. /** defines the fourth component (1.0 by default) */
  58987. w?: number);
  58988. /**
  58989. * Gets a string representation for the current quaternion
  58990. * @returns a string with the Quaternion coordinates
  58991. */
  58992. toString(): string;
  58993. /**
  58994. * Gets the class name of the quaternion
  58995. * @returns the string "Quaternion"
  58996. */
  58997. getClassName(): string;
  58998. /**
  58999. * Gets a hash code for this quaternion
  59000. * @returns the quaternion hash code
  59001. */
  59002. getHashCode(): number;
  59003. /**
  59004. * Copy the quaternion to an array
  59005. * @returns a new array populated with 4 elements from the quaternion coordinates
  59006. */
  59007. asArray(): number[];
  59008. /**
  59009. * Check if two quaternions are equals
  59010. * @param otherQuaternion defines the second operand
  59011. * @return true if the current quaternion and the given one coordinates are strictly equals
  59012. */
  59013. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59014. /**
  59015. * Clone the current quaternion
  59016. * @returns a new quaternion copied from the current one
  59017. */
  59018. clone(): Quaternion;
  59019. /**
  59020. * Copy a quaternion to the current one
  59021. * @param other defines the other quaternion
  59022. * @returns the updated current quaternion
  59023. */
  59024. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59025. /**
  59026. * Updates the current quaternion with the given float coordinates
  59027. * @param x defines the x coordinate
  59028. * @param y defines the y coordinate
  59029. * @param z defines the z coordinate
  59030. * @param w defines the w coordinate
  59031. * @returns the updated current quaternion
  59032. */
  59033. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59034. /**
  59035. * Updates the current quaternion from the given float coordinates
  59036. * @param x defines the x coordinate
  59037. * @param y defines the y coordinate
  59038. * @param z defines the z coordinate
  59039. * @param w defines the w coordinate
  59040. * @returns the updated current quaternion
  59041. */
  59042. set(x: number, y: number, z: number, w: number): Quaternion;
  59043. /**
  59044. * Adds two quaternions
  59045. * @param other defines the second operand
  59046. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59047. */
  59048. add(other: DeepImmutable<Quaternion>): Quaternion;
  59049. /**
  59050. * Add a quaternion to the current one
  59051. * @param other defines the quaternion to add
  59052. * @returns the current quaternion
  59053. */
  59054. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59055. /**
  59056. * Subtract two quaternions
  59057. * @param other defines the second operand
  59058. * @returns a new quaternion as the subtraction result of the given one from the current one
  59059. */
  59060. subtract(other: Quaternion): Quaternion;
  59061. /**
  59062. * Multiplies the current quaternion by a scale factor
  59063. * @param value defines the scale factor
  59064. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59065. */
  59066. scale(value: number): Quaternion;
  59067. /**
  59068. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59069. * @param scale defines the scale factor
  59070. * @param result defines the Quaternion object where to store the result
  59071. * @returns the unmodified current quaternion
  59072. */
  59073. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59074. /**
  59075. * Multiplies in place the current quaternion by a scale factor
  59076. * @param value defines the scale factor
  59077. * @returns the current modified quaternion
  59078. */
  59079. scaleInPlace(value: number): Quaternion;
  59080. /**
  59081. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59082. * @param scale defines the scale factor
  59083. * @param result defines the Quaternion object where to store the result
  59084. * @returns the unmodified current quaternion
  59085. */
  59086. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59087. /**
  59088. * Multiplies two quaternions
  59089. * @param q1 defines the second operand
  59090. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59091. */
  59092. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59093. /**
  59094. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59095. * @param q1 defines the second operand
  59096. * @param result defines the target quaternion
  59097. * @returns the current quaternion
  59098. */
  59099. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59100. /**
  59101. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59102. * @param q1 defines the second operand
  59103. * @returns the currentupdated quaternion
  59104. */
  59105. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59106. /**
  59107. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59108. * @param ref defines the target quaternion
  59109. * @returns the current quaternion
  59110. */
  59111. conjugateToRef(ref: Quaternion): Quaternion;
  59112. /**
  59113. * Conjugates in place (1-q) the current quaternion
  59114. * @returns the current updated quaternion
  59115. */
  59116. conjugateInPlace(): Quaternion;
  59117. /**
  59118. * Conjugates in place (1-q) the current quaternion
  59119. * @returns a new quaternion
  59120. */
  59121. conjugate(): Quaternion;
  59122. /**
  59123. * Gets length of current quaternion
  59124. * @returns the quaternion length (float)
  59125. */
  59126. length(): number;
  59127. /**
  59128. * Normalize in place the current quaternion
  59129. * @returns the current updated quaternion
  59130. */
  59131. normalize(): Quaternion;
  59132. /**
  59133. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59134. * @param order is a reserved parameter and is ignore for now
  59135. * @returns a new Vector3 containing the Euler angles
  59136. */
  59137. toEulerAngles(order?: string): Vector3;
  59138. /**
  59139. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59140. * @param result defines the vector which will be filled with the Euler angles
  59141. * @param order is a reserved parameter and is ignore for now
  59142. * @returns the current unchanged quaternion
  59143. */
  59144. toEulerAnglesToRef(result: Vector3): Quaternion;
  59145. /**
  59146. * Updates the given rotation matrix with the current quaternion values
  59147. * @param result defines the target matrix
  59148. * @returns the current unchanged quaternion
  59149. */
  59150. toRotationMatrix(result: Matrix): Quaternion;
  59151. /**
  59152. * Updates the current quaternion from the given rotation matrix values
  59153. * @param matrix defines the source matrix
  59154. * @returns the current updated quaternion
  59155. */
  59156. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59157. /**
  59158. * Creates a new quaternion from a rotation matrix
  59159. * @param matrix defines the source matrix
  59160. * @returns a new quaternion created from the given rotation matrix values
  59161. */
  59162. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59163. /**
  59164. * Updates the given quaternion with the given rotation matrix values
  59165. * @param matrix defines the source matrix
  59166. * @param result defines the target quaternion
  59167. */
  59168. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59169. /**
  59170. * Returns the dot product (float) between the quaternions "left" and "right"
  59171. * @param left defines the left operand
  59172. * @param right defines the right operand
  59173. * @returns the dot product
  59174. */
  59175. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59176. /**
  59177. * Checks if the two quaternions are close to each other
  59178. * @param quat0 defines the first quaternion to check
  59179. * @param quat1 defines the second quaternion to check
  59180. * @returns true if the two quaternions are close to each other
  59181. */
  59182. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59183. /**
  59184. * Creates an empty quaternion
  59185. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59186. */
  59187. static Zero(): Quaternion;
  59188. /**
  59189. * Inverse a given quaternion
  59190. * @param q defines the source quaternion
  59191. * @returns a new quaternion as the inverted current quaternion
  59192. */
  59193. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59194. /**
  59195. * Inverse a given quaternion
  59196. * @param q defines the source quaternion
  59197. * @param result the quaternion the result will be stored in
  59198. * @returns the result quaternion
  59199. */
  59200. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59201. /**
  59202. * Creates an identity quaternion
  59203. * @returns the identity quaternion
  59204. */
  59205. static Identity(): Quaternion;
  59206. /**
  59207. * Gets a boolean indicating if the given quaternion is identity
  59208. * @param quaternion defines the quaternion to check
  59209. * @returns true if the quaternion is identity
  59210. */
  59211. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59212. /**
  59213. * Creates a quaternion from a rotation around an axis
  59214. * @param axis defines the axis to use
  59215. * @param angle defines the angle to use
  59216. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59217. */
  59218. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59219. /**
  59220. * Creates a rotation around an axis and stores it into the given quaternion
  59221. * @param axis defines the axis to use
  59222. * @param angle defines the angle to use
  59223. * @param result defines the target quaternion
  59224. * @returns the target quaternion
  59225. */
  59226. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59227. /**
  59228. * Creates a new quaternion from data stored into an array
  59229. * @param array defines the data source
  59230. * @param offset defines the offset in the source array where the data starts
  59231. * @returns a new quaternion
  59232. */
  59233. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59234. /**
  59235. * Create a quaternion from Euler rotation angles
  59236. * @param x Pitch
  59237. * @param y Yaw
  59238. * @param z Roll
  59239. * @returns the new Quaternion
  59240. */
  59241. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59242. /**
  59243. * Updates a quaternion from Euler rotation angles
  59244. * @param x Pitch
  59245. * @param y Yaw
  59246. * @param z Roll
  59247. * @param result the quaternion to store the result
  59248. * @returns the updated quaternion
  59249. */
  59250. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59251. /**
  59252. * Create a quaternion from Euler rotation vector
  59253. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59254. * @returns the new Quaternion
  59255. */
  59256. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59257. /**
  59258. * Updates a quaternion from Euler rotation vector
  59259. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59260. * @param result the quaternion to store the result
  59261. * @returns the updated quaternion
  59262. */
  59263. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59264. /**
  59265. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59266. * @param yaw defines the rotation around Y axis
  59267. * @param pitch defines the rotation around X axis
  59268. * @param roll defines the rotation around Z axis
  59269. * @returns the new quaternion
  59270. */
  59271. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59272. /**
  59273. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59274. * @param yaw defines the rotation around Y axis
  59275. * @param pitch defines the rotation around X axis
  59276. * @param roll defines the rotation around Z axis
  59277. * @param result defines the target quaternion
  59278. */
  59279. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59280. /**
  59281. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59282. * @param alpha defines the rotation around first axis
  59283. * @param beta defines the rotation around second axis
  59284. * @param gamma defines the rotation around third axis
  59285. * @returns the new quaternion
  59286. */
  59287. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59288. /**
  59289. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59290. * @param alpha defines the rotation around first axis
  59291. * @param beta defines the rotation around second axis
  59292. * @param gamma defines the rotation around third axis
  59293. * @param result defines the target quaternion
  59294. */
  59295. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59296. /**
  59297. * 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)
  59298. * @param axis1 defines the first axis
  59299. * @param axis2 defines the second axis
  59300. * @param axis3 defines the third axis
  59301. * @returns the new quaternion
  59302. */
  59303. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59304. /**
  59305. * 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
  59306. * @param axis1 defines the first axis
  59307. * @param axis2 defines the second axis
  59308. * @param axis3 defines the third axis
  59309. * @param ref defines the target quaternion
  59310. */
  59311. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59312. /**
  59313. * Interpolates between two quaternions
  59314. * @param left defines first quaternion
  59315. * @param right defines second quaternion
  59316. * @param amount defines the gradient to use
  59317. * @returns the new interpolated quaternion
  59318. */
  59319. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59320. /**
  59321. * Interpolates between two quaternions and stores it into a target quaternion
  59322. * @param left defines first quaternion
  59323. * @param right defines second quaternion
  59324. * @param amount defines the gradient to use
  59325. * @param result defines the target quaternion
  59326. */
  59327. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59328. /**
  59329. * Interpolate between two quaternions using Hermite interpolation
  59330. * @param value1 defines first quaternion
  59331. * @param tangent1 defines the incoming tangent
  59332. * @param value2 defines second quaternion
  59333. * @param tangent2 defines the outgoing tangent
  59334. * @param amount defines the target quaternion
  59335. * @returns the new interpolated quaternion
  59336. */
  59337. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59338. }
  59339. /**
  59340. * Class used to store matrix data (4x4)
  59341. */
  59342. export class Matrix {
  59343. private static _updateFlagSeed;
  59344. private static _identityReadOnly;
  59345. private _isIdentity;
  59346. private _isIdentityDirty;
  59347. private _isIdentity3x2;
  59348. private _isIdentity3x2Dirty;
  59349. /**
  59350. * Gets the update flag of the matrix which is an unique number for the matrix.
  59351. * It will be incremented every time the matrix data change.
  59352. * You can use it to speed the comparison between two versions of the same matrix.
  59353. */
  59354. updateFlag: number;
  59355. private readonly _m;
  59356. /**
  59357. * Gets the internal data of the matrix
  59358. */
  59359. readonly m: DeepImmutable<Float32Array>;
  59360. /** @hidden */
  59361. _markAsUpdated(): void;
  59362. /** @hidden */
  59363. private _updateIdentityStatus;
  59364. /**
  59365. * Creates an empty matrix (filled with zeros)
  59366. */
  59367. constructor();
  59368. /**
  59369. * Check if the current matrix is identity
  59370. * @returns true is the matrix is the identity matrix
  59371. */
  59372. isIdentity(): boolean;
  59373. /**
  59374. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59375. * @returns true is the matrix is the identity matrix
  59376. */
  59377. isIdentityAs3x2(): boolean;
  59378. /**
  59379. * Gets the determinant of the matrix
  59380. * @returns the matrix determinant
  59381. */
  59382. determinant(): number;
  59383. /**
  59384. * Returns the matrix as a Float32Array
  59385. * @returns the matrix underlying array
  59386. */
  59387. toArray(): DeepImmutable<Float32Array>;
  59388. /**
  59389. * Returns the matrix as a Float32Array
  59390. * @returns the matrix underlying array.
  59391. */
  59392. asArray(): DeepImmutable<Float32Array>;
  59393. /**
  59394. * Inverts the current matrix in place
  59395. * @returns the current inverted matrix
  59396. */
  59397. invert(): Matrix;
  59398. /**
  59399. * Sets all the matrix elements to zero
  59400. * @returns the current matrix
  59401. */
  59402. reset(): Matrix;
  59403. /**
  59404. * Adds the current matrix with a second one
  59405. * @param other defines the matrix to add
  59406. * @returns a new matrix as the addition of the current matrix and the given one
  59407. */
  59408. add(other: DeepImmutable<Matrix>): Matrix;
  59409. /**
  59410. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59411. * @param other defines the matrix to add
  59412. * @param result defines the target matrix
  59413. * @returns the current matrix
  59414. */
  59415. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59416. /**
  59417. * Adds in place the given matrix to the current matrix
  59418. * @param other defines the second operand
  59419. * @returns the current updated matrix
  59420. */
  59421. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59422. /**
  59423. * Sets the given matrix to the current inverted Matrix
  59424. * @param other defines the target matrix
  59425. * @returns the unmodified current matrix
  59426. */
  59427. invertToRef(other: Matrix): Matrix;
  59428. /**
  59429. * add a value at the specified position in the current Matrix
  59430. * @param index the index of the value within the matrix. between 0 and 15.
  59431. * @param value the value to be added
  59432. * @returns the current updated matrix
  59433. */
  59434. addAtIndex(index: number, value: number): Matrix;
  59435. /**
  59436. * mutiply the specified position in the current Matrix by a value
  59437. * @param index the index of the value within the matrix. between 0 and 15.
  59438. * @param value the value to be added
  59439. * @returns the current updated matrix
  59440. */
  59441. multiplyAtIndex(index: number, value: number): Matrix;
  59442. /**
  59443. * Inserts the translation vector (using 3 floats) in the current matrix
  59444. * @param x defines the 1st component of the translation
  59445. * @param y defines the 2nd component of the translation
  59446. * @param z defines the 3rd component of the translation
  59447. * @returns the current updated matrix
  59448. */
  59449. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59450. /**
  59451. * Inserts the translation vector in the current matrix
  59452. * @param vector3 defines the translation to insert
  59453. * @returns the current updated matrix
  59454. */
  59455. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59456. /**
  59457. * Gets the translation value of the current matrix
  59458. * @returns a new Vector3 as the extracted translation from the matrix
  59459. */
  59460. getTranslation(): Vector3;
  59461. /**
  59462. * Fill a Vector3 with the extracted translation from the matrix
  59463. * @param result defines the Vector3 where to store the translation
  59464. * @returns the current matrix
  59465. */
  59466. getTranslationToRef(result: Vector3): Matrix;
  59467. /**
  59468. * Remove rotation and scaling part from the matrix
  59469. * @returns the updated matrix
  59470. */
  59471. removeRotationAndScaling(): Matrix;
  59472. /**
  59473. * Multiply two matrices
  59474. * @param other defines the second operand
  59475. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59476. */
  59477. multiply(other: DeepImmutable<Matrix>): Matrix;
  59478. /**
  59479. * Copy the current matrix from the given one
  59480. * @param other defines the source matrix
  59481. * @returns the current updated matrix
  59482. */
  59483. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59484. /**
  59485. * Populates the given array from the starting index with the current matrix values
  59486. * @param array defines the target array
  59487. * @param offset defines the offset in the target array where to start storing values
  59488. * @returns the current matrix
  59489. */
  59490. copyToArray(array: Float32Array, offset?: number): Matrix;
  59491. /**
  59492. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59493. * @param other defines the second operand
  59494. * @param result defines the matrix where to store the multiplication
  59495. * @returns the current matrix
  59496. */
  59497. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59498. /**
  59499. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59500. * @param other defines the second operand
  59501. * @param result defines the array where to store the multiplication
  59502. * @param offset defines the offset in the target array where to start storing values
  59503. * @returns the current matrix
  59504. */
  59505. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59506. /**
  59507. * Check equality between this matrix and a second one
  59508. * @param value defines the second matrix to compare
  59509. * @returns true is the current matrix and the given one values are strictly equal
  59510. */
  59511. equals(value: DeepImmutable<Matrix>): boolean;
  59512. /**
  59513. * Clone the current matrix
  59514. * @returns a new matrix from the current matrix
  59515. */
  59516. clone(): Matrix;
  59517. /**
  59518. * Returns the name of the current matrix class
  59519. * @returns the string "Matrix"
  59520. */
  59521. getClassName(): string;
  59522. /**
  59523. * Gets the hash code of the current matrix
  59524. * @returns the hash code
  59525. */
  59526. getHashCode(): number;
  59527. /**
  59528. * Decomposes the current Matrix into a translation, rotation and scaling components
  59529. * @param scale defines the scale vector3 given as a reference to update
  59530. * @param rotation defines the rotation quaternion given as a reference to update
  59531. * @param translation defines the translation vector3 given as a reference to update
  59532. * @returns true if operation was successful
  59533. */
  59534. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59535. /**
  59536. * Gets specific row of the matrix
  59537. * @param index defines the number of the row to get
  59538. * @returns the index-th row of the current matrix as a new Vector4
  59539. */
  59540. getRow(index: number): Nullable<Vector4>;
  59541. /**
  59542. * Sets the index-th row of the current matrix to the vector4 values
  59543. * @param index defines the number of the row to set
  59544. * @param row defines the target vector4
  59545. * @returns the updated current matrix
  59546. */
  59547. setRow(index: number, row: Vector4): Matrix;
  59548. /**
  59549. * Compute the transpose of the matrix
  59550. * @returns the new transposed matrix
  59551. */
  59552. transpose(): Matrix;
  59553. /**
  59554. * Compute the transpose of the matrix and store it in a given matrix
  59555. * @param result defines the target matrix
  59556. * @returns the current matrix
  59557. */
  59558. transposeToRef(result: Matrix): Matrix;
  59559. /**
  59560. * Sets the index-th row of the current matrix with the given 4 x float values
  59561. * @param index defines the row index
  59562. * @param x defines the x component to set
  59563. * @param y defines the y component to set
  59564. * @param z defines the z component to set
  59565. * @param w defines the w component to set
  59566. * @returns the updated current matrix
  59567. */
  59568. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59569. /**
  59570. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59571. * @param scale defines the scale factor
  59572. * @returns a new matrix
  59573. */
  59574. scale(scale: number): Matrix;
  59575. /**
  59576. * Scale the current matrix values by a factor to a given result matrix
  59577. * @param scale defines the scale factor
  59578. * @param result defines the matrix to store the result
  59579. * @returns the current matrix
  59580. */
  59581. scaleToRef(scale: number, result: Matrix): Matrix;
  59582. /**
  59583. * Scale the current matrix values by a factor and add the result to a given matrix
  59584. * @param scale defines the scale factor
  59585. * @param result defines the Matrix to store the result
  59586. * @returns the current matrix
  59587. */
  59588. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59589. /**
  59590. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59591. * @param ref matrix to store the result
  59592. */
  59593. toNormalMatrix(ref: Matrix): void;
  59594. /**
  59595. * Gets only rotation part of the current matrix
  59596. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59597. */
  59598. getRotationMatrix(): Matrix;
  59599. /**
  59600. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59601. * @param result defines the target matrix to store data to
  59602. * @returns the current matrix
  59603. */
  59604. getRotationMatrixToRef(result: Matrix): Matrix;
  59605. /**
  59606. * Toggles model matrix from being right handed to left handed in place and vice versa
  59607. */
  59608. toggleModelMatrixHandInPlace(): void;
  59609. /**
  59610. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59611. */
  59612. toggleProjectionMatrixHandInPlace(): void;
  59613. /**
  59614. * Creates a matrix from an array
  59615. * @param array defines the source array
  59616. * @param offset defines an offset in the source array
  59617. * @returns a new Matrix set from the starting index of the given array
  59618. */
  59619. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59620. /**
  59621. * Copy the content of an array into a given matrix
  59622. * @param array defines the source array
  59623. * @param offset defines an offset in the source array
  59624. * @param result defines the target matrix
  59625. */
  59626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59627. /**
  59628. * Stores an array into a matrix after having multiplied each component by a given factor
  59629. * @param array defines the source array
  59630. * @param offset defines the offset in the source array
  59631. * @param scale defines the scaling factor
  59632. * @param result defines the target matrix
  59633. */
  59634. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59635. /**
  59636. * Gets an identity matrix that must not be updated
  59637. */
  59638. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59639. /**
  59640. * Stores a list of values (16) inside a given matrix
  59641. * @param initialM11 defines 1st value of 1st row
  59642. * @param initialM12 defines 2nd value of 1st row
  59643. * @param initialM13 defines 3rd value of 1st row
  59644. * @param initialM14 defines 4th value of 1st row
  59645. * @param initialM21 defines 1st value of 2nd row
  59646. * @param initialM22 defines 2nd value of 2nd row
  59647. * @param initialM23 defines 3rd value of 2nd row
  59648. * @param initialM24 defines 4th value of 2nd row
  59649. * @param initialM31 defines 1st value of 3rd row
  59650. * @param initialM32 defines 2nd value of 3rd row
  59651. * @param initialM33 defines 3rd value of 3rd row
  59652. * @param initialM34 defines 4th value of 3rd row
  59653. * @param initialM41 defines 1st value of 4th row
  59654. * @param initialM42 defines 2nd value of 4th row
  59655. * @param initialM43 defines 3rd value of 4th row
  59656. * @param initialM44 defines 4th value of 4th row
  59657. * @param result defines the target matrix
  59658. */
  59659. 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;
  59660. /**
  59661. * Creates new matrix from a list of values (16)
  59662. * @param initialM11 defines 1st value of 1st row
  59663. * @param initialM12 defines 2nd value of 1st row
  59664. * @param initialM13 defines 3rd value of 1st row
  59665. * @param initialM14 defines 4th value of 1st row
  59666. * @param initialM21 defines 1st value of 2nd row
  59667. * @param initialM22 defines 2nd value of 2nd row
  59668. * @param initialM23 defines 3rd value of 2nd row
  59669. * @param initialM24 defines 4th value of 2nd row
  59670. * @param initialM31 defines 1st value of 3rd row
  59671. * @param initialM32 defines 2nd value of 3rd row
  59672. * @param initialM33 defines 3rd value of 3rd row
  59673. * @param initialM34 defines 4th value of 3rd row
  59674. * @param initialM41 defines 1st value of 4th row
  59675. * @param initialM42 defines 2nd value of 4th row
  59676. * @param initialM43 defines 3rd value of 4th row
  59677. * @param initialM44 defines 4th value of 4th row
  59678. * @returns the new matrix
  59679. */
  59680. 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;
  59681. /**
  59682. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59683. * @param scale defines the scale vector3
  59684. * @param rotation defines the rotation quaternion
  59685. * @param translation defines the translation vector3
  59686. * @returns a new matrix
  59687. */
  59688. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59689. /**
  59690. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59691. * @param scale defines the scale vector3
  59692. * @param rotation defines the rotation quaternion
  59693. * @param translation defines the translation vector3
  59694. * @param result defines the target matrix
  59695. */
  59696. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59697. /**
  59698. * Creates a new identity matrix
  59699. * @returns a new identity matrix
  59700. */
  59701. static Identity(): Matrix;
  59702. /**
  59703. * Creates a new identity matrix and stores the result in a given matrix
  59704. * @param result defines the target matrix
  59705. */
  59706. static IdentityToRef(result: Matrix): void;
  59707. /**
  59708. * Creates a new zero matrix
  59709. * @returns a new zero matrix
  59710. */
  59711. static Zero(): Matrix;
  59712. /**
  59713. * Creates a new rotation matrix for "angle" radians around the X axis
  59714. * @param angle defines the angle (in radians) to use
  59715. * @return the new matrix
  59716. */
  59717. static RotationX(angle: number): Matrix;
  59718. /**
  59719. * Creates a new matrix as the invert of a given matrix
  59720. * @param source defines the source matrix
  59721. * @returns the new matrix
  59722. */
  59723. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59724. /**
  59725. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59726. * @param angle defines the angle (in radians) to use
  59727. * @param result defines the target matrix
  59728. */
  59729. static RotationXToRef(angle: number, result: Matrix): void;
  59730. /**
  59731. * Creates a new rotation matrix for "angle" radians around the Y axis
  59732. * @param angle defines the angle (in radians) to use
  59733. * @return the new matrix
  59734. */
  59735. static RotationY(angle: number): Matrix;
  59736. /**
  59737. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59738. * @param angle defines the angle (in radians) to use
  59739. * @param result defines the target matrix
  59740. */
  59741. static RotationYToRef(angle: number, result: Matrix): void;
  59742. /**
  59743. * Creates a new rotation matrix for "angle" radians around the Z axis
  59744. * @param angle defines the angle (in radians) to use
  59745. * @return the new matrix
  59746. */
  59747. static RotationZ(angle: number): Matrix;
  59748. /**
  59749. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59750. * @param angle defines the angle (in radians) to use
  59751. * @param result defines the target matrix
  59752. */
  59753. static RotationZToRef(angle: number, result: Matrix): void;
  59754. /**
  59755. * Creates a new rotation matrix for "angle" radians around the given axis
  59756. * @param axis defines the axis to use
  59757. * @param angle defines the angle (in radians) to use
  59758. * @return the new matrix
  59759. */
  59760. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59761. /**
  59762. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59763. * @param axis defines the axis to use
  59764. * @param angle defines the angle (in radians) to use
  59765. * @param result defines the target matrix
  59766. */
  59767. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59768. /**
  59769. * Creates a rotation matrix
  59770. * @param yaw defines the yaw angle in radians (Y axis)
  59771. * @param pitch defines the pitch angle in radians (X axis)
  59772. * @param roll defines the roll angle in radians (X axis)
  59773. * @returns the new rotation matrix
  59774. */
  59775. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59776. /**
  59777. * Creates a rotation matrix and stores it in a given matrix
  59778. * @param yaw defines the yaw angle in radians (Y axis)
  59779. * @param pitch defines the pitch angle in radians (X axis)
  59780. * @param roll defines the roll angle in radians (X axis)
  59781. * @param result defines the target matrix
  59782. */
  59783. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59784. /**
  59785. * Creates a scaling matrix
  59786. * @param x defines the scale factor on X axis
  59787. * @param y defines the scale factor on Y axis
  59788. * @param z defines the scale factor on Z axis
  59789. * @returns the new matrix
  59790. */
  59791. static Scaling(x: number, y: number, z: number): Matrix;
  59792. /**
  59793. * Creates a scaling matrix and stores it in a given matrix
  59794. * @param x defines the scale factor on X axis
  59795. * @param y defines the scale factor on Y axis
  59796. * @param z defines the scale factor on Z axis
  59797. * @param result defines the target matrix
  59798. */
  59799. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59800. /**
  59801. * Creates a translation matrix
  59802. * @param x defines the translation on X axis
  59803. * @param y defines the translation on Y axis
  59804. * @param z defines the translationon Z axis
  59805. * @returns the new matrix
  59806. */
  59807. static Translation(x: number, y: number, z: number): Matrix;
  59808. /**
  59809. * Creates a translation matrix and stores it in a given matrix
  59810. * @param x defines the translation on X axis
  59811. * @param y defines the translation on Y axis
  59812. * @param z defines the translationon Z axis
  59813. * @param result defines the target matrix
  59814. */
  59815. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59816. /**
  59817. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59818. * @param startValue defines the start value
  59819. * @param endValue defines the end value
  59820. * @param gradient defines the gradient factor
  59821. * @returns the new matrix
  59822. */
  59823. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59824. /**
  59825. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59826. * @param startValue defines the start value
  59827. * @param endValue defines the end value
  59828. * @param gradient defines the gradient factor
  59829. * @param result defines the Matrix object where to store data
  59830. */
  59831. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59832. /**
  59833. * Builds a new matrix whose values are computed by:
  59834. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59835. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59836. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59837. * @param startValue defines the first matrix
  59838. * @param endValue defines the second matrix
  59839. * @param gradient defines the gradient between the two matrices
  59840. * @returns the new matrix
  59841. */
  59842. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59843. /**
  59844. * Update a matrix to values which are computed by:
  59845. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59846. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59847. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59848. * @param startValue defines the first matrix
  59849. * @param endValue defines the second matrix
  59850. * @param gradient defines the gradient between the two matrices
  59851. * @param result defines the target matrix
  59852. */
  59853. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59854. /**
  59855. * 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"
  59856. * This function works in left handed mode
  59857. * @param eye defines the final position of the entity
  59858. * @param target defines where the entity should look at
  59859. * @param up defines the up vector for the entity
  59860. * @returns the new matrix
  59861. */
  59862. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59863. /**
  59864. * 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".
  59865. * This function works in left handed mode
  59866. * @param eye defines the final position of the entity
  59867. * @param target defines where the entity should look at
  59868. * @param up defines the up vector for the entity
  59869. * @param result defines the target matrix
  59870. */
  59871. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59872. /**
  59873. * 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"
  59874. * This function works in right handed mode
  59875. * @param eye defines the final position of the entity
  59876. * @param target defines where the entity should look at
  59877. * @param up defines the up vector for the entity
  59878. * @returns the new matrix
  59879. */
  59880. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59881. /**
  59882. * 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".
  59883. * This function works in right handed mode
  59884. * @param eye defines the final position of the entity
  59885. * @param target defines where the entity should look at
  59886. * @param up defines the up vector for the entity
  59887. * @param result defines the target matrix
  59888. */
  59889. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59890. /**
  59891. * Create a left-handed orthographic projection matrix
  59892. * @param width defines the viewport width
  59893. * @param height defines the viewport height
  59894. * @param znear defines the near clip plane
  59895. * @param zfar defines the far clip plane
  59896. * @returns a new matrix as a left-handed orthographic projection matrix
  59897. */
  59898. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59899. /**
  59900. * Store a left-handed orthographic projection to a given matrix
  59901. * @param width defines the viewport width
  59902. * @param height defines the viewport height
  59903. * @param znear defines the near clip plane
  59904. * @param zfar defines the far clip plane
  59905. * @param result defines the target matrix
  59906. */
  59907. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59908. /**
  59909. * Create a left-handed orthographic projection matrix
  59910. * @param left defines the viewport left coordinate
  59911. * @param right defines the viewport right coordinate
  59912. * @param bottom defines the viewport bottom coordinate
  59913. * @param top defines the viewport top coordinate
  59914. * @param znear defines the near clip plane
  59915. * @param zfar defines the far clip plane
  59916. * @returns a new matrix as a left-handed orthographic projection matrix
  59917. */
  59918. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59919. /**
  59920. * Stores a left-handed orthographic projection into a given matrix
  59921. * @param left defines the viewport left coordinate
  59922. * @param right defines the viewport right coordinate
  59923. * @param bottom defines the viewport bottom coordinate
  59924. * @param top defines the viewport top coordinate
  59925. * @param znear defines the near clip plane
  59926. * @param zfar defines the far clip plane
  59927. * @param result defines the target matrix
  59928. */
  59929. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59930. /**
  59931. * Creates a right-handed orthographic projection matrix
  59932. * @param left defines the viewport left coordinate
  59933. * @param right defines the viewport right coordinate
  59934. * @param bottom defines the viewport bottom coordinate
  59935. * @param top defines the viewport top coordinate
  59936. * @param znear defines the near clip plane
  59937. * @param zfar defines the far clip plane
  59938. * @returns a new matrix as a right-handed orthographic projection matrix
  59939. */
  59940. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59941. /**
  59942. * Stores a right-handed orthographic projection into a given matrix
  59943. * @param left defines the viewport left coordinate
  59944. * @param right defines the viewport right coordinate
  59945. * @param bottom defines the viewport bottom coordinate
  59946. * @param top defines the viewport top coordinate
  59947. * @param znear defines the near clip plane
  59948. * @param zfar defines the far clip plane
  59949. * @param result defines the target matrix
  59950. */
  59951. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59952. /**
  59953. * Creates a left-handed perspective projection matrix
  59954. * @param width defines the viewport width
  59955. * @param height defines the viewport height
  59956. * @param znear defines the near clip plane
  59957. * @param zfar defines the far clip plane
  59958. * @returns a new matrix as a left-handed perspective projection matrix
  59959. */
  59960. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59961. /**
  59962. * Creates a left-handed perspective projection matrix
  59963. * @param fov defines the horizontal field of view
  59964. * @param aspect defines the aspect ratio
  59965. * @param znear defines the near clip plane
  59966. * @param zfar defines the far clip plane
  59967. * @returns a new matrix as a left-handed perspective projection matrix
  59968. */
  59969. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59970. /**
  59971. * Stores a left-handed perspective projection into a given matrix
  59972. * @param fov defines the horizontal field of view
  59973. * @param aspect defines the aspect ratio
  59974. * @param znear defines the near clip plane
  59975. * @param zfar defines the far clip plane
  59976. * @param result defines the target matrix
  59977. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59978. */
  59979. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59980. /**
  59981. * Creates a right-handed perspective projection matrix
  59982. * @param fov defines the horizontal field of view
  59983. * @param aspect defines the aspect ratio
  59984. * @param znear defines the near clip plane
  59985. * @param zfar defines the far clip plane
  59986. * @returns a new matrix as a right-handed perspective projection matrix
  59987. */
  59988. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59989. /**
  59990. * Stores a right-handed perspective projection into a given matrix
  59991. * @param fov defines the horizontal field of view
  59992. * @param aspect defines the aspect ratio
  59993. * @param znear defines the near clip plane
  59994. * @param zfar defines the far clip plane
  59995. * @param result defines the target matrix
  59996. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59997. */
  59998. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59999. /**
  60000. * Stores a perspective projection for WebVR info a given matrix
  60001. * @param fov defines the field of view
  60002. * @param znear defines the near clip plane
  60003. * @param zfar defines the far clip plane
  60004. * @param result defines the target matrix
  60005. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60006. */
  60007. static PerspectiveFovWebVRToRef(fov: {
  60008. upDegrees: number;
  60009. downDegrees: number;
  60010. leftDegrees: number;
  60011. rightDegrees: number;
  60012. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60013. /**
  60014. * Computes a complete transformation matrix
  60015. * @param viewport defines the viewport to use
  60016. * @param world defines the world matrix
  60017. * @param view defines the view matrix
  60018. * @param projection defines the projection matrix
  60019. * @param zmin defines the near clip plane
  60020. * @param zmax defines the far clip plane
  60021. * @returns the transformation matrix
  60022. */
  60023. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60024. /**
  60025. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60026. * @param matrix defines the matrix to use
  60027. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60028. */
  60029. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60030. /**
  60031. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60032. * @param matrix defines the matrix to use
  60033. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60034. */
  60035. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60036. /**
  60037. * Compute the transpose of a given matrix
  60038. * @param matrix defines the matrix to transpose
  60039. * @returns the new matrix
  60040. */
  60041. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60042. /**
  60043. * Compute the transpose of a matrix and store it in a target matrix
  60044. * @param matrix defines the matrix to transpose
  60045. * @param result defines the target matrix
  60046. */
  60047. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60048. /**
  60049. * Computes a reflection matrix from a plane
  60050. * @param plane defines the reflection plane
  60051. * @returns a new matrix
  60052. */
  60053. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60054. /**
  60055. * Computes a reflection matrix from a plane
  60056. * @param plane defines the reflection plane
  60057. * @param result defines the target matrix
  60058. */
  60059. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60060. /**
  60061. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60062. * @param xaxis defines the value of the 1st axis
  60063. * @param yaxis defines the value of the 2nd axis
  60064. * @param zaxis defines the value of the 3rd axis
  60065. * @param result defines the target matrix
  60066. */
  60067. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60068. /**
  60069. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60070. * @param quat defines the quaternion to use
  60071. * @param result defines the target matrix
  60072. */
  60073. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60074. }
  60075. /**
  60076. * Represens a plane by the equation ax + by + cz + d = 0
  60077. */
  60078. export class Plane {
  60079. /**
  60080. * Normal of the plane (a,b,c)
  60081. */
  60082. normal: Vector3;
  60083. /**
  60084. * d component of the plane
  60085. */
  60086. d: number;
  60087. /**
  60088. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60089. * @param a a component of the plane
  60090. * @param b b component of the plane
  60091. * @param c c component of the plane
  60092. * @param d d component of the plane
  60093. */
  60094. constructor(a: number, b: number, c: number, d: number);
  60095. /**
  60096. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60097. */
  60098. asArray(): number[];
  60099. /**
  60100. * @returns a new plane copied from the current Plane.
  60101. */
  60102. clone(): Plane;
  60103. /**
  60104. * @returns the string "Plane".
  60105. */
  60106. getClassName(): string;
  60107. /**
  60108. * @returns the Plane hash code.
  60109. */
  60110. getHashCode(): number;
  60111. /**
  60112. * Normalize the current Plane in place.
  60113. * @returns the updated Plane.
  60114. */
  60115. normalize(): Plane;
  60116. /**
  60117. * Applies a transformation the plane and returns the result
  60118. * @param transformation the transformation matrix to be applied to the plane
  60119. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60120. */
  60121. transform(transformation: DeepImmutable<Matrix>): Plane;
  60122. /**
  60123. * Calcualtte the dot product between the point and the plane normal
  60124. * @param point point to calculate the dot product with
  60125. * @returns the dot product (float) of the point coordinates and the plane normal.
  60126. */
  60127. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60128. /**
  60129. * Updates the current Plane from the plane defined by the three given points.
  60130. * @param point1 one of the points used to contruct the plane
  60131. * @param point2 one of the points used to contruct the plane
  60132. * @param point3 one of the points used to contruct the plane
  60133. * @returns the updated Plane.
  60134. */
  60135. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60136. /**
  60137. * Checks if the plane is facing a given direction
  60138. * @param direction the direction to check if the plane is facing
  60139. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60140. * @returns True is the vector "direction" is the same side than the plane normal.
  60141. */
  60142. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60143. /**
  60144. * Calculates the distance to a point
  60145. * @param point point to calculate distance to
  60146. * @returns the signed distance (float) from the given point to the Plane.
  60147. */
  60148. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60149. /**
  60150. * Creates a plane from an array
  60151. * @param array the array to create a plane from
  60152. * @returns a new Plane from the given array.
  60153. */
  60154. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60155. /**
  60156. * Creates a plane from three points
  60157. * @param point1 point used to create the plane
  60158. * @param point2 point used to create the plane
  60159. * @param point3 point used to create the plane
  60160. * @returns a new Plane defined by the three given points.
  60161. */
  60162. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60163. /**
  60164. * Creates a plane from an origin point and a normal
  60165. * @param origin origin of the plane to be constructed
  60166. * @param normal normal of the plane to be constructed
  60167. * @returns a new Plane the normal vector to this plane at the given origin point.
  60168. * Note : the vector "normal" is updated because normalized.
  60169. */
  60170. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60171. /**
  60172. * Calculates the distance from a plane and a point
  60173. * @param origin origin of the plane to be constructed
  60174. * @param normal normal of the plane to be constructed
  60175. * @param point point to calculate distance to
  60176. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60177. */
  60178. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60179. }
  60180. /**
  60181. * Class used to represent a viewport on screen
  60182. */
  60183. export class Viewport {
  60184. /** viewport left coordinate */
  60185. x: number;
  60186. /** viewport top coordinate */
  60187. y: number;
  60188. /**viewport width */
  60189. width: number;
  60190. /** viewport height */
  60191. height: number;
  60192. /**
  60193. * Creates a Viewport object located at (x, y) and sized (width, height)
  60194. * @param x defines viewport left coordinate
  60195. * @param y defines viewport top coordinate
  60196. * @param width defines the viewport width
  60197. * @param height defines the viewport height
  60198. */
  60199. constructor(
  60200. /** viewport left coordinate */
  60201. x: number,
  60202. /** viewport top coordinate */
  60203. y: number,
  60204. /**viewport width */
  60205. width: number,
  60206. /** viewport height */
  60207. height: number);
  60208. /**
  60209. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60210. * @param renderWidth defines the rendering width
  60211. * @param renderHeight defines the rendering height
  60212. * @returns a new Viewport
  60213. */
  60214. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60215. /**
  60216. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60217. * @param renderWidth defines the rendering width
  60218. * @param renderHeight defines the rendering height
  60219. * @param ref defines the target viewport
  60220. * @returns the current viewport
  60221. */
  60222. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60223. /**
  60224. * Returns a new Viewport copied from the current one
  60225. * @returns a new Viewport
  60226. */
  60227. clone(): Viewport;
  60228. }
  60229. /**
  60230. * Reprasents a camera frustum
  60231. */
  60232. export class Frustum {
  60233. /**
  60234. * Gets the planes representing the frustum
  60235. * @param transform matrix to be applied to the returned planes
  60236. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60237. */
  60238. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60239. /**
  60240. * Gets the near frustum plane transformed by the transform matrix
  60241. * @param transform transformation matrix to be applied to the resulting frustum plane
  60242. * @param frustumPlane the resuling frustum plane
  60243. */
  60244. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60245. /**
  60246. * Gets the far frustum plane transformed by the transform matrix
  60247. * @param transform transformation matrix to be applied to the resulting frustum plane
  60248. * @param frustumPlane the resuling frustum plane
  60249. */
  60250. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60251. /**
  60252. * Gets the left frustum plane transformed by the transform matrix
  60253. * @param transform transformation matrix to be applied to the resulting frustum plane
  60254. * @param frustumPlane the resuling frustum plane
  60255. */
  60256. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60257. /**
  60258. * Gets the right frustum plane transformed by the transform matrix
  60259. * @param transform transformation matrix to be applied to the resulting frustum plane
  60260. * @param frustumPlane the resuling frustum plane
  60261. */
  60262. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60263. /**
  60264. * Gets the top frustum plane transformed by the transform matrix
  60265. * @param transform transformation matrix to be applied to the resulting frustum plane
  60266. * @param frustumPlane the resuling frustum plane
  60267. */
  60268. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60269. /**
  60270. * Gets the bottom frustum plane transformed by the transform matrix
  60271. * @param transform transformation matrix to be applied to the resulting frustum plane
  60272. * @param frustumPlane the resuling frustum plane
  60273. */
  60274. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60275. /**
  60276. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60277. * @param transform transformation matrix to be applied to the resulting frustum planes
  60278. * @param frustumPlanes the resuling frustum planes
  60279. */
  60280. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60281. }
  60282. /** Defines supported spaces */
  60283. export enum Space {
  60284. /** Local (object) space */
  60285. LOCAL = 0,
  60286. /** World space */
  60287. WORLD = 1,
  60288. /** Bone space */
  60289. BONE = 2
  60290. }
  60291. /** Defines the 3 main axes */
  60292. export class Axis {
  60293. /** X axis */
  60294. static X: Vector3;
  60295. /** Y axis */
  60296. static Y: Vector3;
  60297. /** Z axis */
  60298. static Z: Vector3;
  60299. }
  60300. /** Class used to represent a Bezier curve */
  60301. export class BezierCurve {
  60302. /**
  60303. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60304. * @param t defines the time
  60305. * @param x1 defines the left coordinate on X axis
  60306. * @param y1 defines the left coordinate on Y axis
  60307. * @param x2 defines the right coordinate on X axis
  60308. * @param y2 defines the right coordinate on Y axis
  60309. * @returns the interpolated value
  60310. */
  60311. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60312. }
  60313. /**
  60314. * Defines potential orientation for back face culling
  60315. */
  60316. export enum Orientation {
  60317. /**
  60318. * Clockwise
  60319. */
  60320. CW = 0,
  60321. /** Counter clockwise */
  60322. CCW = 1
  60323. }
  60324. /**
  60325. * Defines angle representation
  60326. */
  60327. export class Angle {
  60328. private _radians;
  60329. /**
  60330. * Creates an Angle object of "radians" radians (float).
  60331. * @param radians the angle in radians
  60332. */
  60333. constructor(radians: number);
  60334. /**
  60335. * Get value in degrees
  60336. * @returns the Angle value in degrees (float)
  60337. */
  60338. degrees(): number;
  60339. /**
  60340. * Get value in radians
  60341. * @returns the Angle value in radians (float)
  60342. */
  60343. radians(): number;
  60344. /**
  60345. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60346. * @param a defines first vector
  60347. * @param b defines second vector
  60348. * @returns a new Angle
  60349. */
  60350. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60351. /**
  60352. * Gets a new Angle object from the given float in radians
  60353. * @param radians defines the angle value in radians
  60354. * @returns a new Angle
  60355. */
  60356. static FromRadians(radians: number): Angle;
  60357. /**
  60358. * Gets a new Angle object from the given float in degrees
  60359. * @param degrees defines the angle value in degrees
  60360. * @returns a new Angle
  60361. */
  60362. static FromDegrees(degrees: number): Angle;
  60363. }
  60364. /**
  60365. * This represents an arc in a 2d space.
  60366. */
  60367. export class Arc2 {
  60368. /** Defines the start point of the arc */
  60369. startPoint: Vector2;
  60370. /** Defines the mid point of the arc */
  60371. midPoint: Vector2;
  60372. /** Defines the end point of the arc */
  60373. endPoint: Vector2;
  60374. /**
  60375. * Defines the center point of the arc.
  60376. */
  60377. centerPoint: Vector2;
  60378. /**
  60379. * Defines the radius of the arc.
  60380. */
  60381. radius: number;
  60382. /**
  60383. * Defines the angle of the arc (from mid point to end point).
  60384. */
  60385. angle: Angle;
  60386. /**
  60387. * Defines the start angle of the arc (from start point to middle point).
  60388. */
  60389. startAngle: Angle;
  60390. /**
  60391. * Defines the orientation of the arc (clock wise/counter clock wise).
  60392. */
  60393. orientation: Orientation;
  60394. /**
  60395. * Creates an Arc object from the three given points : start, middle and end.
  60396. * @param startPoint Defines the start point of the arc
  60397. * @param midPoint Defines the midlle point of the arc
  60398. * @param endPoint Defines the end point of the arc
  60399. */
  60400. constructor(
  60401. /** Defines the start point of the arc */
  60402. startPoint: Vector2,
  60403. /** Defines the mid point of the arc */
  60404. midPoint: Vector2,
  60405. /** Defines the end point of the arc */
  60406. endPoint: Vector2);
  60407. }
  60408. /**
  60409. * Represents a 2D path made up of multiple 2D points
  60410. */
  60411. export class Path2 {
  60412. private _points;
  60413. private _length;
  60414. /**
  60415. * If the path start and end point are the same
  60416. */
  60417. closed: boolean;
  60418. /**
  60419. * Creates a Path2 object from the starting 2D coordinates x and y.
  60420. * @param x the starting points x value
  60421. * @param y the starting points y value
  60422. */
  60423. constructor(x: number, y: number);
  60424. /**
  60425. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60426. * @param x the added points x value
  60427. * @param y the added points y value
  60428. * @returns the updated Path2.
  60429. */
  60430. addLineTo(x: number, y: number): Path2;
  60431. /**
  60432. * 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.
  60433. * @param midX middle point x value
  60434. * @param midY middle point y value
  60435. * @param endX end point x value
  60436. * @param endY end point y value
  60437. * @param numberOfSegments (default: 36)
  60438. * @returns the updated Path2.
  60439. */
  60440. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60441. /**
  60442. * Closes the Path2.
  60443. * @returns the Path2.
  60444. */
  60445. close(): Path2;
  60446. /**
  60447. * Gets the sum of the distance between each sequential point in the path
  60448. * @returns the Path2 total length (float).
  60449. */
  60450. length(): number;
  60451. /**
  60452. * Gets the points which construct the path
  60453. * @returns the Path2 internal array of points.
  60454. */
  60455. getPoints(): Vector2[];
  60456. /**
  60457. * Retreives the point at the distance aways from the starting point
  60458. * @param normalizedLengthPosition the length along the path to retreive the point from
  60459. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60460. */
  60461. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60462. /**
  60463. * Creates a new path starting from an x and y position
  60464. * @param x starting x value
  60465. * @param y starting y value
  60466. * @returns a new Path2 starting at the coordinates (x, y).
  60467. */
  60468. static StartingAt(x: number, y: number): Path2;
  60469. }
  60470. /**
  60471. * Represents a 3D path made up of multiple 3D points
  60472. */
  60473. export class Path3D {
  60474. /**
  60475. * an array of Vector3, the curve axis of the Path3D
  60476. */
  60477. path: Vector3[];
  60478. private _curve;
  60479. private _distances;
  60480. private _tangents;
  60481. private _normals;
  60482. private _binormals;
  60483. private _raw;
  60484. /**
  60485. * new Path3D(path, normal, raw)
  60486. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60487. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60488. * @param path an array of Vector3, the curve axis of the Path3D
  60489. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60490. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60491. */
  60492. constructor(
  60493. /**
  60494. * an array of Vector3, the curve axis of the Path3D
  60495. */
  60496. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60497. /**
  60498. * Returns the Path3D array of successive Vector3 designing its curve.
  60499. * @returns the Path3D array of successive Vector3 designing its curve.
  60500. */
  60501. getCurve(): Vector3[];
  60502. /**
  60503. * Returns an array populated with tangent vectors on each Path3D curve point.
  60504. * @returns an array populated with tangent vectors on each Path3D curve point.
  60505. */
  60506. getTangents(): Vector3[];
  60507. /**
  60508. * Returns an array populated with normal vectors on each Path3D curve point.
  60509. * @returns an array populated with normal vectors on each Path3D curve point.
  60510. */
  60511. getNormals(): Vector3[];
  60512. /**
  60513. * Returns an array populated with binormal vectors on each Path3D curve point.
  60514. * @returns an array populated with binormal vectors on each Path3D curve point.
  60515. */
  60516. getBinormals(): Vector3[];
  60517. /**
  60518. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60519. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60520. */
  60521. getDistances(): number[];
  60522. /**
  60523. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60524. * @param path path which all values are copied into the curves points
  60525. * @param firstNormal which should be projected onto the curve
  60526. * @returns the same object updated.
  60527. */
  60528. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60529. private _compute;
  60530. private _getFirstNonNullVector;
  60531. private _getLastNonNullVector;
  60532. private _normalVector;
  60533. }
  60534. /**
  60535. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60536. * A Curve3 is designed from a series of successive Vector3.
  60537. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60538. */
  60539. export class Curve3 {
  60540. private _points;
  60541. private _length;
  60542. /**
  60543. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60544. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60545. * @param v1 (Vector3) the control point
  60546. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60547. * @param nbPoints (integer) the wanted number of points in the curve
  60548. * @returns the created Curve3
  60549. */
  60550. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60551. /**
  60552. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60553. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60554. * @param v1 (Vector3) the first control point
  60555. * @param v2 (Vector3) the second control point
  60556. * @param v3 (Vector3) the end point of the Cubic Bezier
  60557. * @param nbPoints (integer) the wanted number of points in the curve
  60558. * @returns the created Curve3
  60559. */
  60560. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60561. /**
  60562. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60563. * @param p1 (Vector3) the origin point of the Hermite Spline
  60564. * @param t1 (Vector3) the tangent vector at the origin point
  60565. * @param p2 (Vector3) the end point of the Hermite Spline
  60566. * @param t2 (Vector3) the tangent vector at the end point
  60567. * @param nbPoints (integer) the wanted number of points in the curve
  60568. * @returns the created Curve3
  60569. */
  60570. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60571. /**
  60572. * Returns a Curve3 object along a CatmullRom Spline curve :
  60573. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60574. * @param nbPoints (integer) the wanted number of points between each curve control points
  60575. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60576. * @returns the created Curve3
  60577. */
  60578. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60579. /**
  60580. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60581. * A Curve3 is designed from a series of successive Vector3.
  60582. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60583. * @param points points which make up the curve
  60584. */
  60585. constructor(points: Vector3[]);
  60586. /**
  60587. * @returns the Curve3 stored array of successive Vector3
  60588. */
  60589. getPoints(): Vector3[];
  60590. /**
  60591. * @returns the computed length (float) of the curve.
  60592. */
  60593. length(): number;
  60594. /**
  60595. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60596. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60597. * curveA and curveB keep unchanged.
  60598. * @param curve the curve to continue from this curve
  60599. * @returns the newly constructed curve
  60600. */
  60601. continue(curve: DeepImmutable<Curve3>): Curve3;
  60602. private _computeLength;
  60603. }
  60604. /**
  60605. * Contains position and normal vectors for a vertex
  60606. */
  60607. export class PositionNormalVertex {
  60608. /** the position of the vertex (defaut: 0,0,0) */
  60609. position: Vector3;
  60610. /** the normal of the vertex (defaut: 0,1,0) */
  60611. normal: Vector3;
  60612. /**
  60613. * Creates a PositionNormalVertex
  60614. * @param position the position of the vertex (defaut: 0,0,0)
  60615. * @param normal the normal of the vertex (defaut: 0,1,0)
  60616. */
  60617. constructor(
  60618. /** the position of the vertex (defaut: 0,0,0) */
  60619. position?: Vector3,
  60620. /** the normal of the vertex (defaut: 0,1,0) */
  60621. normal?: Vector3);
  60622. /**
  60623. * Clones the PositionNormalVertex
  60624. * @returns the cloned PositionNormalVertex
  60625. */
  60626. clone(): PositionNormalVertex;
  60627. }
  60628. /**
  60629. * Contains position, normal and uv vectors for a vertex
  60630. */
  60631. export class PositionNormalTextureVertex {
  60632. /** the position of the vertex (defaut: 0,0,0) */
  60633. position: Vector3;
  60634. /** the normal of the vertex (defaut: 0,1,0) */
  60635. normal: Vector3;
  60636. /** the uv of the vertex (default: 0,0) */
  60637. uv: Vector2;
  60638. /**
  60639. * Creates a PositionNormalTextureVertex
  60640. * @param position the position of the vertex (defaut: 0,0,0)
  60641. * @param normal the normal of the vertex (defaut: 0,1,0)
  60642. * @param uv the uv of the vertex (default: 0,0)
  60643. */
  60644. constructor(
  60645. /** the position of the vertex (defaut: 0,0,0) */
  60646. position?: Vector3,
  60647. /** the normal of the vertex (defaut: 0,1,0) */
  60648. normal?: Vector3,
  60649. /** the uv of the vertex (default: 0,0) */
  60650. uv?: Vector2);
  60651. /**
  60652. * Clones the PositionNormalTextureVertex
  60653. * @returns the cloned PositionNormalTextureVertex
  60654. */
  60655. clone(): PositionNormalTextureVertex;
  60656. }
  60657. /**
  60658. * @hidden
  60659. */
  60660. export class Tmp {
  60661. static Color3: Color3[];
  60662. static Color4: Color4[];
  60663. static Vector2: Vector2[];
  60664. static Vector3: Vector3[];
  60665. static Vector4: Vector4[];
  60666. static Quaternion: Quaternion[];
  60667. static Matrix: Matrix[];
  60668. }
  60669. }
  60670. declare module BABYLON {
  60671. /**
  60672. * Class used to enable access to offline support
  60673. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60674. */
  60675. export interface IOfflineProvider {
  60676. /**
  60677. * Gets a boolean indicating if scene must be saved in the database
  60678. */
  60679. enableSceneOffline: boolean;
  60680. /**
  60681. * Gets a boolean indicating if textures must be saved in the database
  60682. */
  60683. enableTexturesOffline: boolean;
  60684. /**
  60685. * Open the offline support and make it available
  60686. * @param successCallback defines the callback to call on success
  60687. * @param errorCallback defines the callback to call on error
  60688. */
  60689. open(successCallback: () => void, errorCallback: () => void): void;
  60690. /**
  60691. * Loads an image from the offline support
  60692. * @param url defines the url to load from
  60693. * @param image defines the target DOM image
  60694. */
  60695. loadImage(url: string, image: HTMLImageElement): void;
  60696. /**
  60697. * Loads a file from offline support
  60698. * @param url defines the URL to load from
  60699. * @param sceneLoaded defines a callback to call on success
  60700. * @param progressCallBack defines a callback to call when progress changed
  60701. * @param errorCallback defines a callback to call on error
  60702. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60703. */
  60704. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60705. }
  60706. }
  60707. declare module BABYLON {
  60708. /**
  60709. * A class serves as a medium between the observable and its observers
  60710. */
  60711. export class EventState {
  60712. /**
  60713. * Create a new EventState
  60714. * @param mask defines the mask associated with this state
  60715. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60716. * @param target defines the original target of the state
  60717. * @param currentTarget defines the current target of the state
  60718. */
  60719. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60720. /**
  60721. * Initialize the current event state
  60722. * @param mask defines the mask associated with this state
  60723. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60724. * @param target defines the original target of the state
  60725. * @param currentTarget defines the current target of the state
  60726. * @returns the current event state
  60727. */
  60728. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60729. /**
  60730. * An Observer can set this property to true to prevent subsequent observers of being notified
  60731. */
  60732. skipNextObservers: boolean;
  60733. /**
  60734. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60735. */
  60736. mask: number;
  60737. /**
  60738. * The object that originally notified the event
  60739. */
  60740. target?: any;
  60741. /**
  60742. * The current object in the bubbling phase
  60743. */
  60744. currentTarget?: any;
  60745. /**
  60746. * This will be populated with the return value of the last function that was executed.
  60747. * If it is the first function in the callback chain it will be the event data.
  60748. */
  60749. lastReturnValue?: any;
  60750. }
  60751. /**
  60752. * Represent an Observer registered to a given Observable object.
  60753. */
  60754. export class Observer<T> {
  60755. /**
  60756. * Defines the callback to call when the observer is notified
  60757. */
  60758. callback: (eventData: T, eventState: EventState) => void;
  60759. /**
  60760. * Defines the mask of the observer (used to filter notifications)
  60761. */
  60762. mask: number;
  60763. /**
  60764. * Defines the current scope used to restore the JS context
  60765. */
  60766. scope: any;
  60767. /** @hidden */
  60768. _willBeUnregistered: boolean;
  60769. /**
  60770. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60771. */
  60772. unregisterOnNextCall: boolean;
  60773. /**
  60774. * Creates a new observer
  60775. * @param callback defines the callback to call when the observer is notified
  60776. * @param mask defines the mask of the observer (used to filter notifications)
  60777. * @param scope defines the current scope used to restore the JS context
  60778. */
  60779. constructor(
  60780. /**
  60781. * Defines the callback to call when the observer is notified
  60782. */
  60783. callback: (eventData: T, eventState: EventState) => void,
  60784. /**
  60785. * Defines the mask of the observer (used to filter notifications)
  60786. */
  60787. mask: number,
  60788. /**
  60789. * Defines the current scope used to restore the JS context
  60790. */
  60791. scope?: any);
  60792. }
  60793. /**
  60794. * Represent a list of observers registered to multiple Observables object.
  60795. */
  60796. export class MultiObserver<T> {
  60797. private _observers;
  60798. private _observables;
  60799. /**
  60800. * Release associated resources
  60801. */
  60802. dispose(): void;
  60803. /**
  60804. * Raise a callback when one of the observable will notify
  60805. * @param observables defines a list of observables to watch
  60806. * @param callback defines the callback to call on notification
  60807. * @param mask defines the mask used to filter notifications
  60808. * @param scope defines the current scope used to restore the JS context
  60809. * @returns the new MultiObserver
  60810. */
  60811. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60812. }
  60813. /**
  60814. * The Observable class is a simple implementation of the Observable pattern.
  60815. *
  60816. * 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.
  60817. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60818. * 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).
  60819. * 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.
  60820. */
  60821. export class Observable<T> {
  60822. private _observers;
  60823. private _eventState;
  60824. private _onObserverAdded;
  60825. /**
  60826. * Creates a new observable
  60827. * @param onObserverAdded defines a callback to call when a new observer is added
  60828. */
  60829. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60830. /**
  60831. * Create a new Observer with the specified callback
  60832. * @param callback the callback that will be executed for that Observer
  60833. * @param mask the mask used to filter observers
  60834. * @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.
  60835. * @param scope optional scope for the callback to be called from
  60836. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60837. * @returns the new observer created for the callback
  60838. */
  60839. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60840. /**
  60841. * Create a new Observer with the specified callback and unregisters after the next notification
  60842. * @param callback the callback that will be executed for that Observer
  60843. * @returns the new observer created for the callback
  60844. */
  60845. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60846. /**
  60847. * Remove an Observer from the Observable object
  60848. * @param observer the instance of the Observer to remove
  60849. * @returns false if it doesn't belong to this Observable
  60850. */
  60851. remove(observer: Nullable<Observer<T>>): boolean;
  60852. /**
  60853. * Remove a callback from the Observable object
  60854. * @param callback the callback to remove
  60855. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60856. * @returns false if it doesn't belong to this Observable
  60857. */
  60858. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60859. private _deferUnregister;
  60860. private _remove;
  60861. /**
  60862. * Notify all Observers by calling their respective callback with the given data
  60863. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60864. * @param eventData defines the data to send to all observers
  60865. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60866. * @param target defines the original target of the state
  60867. * @param currentTarget defines the current target of the state
  60868. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60869. */
  60870. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60871. /**
  60872. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60873. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60874. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60875. * and it is crucial that all callbacks will be executed.
  60876. * The order of the callbacks is kept, callbacks are not executed parallel.
  60877. *
  60878. * @param eventData The data to be sent to each callback
  60879. * @param mask is used to filter observers defaults to -1
  60880. * @param target defines the callback target (see EventState)
  60881. * @param currentTarget defines he current object in the bubbling phase
  60882. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60883. */
  60884. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60885. /**
  60886. * Notify a specific observer
  60887. * @param observer defines the observer to notify
  60888. * @param eventData defines the data to be sent to each callback
  60889. * @param mask is used to filter observers defaults to -1
  60890. */
  60891. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60892. /**
  60893. * Gets a boolean indicating if the observable has at least one observer
  60894. * @returns true is the Observable has at least one Observer registered
  60895. */
  60896. hasObservers(): boolean;
  60897. /**
  60898. * Clear the list of observers
  60899. */
  60900. clear(): void;
  60901. /**
  60902. * Clone the current observable
  60903. * @returns a new observable
  60904. */
  60905. clone(): Observable<T>;
  60906. /**
  60907. * Does this observable handles observer registered with a given mask
  60908. * @param mask defines the mask to be tested
  60909. * @return whether or not one observer registered with the given mask is handeled
  60910. **/
  60911. hasSpecificMask(mask?: number): boolean;
  60912. }
  60913. }
  60914. declare module BABYLON {
  60915. /**
  60916. * Class used to help managing file picking and drag'n'drop
  60917. * File Storage
  60918. */
  60919. export class FilesInputStore {
  60920. /**
  60921. * List of files ready to be loaded
  60922. */
  60923. static FilesToLoad: {
  60924. [key: string]: File;
  60925. };
  60926. }
  60927. }
  60928. declare module BABYLON {
  60929. /** Defines the cross module used constants to avoid circular dependncies */
  60930. export class Constants {
  60931. /** Defines that alpha blending is disabled */
  60932. static readonly ALPHA_DISABLE: number;
  60933. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60934. static readonly ALPHA_ADD: number;
  60935. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60936. static readonly ALPHA_COMBINE: number;
  60937. /** Defines that alpha blending to DEST - SRC * DEST */
  60938. static readonly ALPHA_SUBTRACT: number;
  60939. /** Defines that alpha blending to SRC * DEST */
  60940. static readonly ALPHA_MULTIPLY: number;
  60941. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60942. static readonly ALPHA_MAXIMIZED: number;
  60943. /** Defines that alpha blending to SRC + DEST */
  60944. static readonly ALPHA_ONEONE: number;
  60945. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60946. static readonly ALPHA_PREMULTIPLIED: number;
  60947. /**
  60948. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60949. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60950. */
  60951. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60952. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60953. static readonly ALPHA_INTERPOLATE: number;
  60954. /**
  60955. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60956. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60957. */
  60958. static readonly ALPHA_SCREENMODE: number;
  60959. /** Defines that the ressource is not delayed*/
  60960. static readonly DELAYLOADSTATE_NONE: number;
  60961. /** Defines that the ressource was successfully delay loaded */
  60962. static readonly DELAYLOADSTATE_LOADED: number;
  60963. /** Defines that the ressource is currently delay loading */
  60964. static readonly DELAYLOADSTATE_LOADING: number;
  60965. /** Defines that the ressource is delayed and has not started loading */
  60966. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60968. static readonly NEVER: number;
  60969. /** 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 */
  60970. static readonly ALWAYS: number;
  60971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60972. static readonly LESS: number;
  60973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60974. static readonly EQUAL: number;
  60975. /** 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 */
  60976. static readonly LEQUAL: number;
  60977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60978. static readonly GREATER: number;
  60979. /** 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 */
  60980. static readonly GEQUAL: number;
  60981. /** 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 */
  60982. static readonly NOTEQUAL: number;
  60983. /** Passed to stencilOperation to specify that stencil value must be kept */
  60984. static readonly KEEP: number;
  60985. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60986. static readonly REPLACE: number;
  60987. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60988. static readonly INCR: number;
  60989. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60990. static readonly DECR: number;
  60991. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60992. static readonly INVERT: number;
  60993. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60994. static readonly INCR_WRAP: number;
  60995. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60996. static readonly DECR_WRAP: number;
  60997. /** Texture is not repeating outside of 0..1 UVs */
  60998. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60999. /** Texture is repeating outside of 0..1 UVs */
  61000. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61001. /** Texture is repeating and mirrored */
  61002. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61003. /** ALPHA */
  61004. static readonly TEXTUREFORMAT_ALPHA: number;
  61005. /** LUMINANCE */
  61006. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61007. /** LUMINANCE_ALPHA */
  61008. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61009. /** RGB */
  61010. static readonly TEXTUREFORMAT_RGB: number;
  61011. /** RGBA */
  61012. static readonly TEXTUREFORMAT_RGBA: number;
  61013. /** RED */
  61014. static readonly TEXTUREFORMAT_RED: number;
  61015. /** RED (2nd reference) */
  61016. static readonly TEXTUREFORMAT_R: number;
  61017. /** RG */
  61018. static readonly TEXTUREFORMAT_RG: number;
  61019. /** RED_INTEGER */
  61020. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61021. /** RED_INTEGER (2nd reference) */
  61022. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61023. /** RG_INTEGER */
  61024. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61025. /** RGB_INTEGER */
  61026. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61027. /** RGBA_INTEGER */
  61028. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61029. /** UNSIGNED_BYTE */
  61030. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61031. /** UNSIGNED_BYTE (2nd reference) */
  61032. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61033. /** FLOAT */
  61034. static readonly TEXTURETYPE_FLOAT: number;
  61035. /** HALF_FLOAT */
  61036. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61037. /** BYTE */
  61038. static readonly TEXTURETYPE_BYTE: number;
  61039. /** SHORT */
  61040. static readonly TEXTURETYPE_SHORT: number;
  61041. /** UNSIGNED_SHORT */
  61042. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61043. /** INT */
  61044. static readonly TEXTURETYPE_INT: number;
  61045. /** UNSIGNED_INT */
  61046. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61047. /** UNSIGNED_SHORT_4_4_4_4 */
  61048. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61049. /** UNSIGNED_SHORT_5_5_5_1 */
  61050. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61051. /** UNSIGNED_SHORT_5_6_5 */
  61052. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61053. /** UNSIGNED_INT_2_10_10_10_REV */
  61054. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61055. /** UNSIGNED_INT_24_8 */
  61056. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61057. /** UNSIGNED_INT_10F_11F_11F_REV */
  61058. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61059. /** UNSIGNED_INT_5_9_9_9_REV */
  61060. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61061. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61062. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61063. /** nearest is mag = nearest and min = nearest and mip = linear */
  61064. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61065. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61066. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61067. /** Trilinear is mag = linear and min = linear and mip = linear */
  61068. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61069. /** nearest is mag = nearest and min = nearest and mip = linear */
  61070. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61071. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61072. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61073. /** Trilinear is mag = linear and min = linear and mip = linear */
  61074. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61075. /** mag = nearest and min = nearest and mip = nearest */
  61076. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61077. /** mag = nearest and min = linear and mip = nearest */
  61078. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61079. /** mag = nearest and min = linear and mip = linear */
  61080. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61081. /** mag = nearest and min = linear and mip = none */
  61082. static readonly TEXTURE_NEAREST_LINEAR: number;
  61083. /** mag = nearest and min = nearest and mip = none */
  61084. static readonly TEXTURE_NEAREST_NEAREST: number;
  61085. /** mag = linear and min = nearest and mip = nearest */
  61086. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61087. /** mag = linear and min = nearest and mip = linear */
  61088. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61089. /** mag = linear and min = linear and mip = none */
  61090. static readonly TEXTURE_LINEAR_LINEAR: number;
  61091. /** mag = linear and min = nearest and mip = none */
  61092. static readonly TEXTURE_LINEAR_NEAREST: number;
  61093. /** Explicit coordinates mode */
  61094. static readonly TEXTURE_EXPLICIT_MODE: number;
  61095. /** Spherical coordinates mode */
  61096. static readonly TEXTURE_SPHERICAL_MODE: number;
  61097. /** Planar coordinates mode */
  61098. static readonly TEXTURE_PLANAR_MODE: number;
  61099. /** Cubic coordinates mode */
  61100. static readonly TEXTURE_CUBIC_MODE: number;
  61101. /** Projection coordinates mode */
  61102. static readonly TEXTURE_PROJECTION_MODE: number;
  61103. /** Skybox coordinates mode */
  61104. static readonly TEXTURE_SKYBOX_MODE: number;
  61105. /** Inverse Cubic coordinates mode */
  61106. static readonly TEXTURE_INVCUBIC_MODE: number;
  61107. /** Equirectangular coordinates mode */
  61108. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61109. /** Equirectangular Fixed coordinates mode */
  61110. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61111. /** Equirectangular Fixed Mirrored coordinates mode */
  61112. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61113. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61114. static readonly SCALEMODE_FLOOR: number;
  61115. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61116. static readonly SCALEMODE_NEAREST: number;
  61117. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61118. static readonly SCALEMODE_CEILING: number;
  61119. /**
  61120. * The dirty texture flag value
  61121. */
  61122. static readonly MATERIAL_TextureDirtyFlag: number;
  61123. /**
  61124. * The dirty light flag value
  61125. */
  61126. static readonly MATERIAL_LightDirtyFlag: number;
  61127. /**
  61128. * The dirty fresnel flag value
  61129. */
  61130. static readonly MATERIAL_FresnelDirtyFlag: number;
  61131. /**
  61132. * The dirty attribute flag value
  61133. */
  61134. static readonly MATERIAL_AttributesDirtyFlag: number;
  61135. /**
  61136. * The dirty misc flag value
  61137. */
  61138. static readonly MATERIAL_MiscDirtyFlag: number;
  61139. /**
  61140. * The all dirty flag value
  61141. */
  61142. static readonly MATERIAL_AllDirtyFlag: number;
  61143. /**
  61144. * Returns the triangle fill mode
  61145. */
  61146. static readonly MATERIAL_TriangleFillMode: number;
  61147. /**
  61148. * Returns the wireframe mode
  61149. */
  61150. static readonly MATERIAL_WireFrameFillMode: number;
  61151. /**
  61152. * Returns the point fill mode
  61153. */
  61154. static readonly MATERIAL_PointFillMode: number;
  61155. /**
  61156. * Returns the point list draw mode
  61157. */
  61158. static readonly MATERIAL_PointListDrawMode: number;
  61159. /**
  61160. * Returns the line list draw mode
  61161. */
  61162. static readonly MATERIAL_LineListDrawMode: number;
  61163. /**
  61164. * Returns the line loop draw mode
  61165. */
  61166. static readonly MATERIAL_LineLoopDrawMode: number;
  61167. /**
  61168. * Returns the line strip draw mode
  61169. */
  61170. static readonly MATERIAL_LineStripDrawMode: number;
  61171. /**
  61172. * Returns the triangle strip draw mode
  61173. */
  61174. static readonly MATERIAL_TriangleStripDrawMode: number;
  61175. /**
  61176. * Returns the triangle fan draw mode
  61177. */
  61178. static readonly MATERIAL_TriangleFanDrawMode: number;
  61179. /**
  61180. * Stores the clock-wise side orientation
  61181. */
  61182. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61183. /**
  61184. * Stores the counter clock-wise side orientation
  61185. */
  61186. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61187. /**
  61188. * Nothing
  61189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61190. */
  61191. static readonly ACTION_NothingTrigger: number;
  61192. /**
  61193. * On pick
  61194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61195. */
  61196. static readonly ACTION_OnPickTrigger: number;
  61197. /**
  61198. * On left pick
  61199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61200. */
  61201. static readonly ACTION_OnLeftPickTrigger: number;
  61202. /**
  61203. * On right pick
  61204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61205. */
  61206. static readonly ACTION_OnRightPickTrigger: number;
  61207. /**
  61208. * On center pick
  61209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61210. */
  61211. static readonly ACTION_OnCenterPickTrigger: number;
  61212. /**
  61213. * On pick down
  61214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61215. */
  61216. static readonly ACTION_OnPickDownTrigger: number;
  61217. /**
  61218. * On double pick
  61219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61220. */
  61221. static readonly ACTION_OnDoublePickTrigger: number;
  61222. /**
  61223. * On pick up
  61224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61225. */
  61226. static readonly ACTION_OnPickUpTrigger: number;
  61227. /**
  61228. * On pick out.
  61229. * This trigger will only be raised if you also declared a OnPickDown
  61230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61231. */
  61232. static readonly ACTION_OnPickOutTrigger: number;
  61233. /**
  61234. * On long press
  61235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61236. */
  61237. static readonly ACTION_OnLongPressTrigger: number;
  61238. /**
  61239. * On pointer over
  61240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61241. */
  61242. static readonly ACTION_OnPointerOverTrigger: number;
  61243. /**
  61244. * On pointer out
  61245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61246. */
  61247. static readonly ACTION_OnPointerOutTrigger: number;
  61248. /**
  61249. * On every frame
  61250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61251. */
  61252. static readonly ACTION_OnEveryFrameTrigger: number;
  61253. /**
  61254. * On intersection enter
  61255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61256. */
  61257. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61258. /**
  61259. * On intersection exit
  61260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61261. */
  61262. static readonly ACTION_OnIntersectionExitTrigger: number;
  61263. /**
  61264. * On key down
  61265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61266. */
  61267. static readonly ACTION_OnKeyDownTrigger: number;
  61268. /**
  61269. * On key up
  61270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61271. */
  61272. static readonly ACTION_OnKeyUpTrigger: number;
  61273. /**
  61274. * Billboard mode will only apply to Y axis
  61275. */
  61276. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61277. /**
  61278. * Billboard mode will apply to all axes
  61279. */
  61280. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61281. /**
  61282. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61283. */
  61284. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61285. /**
  61286. * Gets or sets base Assets URL
  61287. */
  61288. static readonly PARTICLES_BaseAssetsUrl: string;
  61289. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61290. * Test order :
  61291. * Is the bounding sphere outside the frustum ?
  61292. * If not, are the bounding box vertices outside the frustum ?
  61293. * It not, then the cullable object is in the frustum.
  61294. */
  61295. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61296. /** Culling strategy : Bounding Sphere Only.
  61297. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61298. * It's also less accurate than the standard because some not visible objects can still be selected.
  61299. * Test : is the bounding sphere outside the frustum ?
  61300. * If not, then the cullable object is in the frustum.
  61301. */
  61302. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61303. /** Culling strategy : Optimistic Inclusion.
  61304. * This in an inclusion test first, then the standard exclusion test.
  61305. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61306. * 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.
  61307. * Anyway, it's as accurate as the standard strategy.
  61308. * Test :
  61309. * Is the cullable object bounding sphere center in the frustum ?
  61310. * If not, apply the default culling strategy.
  61311. */
  61312. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61313. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61314. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61315. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61316. * 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.
  61317. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61318. * Test :
  61319. * Is the cullable object bounding sphere center in the frustum ?
  61320. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61321. */
  61322. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61323. /**
  61324. * No logging while loading
  61325. */
  61326. static readonly SCENELOADER_NO_LOGGING: number;
  61327. /**
  61328. * Minimal logging while loading
  61329. */
  61330. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61331. /**
  61332. * Summary logging while loading
  61333. */
  61334. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61335. /**
  61336. * Detailled logging while loading
  61337. */
  61338. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61339. }
  61340. }
  61341. declare module BABYLON {
  61342. /**
  61343. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61344. * Babylon.js
  61345. */
  61346. export class DomManagement {
  61347. /**
  61348. * Checks if the window object exists
  61349. * @returns true if the window object exists
  61350. */
  61351. static IsWindowObjectExist(): boolean;
  61352. /**
  61353. * Extracts text content from a DOM element hierarchy
  61354. * @param element defines the root element
  61355. * @returns a string
  61356. */
  61357. static GetDOMTextContent(element: HTMLElement): string;
  61358. }
  61359. }
  61360. declare module BABYLON {
  61361. /**
  61362. * Logger used througouht the application to allow configuration of
  61363. * the log level required for the messages.
  61364. */
  61365. export class Logger {
  61366. /**
  61367. * No log
  61368. */
  61369. static readonly NoneLogLevel: number;
  61370. /**
  61371. * Only message logs
  61372. */
  61373. static readonly MessageLogLevel: number;
  61374. /**
  61375. * Only warning logs
  61376. */
  61377. static readonly WarningLogLevel: number;
  61378. /**
  61379. * Only error logs
  61380. */
  61381. static readonly ErrorLogLevel: number;
  61382. /**
  61383. * All logs
  61384. */
  61385. static readonly AllLogLevel: number;
  61386. private static _LogCache;
  61387. /**
  61388. * Gets a value indicating the number of loading errors
  61389. * @ignorenaming
  61390. */
  61391. static errorsCount: number;
  61392. /**
  61393. * Callback called when a new log is added
  61394. */
  61395. static OnNewCacheEntry: (entry: string) => void;
  61396. private static _AddLogEntry;
  61397. private static _FormatMessage;
  61398. private static _LogDisabled;
  61399. private static _LogEnabled;
  61400. private static _WarnDisabled;
  61401. private static _WarnEnabled;
  61402. private static _ErrorDisabled;
  61403. private static _ErrorEnabled;
  61404. /**
  61405. * Log a message to the console
  61406. */
  61407. static Log: (message: string) => void;
  61408. /**
  61409. * Write a warning message to the console
  61410. */
  61411. static Warn: (message: string) => void;
  61412. /**
  61413. * Write an error message to the console
  61414. */
  61415. static Error: (message: string) => void;
  61416. /**
  61417. * Gets current log cache (list of logs)
  61418. */
  61419. static readonly LogCache: string;
  61420. /**
  61421. * Clears the log cache
  61422. */
  61423. static ClearLogCache(): void;
  61424. /**
  61425. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61426. */
  61427. static LogLevels: number;
  61428. }
  61429. }
  61430. declare module BABYLON {
  61431. /** @hidden */
  61432. export class _TypeStore {
  61433. /** @hidden */
  61434. static RegisteredTypes: {
  61435. [key: string]: Object;
  61436. };
  61437. /** @hidden */
  61438. static GetClass(fqdn: string): any;
  61439. }
  61440. }
  61441. declare module BABYLON {
  61442. /**
  61443. * Class containing a set of static utilities functions for deep copy.
  61444. */
  61445. export class DeepCopier {
  61446. /**
  61447. * Tries to copy an object by duplicating every property
  61448. * @param source defines the source object
  61449. * @param destination defines the target object
  61450. * @param doNotCopyList defines a list of properties to avoid
  61451. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61452. */
  61453. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61454. }
  61455. }
  61456. declare module BABYLON {
  61457. /**
  61458. * Class containing a set of static utilities functions for precision date
  61459. */
  61460. export class PrecisionDate {
  61461. /**
  61462. * Gets either window.performance.now() if supported or Date.now() else
  61463. */
  61464. static readonly Now: number;
  61465. }
  61466. }
  61467. declare module BABYLON {
  61468. /** @hidden */
  61469. export class _DevTools {
  61470. static WarnImport(name: string): string;
  61471. }
  61472. }
  61473. declare module BABYLON {
  61474. /**
  61475. * Class used to evalaute queries containing `and` and `or` operators
  61476. */
  61477. export class AndOrNotEvaluator {
  61478. /**
  61479. * Evaluate a query
  61480. * @param query defines the query to evaluate
  61481. * @param evaluateCallback defines the callback used to filter result
  61482. * @returns true if the query matches
  61483. */
  61484. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61485. private static _HandleParenthesisContent;
  61486. private static _SimplifyNegation;
  61487. }
  61488. }
  61489. declare module BABYLON {
  61490. /**
  61491. * Class used to store custom tags
  61492. */
  61493. export class Tags {
  61494. /**
  61495. * Adds support for tags on the given object
  61496. * @param obj defines the object to use
  61497. */
  61498. static EnableFor(obj: any): void;
  61499. /**
  61500. * Removes tags support
  61501. * @param obj defines the object to use
  61502. */
  61503. static DisableFor(obj: any): void;
  61504. /**
  61505. * Gets a boolean indicating if the given object has tags
  61506. * @param obj defines the object to use
  61507. * @returns a boolean
  61508. */
  61509. static HasTags(obj: any): boolean;
  61510. /**
  61511. * Gets the tags available on a given object
  61512. * @param obj defines the object to use
  61513. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61514. * @returns the tags
  61515. */
  61516. static GetTags(obj: any, asString?: boolean): any;
  61517. /**
  61518. * Adds tags to an object
  61519. * @param obj defines the object to use
  61520. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61521. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61522. */
  61523. static AddTagsTo(obj: any, tagsString: string): void;
  61524. /**
  61525. * @hidden
  61526. */
  61527. static _AddTagTo(obj: any, tag: string): void;
  61528. /**
  61529. * Removes specific tags from a specific object
  61530. * @param obj defines the object to use
  61531. * @param tagsString defines the tags to remove
  61532. */
  61533. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61534. /**
  61535. * @hidden
  61536. */
  61537. static _RemoveTagFrom(obj: any, tag: string): void;
  61538. /**
  61539. * Defines if tags hosted on an object match a given query
  61540. * @param obj defines the object to use
  61541. * @param tagsQuery defines the tag query
  61542. * @returns a boolean
  61543. */
  61544. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61545. }
  61546. }
  61547. declare module BABYLON {
  61548. /**
  61549. * Manages the defines for the Material
  61550. */
  61551. export class MaterialDefines {
  61552. private _keys;
  61553. private _isDirty;
  61554. /** @hidden */
  61555. _renderId: number;
  61556. /** @hidden */
  61557. _areLightsDirty: boolean;
  61558. /** @hidden */
  61559. _areAttributesDirty: boolean;
  61560. /** @hidden */
  61561. _areTexturesDirty: boolean;
  61562. /** @hidden */
  61563. _areFresnelDirty: boolean;
  61564. /** @hidden */
  61565. _areMiscDirty: boolean;
  61566. /** @hidden */
  61567. _areImageProcessingDirty: boolean;
  61568. /** @hidden */
  61569. _normals: boolean;
  61570. /** @hidden */
  61571. _uvs: boolean;
  61572. /** @hidden */
  61573. _needNormals: boolean;
  61574. /** @hidden */
  61575. _needUVs: boolean;
  61576. /**
  61577. * Specifies if the material needs to be re-calculated
  61578. */
  61579. readonly isDirty: boolean;
  61580. /**
  61581. * Marks the material to indicate that it has been re-calculated
  61582. */
  61583. markAsProcessed(): void;
  61584. /**
  61585. * Marks the material to indicate that it needs to be re-calculated
  61586. */
  61587. markAsUnprocessed(): void;
  61588. /**
  61589. * Marks the material to indicate all of its defines need to be re-calculated
  61590. */
  61591. markAllAsDirty(): void;
  61592. /**
  61593. * Marks the material to indicate that image processing needs to be re-calculated
  61594. */
  61595. markAsImageProcessingDirty(): void;
  61596. /**
  61597. * Marks the material to indicate the lights need to be re-calculated
  61598. */
  61599. markAsLightDirty(): void;
  61600. /**
  61601. * Marks the attribute state as changed
  61602. */
  61603. markAsAttributesDirty(): void;
  61604. /**
  61605. * Marks the texture state as changed
  61606. */
  61607. markAsTexturesDirty(): void;
  61608. /**
  61609. * Marks the fresnel state as changed
  61610. */
  61611. markAsFresnelDirty(): void;
  61612. /**
  61613. * Marks the misc state as changed
  61614. */
  61615. markAsMiscDirty(): void;
  61616. /**
  61617. * Rebuilds the material defines
  61618. */
  61619. rebuild(): void;
  61620. /**
  61621. * Specifies if two material defines are equal
  61622. * @param other - A material define instance to compare to
  61623. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61624. */
  61625. isEqual(other: MaterialDefines): boolean;
  61626. /**
  61627. * Clones this instance's defines to another instance
  61628. * @param other - material defines to clone values to
  61629. */
  61630. cloneTo(other: MaterialDefines): void;
  61631. /**
  61632. * Resets the material define values
  61633. */
  61634. reset(): void;
  61635. /**
  61636. * Converts the material define values to a string
  61637. * @returns - String of material define information
  61638. */
  61639. toString(): string;
  61640. }
  61641. }
  61642. declare module BABYLON {
  61643. /**
  61644. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61645. */
  61646. export class PerformanceMonitor {
  61647. private _enabled;
  61648. private _rollingFrameTime;
  61649. private _lastFrameTimeMs;
  61650. /**
  61651. * constructor
  61652. * @param frameSampleSize The number of samples required to saturate the sliding window
  61653. */
  61654. constructor(frameSampleSize?: number);
  61655. /**
  61656. * Samples current frame
  61657. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61658. */
  61659. sampleFrame(timeMs?: number): void;
  61660. /**
  61661. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61662. */
  61663. readonly averageFrameTime: number;
  61664. /**
  61665. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61666. */
  61667. readonly averageFrameTimeVariance: number;
  61668. /**
  61669. * Returns the frame time of the most recent frame
  61670. */
  61671. readonly instantaneousFrameTime: number;
  61672. /**
  61673. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61674. */
  61675. readonly averageFPS: number;
  61676. /**
  61677. * Returns the average framerate in frames per second using the most recent frame time
  61678. */
  61679. readonly instantaneousFPS: number;
  61680. /**
  61681. * Returns true if enough samples have been taken to completely fill the sliding window
  61682. */
  61683. readonly isSaturated: boolean;
  61684. /**
  61685. * Enables contributions to the sliding window sample set
  61686. */
  61687. enable(): void;
  61688. /**
  61689. * Disables contributions to the sliding window sample set
  61690. * Samples will not be interpolated over the disabled period
  61691. */
  61692. disable(): void;
  61693. /**
  61694. * Returns true if sampling is enabled
  61695. */
  61696. readonly isEnabled: boolean;
  61697. /**
  61698. * Resets performance monitor
  61699. */
  61700. reset(): void;
  61701. }
  61702. /**
  61703. * RollingAverage
  61704. *
  61705. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61706. */
  61707. export class RollingAverage {
  61708. /**
  61709. * Current average
  61710. */
  61711. average: number;
  61712. /**
  61713. * Current variance
  61714. */
  61715. variance: number;
  61716. protected _samples: Array<number>;
  61717. protected _sampleCount: number;
  61718. protected _pos: number;
  61719. protected _m2: number;
  61720. /**
  61721. * constructor
  61722. * @param length The number of samples required to saturate the sliding window
  61723. */
  61724. constructor(length: number);
  61725. /**
  61726. * Adds a sample to the sample set
  61727. * @param v The sample value
  61728. */
  61729. add(v: number): void;
  61730. /**
  61731. * Returns previously added values or null if outside of history or outside the sliding window domain
  61732. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61733. * @return Value previously recorded with add() or null if outside of range
  61734. */
  61735. history(i: number): number;
  61736. /**
  61737. * Returns true if enough samples have been taken to completely fill the sliding window
  61738. * @return true if sample-set saturated
  61739. */
  61740. isSaturated(): boolean;
  61741. /**
  61742. * Resets the rolling average (equivalent to 0 samples taken so far)
  61743. */
  61744. reset(): void;
  61745. /**
  61746. * Wraps a value around the sample range boundaries
  61747. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61748. * @return Wrapped position in sample range
  61749. */
  61750. protected _wrapPosition(i: number): number;
  61751. }
  61752. }
  61753. declare module BABYLON {
  61754. /**
  61755. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61756. * The underlying implementation relies on an associative array to ensure the best performances.
  61757. * The value can be anything including 'null' but except 'undefined'
  61758. */
  61759. export class StringDictionary<T> {
  61760. /**
  61761. * This will clear this dictionary and copy the content from the 'source' one.
  61762. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61763. * @param source the dictionary to take the content from and copy to this dictionary
  61764. */
  61765. copyFrom(source: StringDictionary<T>): void;
  61766. /**
  61767. * Get a value based from its key
  61768. * @param key the given key to get the matching value from
  61769. * @return the value if found, otherwise undefined is returned
  61770. */
  61771. get(key: string): T | undefined;
  61772. /**
  61773. * Get a value from its key or add it if it doesn't exist.
  61774. * This method will ensure you that a given key/data will be present in the dictionary.
  61775. * @param key the given key to get the matching value from
  61776. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61777. * The factory will only be invoked if there's no data for the given key.
  61778. * @return the value corresponding to the key.
  61779. */
  61780. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61781. /**
  61782. * Get a value from its key if present in the dictionary otherwise add it
  61783. * @param key the key to get the value from
  61784. * @param val if there's no such key/value pair in the dictionary add it with this value
  61785. * @return the value corresponding to the key
  61786. */
  61787. getOrAdd(key: string, val: T): T;
  61788. /**
  61789. * Check if there's a given key in the dictionary
  61790. * @param key the key to check for
  61791. * @return true if the key is present, false otherwise
  61792. */
  61793. contains(key: string): boolean;
  61794. /**
  61795. * Add a new key and its corresponding value
  61796. * @param key the key to add
  61797. * @param value the value corresponding to the key
  61798. * @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
  61799. */
  61800. add(key: string, value: T): boolean;
  61801. /**
  61802. * Update a specific value associated to a key
  61803. * @param key defines the key to use
  61804. * @param value defines the value to store
  61805. * @returns true if the value was updated (or false if the key was not found)
  61806. */
  61807. set(key: string, value: T): boolean;
  61808. /**
  61809. * Get the element of the given key and remove it from the dictionary
  61810. * @param key defines the key to search
  61811. * @returns the value associated with the key or null if not found
  61812. */
  61813. getAndRemove(key: string): Nullable<T>;
  61814. /**
  61815. * Remove a key/value from the dictionary.
  61816. * @param key the key to remove
  61817. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61818. */
  61819. remove(key: string): boolean;
  61820. /**
  61821. * Clear the whole content of the dictionary
  61822. */
  61823. clear(): void;
  61824. /**
  61825. * Gets the current count
  61826. */
  61827. readonly count: number;
  61828. /**
  61829. * Execute a callback on each key/val of the dictionary.
  61830. * Note that you can remove any element in this dictionary in the callback implementation
  61831. * @param callback the callback to execute on a given key/value pair
  61832. */
  61833. forEach(callback: (key: string, val: T) => void): void;
  61834. /**
  61835. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61836. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61837. * Note that you can remove any element in this dictionary in the callback implementation
  61838. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61839. * @returns the first item
  61840. */
  61841. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61842. private _count;
  61843. private _data;
  61844. }
  61845. }
  61846. declare module BABYLON {
  61847. /**
  61848. * Helper class that provides a small promise polyfill
  61849. */
  61850. export class PromisePolyfill {
  61851. /**
  61852. * Static function used to check if the polyfill is required
  61853. * If this is the case then the function will inject the polyfill to window.Promise
  61854. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61855. */
  61856. static Apply(force?: boolean): void;
  61857. }
  61858. }
  61859. declare module BABYLON {
  61860. /**
  61861. * Class used to store data that will be store in GPU memory
  61862. */
  61863. export class Buffer {
  61864. private _engine;
  61865. private _buffer;
  61866. /** @hidden */
  61867. _data: Nullable<DataArray>;
  61868. private _updatable;
  61869. private _instanced;
  61870. /**
  61871. * Gets the byte stride.
  61872. */
  61873. readonly byteStride: number;
  61874. /**
  61875. * Constructor
  61876. * @param engine the engine
  61877. * @param data the data to use for this buffer
  61878. * @param updatable whether the data is updatable
  61879. * @param stride the stride (optional)
  61880. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61881. * @param instanced whether the buffer is instanced (optional)
  61882. * @param useBytes set to true if the stride in in bytes (optional)
  61883. */
  61884. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61885. /**
  61886. * Create a new VertexBuffer based on the current buffer
  61887. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61888. * @param offset defines offset in the buffer (0 by default)
  61889. * @param size defines the size in floats of attributes (position is 3 for instance)
  61890. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61891. * @param instanced defines if the vertex buffer contains indexed data
  61892. * @param useBytes defines if the offset and stride are in bytes
  61893. * @returns the new vertex buffer
  61894. */
  61895. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61896. /**
  61897. * Gets a boolean indicating if the Buffer is updatable?
  61898. * @returns true if the buffer is updatable
  61899. */
  61900. isUpdatable(): boolean;
  61901. /**
  61902. * Gets current buffer's data
  61903. * @returns a DataArray or null
  61904. */
  61905. getData(): Nullable<DataArray>;
  61906. /**
  61907. * Gets underlying native buffer
  61908. * @returns underlying native buffer
  61909. */
  61910. getBuffer(): Nullable<WebGLBuffer>;
  61911. /**
  61912. * Gets the stride in float32 units (i.e. byte stride / 4).
  61913. * May not be an integer if the byte stride is not divisible by 4.
  61914. * DEPRECATED. Use byteStride instead.
  61915. * @returns the stride in float32 units
  61916. */
  61917. getStrideSize(): number;
  61918. /**
  61919. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61920. * @param data defines the data to store
  61921. */
  61922. create(data?: Nullable<DataArray>): void;
  61923. /** @hidden */
  61924. _rebuild(): void;
  61925. /**
  61926. * Update current buffer data
  61927. * @param data defines the data to store
  61928. */
  61929. update(data: DataArray): void;
  61930. /**
  61931. * Updates the data directly.
  61932. * @param data the new data
  61933. * @param offset the new offset
  61934. * @param vertexCount the vertex count (optional)
  61935. * @param useBytes set to true if the offset is in bytes
  61936. */
  61937. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61938. /**
  61939. * Release all resources
  61940. */
  61941. dispose(): void;
  61942. }
  61943. /**
  61944. * Specialized buffer used to store vertex data
  61945. */
  61946. export class VertexBuffer {
  61947. /** @hidden */
  61948. _buffer: Buffer;
  61949. private _kind;
  61950. private _size;
  61951. private _ownsBuffer;
  61952. private _instanced;
  61953. private _instanceDivisor;
  61954. /**
  61955. * The byte type.
  61956. */
  61957. static readonly BYTE: number;
  61958. /**
  61959. * The unsigned byte type.
  61960. */
  61961. static readonly UNSIGNED_BYTE: number;
  61962. /**
  61963. * The short type.
  61964. */
  61965. static readonly SHORT: number;
  61966. /**
  61967. * The unsigned short type.
  61968. */
  61969. static readonly UNSIGNED_SHORT: number;
  61970. /**
  61971. * The integer type.
  61972. */
  61973. static readonly INT: number;
  61974. /**
  61975. * The unsigned integer type.
  61976. */
  61977. static readonly UNSIGNED_INT: number;
  61978. /**
  61979. * The float type.
  61980. */
  61981. static readonly FLOAT: number;
  61982. /**
  61983. * Gets or sets the instance divisor when in instanced mode
  61984. */
  61985. instanceDivisor: number;
  61986. /**
  61987. * Gets the byte stride.
  61988. */
  61989. readonly byteStride: number;
  61990. /**
  61991. * Gets the byte offset.
  61992. */
  61993. readonly byteOffset: number;
  61994. /**
  61995. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61996. */
  61997. readonly normalized: boolean;
  61998. /**
  61999. * Gets the data type of each component in the array.
  62000. */
  62001. readonly type: number;
  62002. /**
  62003. * Constructor
  62004. * @param engine the engine
  62005. * @param data the data to use for this vertex buffer
  62006. * @param kind the vertex buffer kind
  62007. * @param updatable whether the data is updatable
  62008. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62009. * @param stride the stride (optional)
  62010. * @param instanced whether the buffer is instanced (optional)
  62011. * @param offset the offset of the data (optional)
  62012. * @param size the number of components (optional)
  62013. * @param type the type of the component (optional)
  62014. * @param normalized whether the data contains normalized data (optional)
  62015. * @param useBytes set to true if stride and offset are in bytes (optional)
  62016. */
  62017. 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);
  62018. /** @hidden */
  62019. _rebuild(): void;
  62020. /**
  62021. * Returns the kind of the VertexBuffer (string)
  62022. * @returns a string
  62023. */
  62024. getKind(): string;
  62025. /**
  62026. * Gets a boolean indicating if the VertexBuffer is updatable?
  62027. * @returns true if the buffer is updatable
  62028. */
  62029. isUpdatable(): boolean;
  62030. /**
  62031. * Gets current buffer's data
  62032. * @returns a DataArray or null
  62033. */
  62034. getData(): Nullable<DataArray>;
  62035. /**
  62036. * Gets underlying native buffer
  62037. * @returns underlying native buffer
  62038. */
  62039. getBuffer(): Nullable<WebGLBuffer>;
  62040. /**
  62041. * Gets the stride in float32 units (i.e. byte stride / 4).
  62042. * May not be an integer if the byte stride is not divisible by 4.
  62043. * DEPRECATED. Use byteStride instead.
  62044. * @returns the stride in float32 units
  62045. */
  62046. getStrideSize(): number;
  62047. /**
  62048. * Returns the offset as a multiple of the type byte length.
  62049. * DEPRECATED. Use byteOffset instead.
  62050. * @returns the offset in bytes
  62051. */
  62052. getOffset(): number;
  62053. /**
  62054. * Returns the number of components per vertex attribute (integer)
  62055. * @returns the size in float
  62056. */
  62057. getSize(): number;
  62058. /**
  62059. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62060. * @returns true if this buffer is instanced
  62061. */
  62062. getIsInstanced(): boolean;
  62063. /**
  62064. * Returns the instancing divisor, zero for non-instanced (integer).
  62065. * @returns a number
  62066. */
  62067. getInstanceDivisor(): number;
  62068. /**
  62069. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62070. * @param data defines the data to store
  62071. */
  62072. create(data?: DataArray): void;
  62073. /**
  62074. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62075. * This function will create a new buffer if the current one is not updatable
  62076. * @param data defines the data to store
  62077. */
  62078. update(data: DataArray): void;
  62079. /**
  62080. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62081. * Returns the directly updated WebGLBuffer.
  62082. * @param data the new data
  62083. * @param offset the new offset
  62084. * @param useBytes set to true if the offset is in bytes
  62085. */
  62086. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62087. /**
  62088. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62089. */
  62090. dispose(): void;
  62091. /**
  62092. * Enumerates each value of this vertex buffer as numbers.
  62093. * @param count the number of values to enumerate
  62094. * @param callback the callback function called for each value
  62095. */
  62096. forEach(count: number, callback: (value: number, index: number) => void): void;
  62097. /**
  62098. * Positions
  62099. */
  62100. static readonly PositionKind: string;
  62101. /**
  62102. * Normals
  62103. */
  62104. static readonly NormalKind: string;
  62105. /**
  62106. * Tangents
  62107. */
  62108. static readonly TangentKind: string;
  62109. /**
  62110. * Texture coordinates
  62111. */
  62112. static readonly UVKind: string;
  62113. /**
  62114. * Texture coordinates 2
  62115. */
  62116. static readonly UV2Kind: string;
  62117. /**
  62118. * Texture coordinates 3
  62119. */
  62120. static readonly UV3Kind: string;
  62121. /**
  62122. * Texture coordinates 4
  62123. */
  62124. static readonly UV4Kind: string;
  62125. /**
  62126. * Texture coordinates 5
  62127. */
  62128. static readonly UV5Kind: string;
  62129. /**
  62130. * Texture coordinates 6
  62131. */
  62132. static readonly UV6Kind: string;
  62133. /**
  62134. * Colors
  62135. */
  62136. static readonly ColorKind: string;
  62137. /**
  62138. * Matrix indices (for bones)
  62139. */
  62140. static readonly MatricesIndicesKind: string;
  62141. /**
  62142. * Matrix weights (for bones)
  62143. */
  62144. static readonly MatricesWeightsKind: string;
  62145. /**
  62146. * Additional matrix indices (for bones)
  62147. */
  62148. static readonly MatricesIndicesExtraKind: string;
  62149. /**
  62150. * Additional matrix weights (for bones)
  62151. */
  62152. static readonly MatricesWeightsExtraKind: string;
  62153. /**
  62154. * Deduces the stride given a kind.
  62155. * @param kind The kind string to deduce
  62156. * @returns The deduced stride
  62157. */
  62158. static DeduceStride(kind: string): number;
  62159. /**
  62160. * Gets the byte length of the given type.
  62161. * @param type the type
  62162. * @returns the number of bytes
  62163. */
  62164. static GetTypeByteLength(type: number): number;
  62165. /**
  62166. * Enumerates each value of the given parameters as numbers.
  62167. * @param data the data to enumerate
  62168. * @param byteOffset the byte offset of the data
  62169. * @param byteStride the byte stride of the data
  62170. * @param componentCount the number of components per element
  62171. * @param componentType the type of the component
  62172. * @param count the total number of components
  62173. * @param normalized whether the data is normalized
  62174. * @param callback the callback function called for each value
  62175. */
  62176. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62177. private static _GetFloatValue;
  62178. }
  62179. }
  62180. declare module BABYLON {
  62181. /**
  62182. * Class representing spherical polynomial coefficients to the 3rd degree
  62183. */
  62184. export class SphericalPolynomial {
  62185. /**
  62186. * The x coefficients of the spherical polynomial
  62187. */
  62188. x: Vector3;
  62189. /**
  62190. * The y coefficients of the spherical polynomial
  62191. */
  62192. y: Vector3;
  62193. /**
  62194. * The z coefficients of the spherical polynomial
  62195. */
  62196. z: Vector3;
  62197. /**
  62198. * The xx coefficients of the spherical polynomial
  62199. */
  62200. xx: Vector3;
  62201. /**
  62202. * The yy coefficients of the spherical polynomial
  62203. */
  62204. yy: Vector3;
  62205. /**
  62206. * The zz coefficients of the spherical polynomial
  62207. */
  62208. zz: Vector3;
  62209. /**
  62210. * The xy coefficients of the spherical polynomial
  62211. */
  62212. xy: Vector3;
  62213. /**
  62214. * The yz coefficients of the spherical polynomial
  62215. */
  62216. yz: Vector3;
  62217. /**
  62218. * The zx coefficients of the spherical polynomial
  62219. */
  62220. zx: Vector3;
  62221. /**
  62222. * Adds an ambient color to the spherical polynomial
  62223. * @param color the color to add
  62224. */
  62225. addAmbient(color: Color3): void;
  62226. /**
  62227. * Scales the spherical polynomial by the given amount
  62228. * @param scale the amount to scale
  62229. */
  62230. scale(scale: number): void;
  62231. /**
  62232. * Gets the spherical polynomial from harmonics
  62233. * @param harmonics the spherical harmonics
  62234. * @returns the spherical polynomial
  62235. */
  62236. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62237. /**
  62238. * Constructs a spherical polynomial from an array.
  62239. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62240. * @returns the spherical polynomial
  62241. */
  62242. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62243. }
  62244. /**
  62245. * Class representing spherical harmonics coefficients to the 3rd degree
  62246. */
  62247. export class SphericalHarmonics {
  62248. /**
  62249. * The l0,0 coefficients of the spherical harmonics
  62250. */
  62251. l00: Vector3;
  62252. /**
  62253. * The l1,-1 coefficients of the spherical harmonics
  62254. */
  62255. l1_1: Vector3;
  62256. /**
  62257. * The l1,0 coefficients of the spherical harmonics
  62258. */
  62259. l10: Vector3;
  62260. /**
  62261. * The l1,1 coefficients of the spherical harmonics
  62262. */
  62263. l11: Vector3;
  62264. /**
  62265. * The l2,-2 coefficients of the spherical harmonics
  62266. */
  62267. l2_2: Vector3;
  62268. /**
  62269. * The l2,-1 coefficients of the spherical harmonics
  62270. */
  62271. l2_1: Vector3;
  62272. /**
  62273. * The l2,0 coefficients of the spherical harmonics
  62274. */
  62275. l20: Vector3;
  62276. /**
  62277. * The l2,1 coefficients of the spherical harmonics
  62278. */
  62279. l21: Vector3;
  62280. /**
  62281. * The l2,2 coefficients of the spherical harmonics
  62282. */
  62283. lL22: Vector3;
  62284. /**
  62285. * Adds a light to the spherical harmonics
  62286. * @param direction the direction of the light
  62287. * @param color the color of the light
  62288. * @param deltaSolidAngle the delta solid angle of the light
  62289. */
  62290. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62291. /**
  62292. * Scales the spherical harmonics by the given amount
  62293. * @param scale the amount to scale
  62294. */
  62295. scale(scale: number): void;
  62296. /**
  62297. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62298. *
  62299. * ```
  62300. * E_lm = A_l * L_lm
  62301. * ```
  62302. *
  62303. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62304. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62305. * the scaling factors are given in equation 9.
  62306. */
  62307. convertIncidentRadianceToIrradiance(): void;
  62308. /**
  62309. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62310. *
  62311. * ```
  62312. * L = (1/pi) * E * rho
  62313. * ```
  62314. *
  62315. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62316. */
  62317. convertIrradianceToLambertianRadiance(): void;
  62318. /**
  62319. * Gets the spherical harmonics from polynomial
  62320. * @param polynomial the spherical polynomial
  62321. * @returns the spherical harmonics
  62322. */
  62323. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62324. /**
  62325. * Constructs a spherical harmonics from an array.
  62326. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62327. * @returns the spherical harmonics
  62328. */
  62329. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62330. }
  62331. }
  62332. declare module BABYLON {
  62333. /**
  62334. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62335. */
  62336. export interface CubeMapInfo {
  62337. /**
  62338. * The pixel array for the front face.
  62339. * This is stored in format, left to right, up to down format.
  62340. */
  62341. front: Nullable<ArrayBufferView>;
  62342. /**
  62343. * The pixel array for the back face.
  62344. * This is stored in format, left to right, up to down format.
  62345. */
  62346. back: Nullable<ArrayBufferView>;
  62347. /**
  62348. * The pixel array for the left face.
  62349. * This is stored in format, left to right, up to down format.
  62350. */
  62351. left: Nullable<ArrayBufferView>;
  62352. /**
  62353. * The pixel array for the right face.
  62354. * This is stored in format, left to right, up to down format.
  62355. */
  62356. right: Nullable<ArrayBufferView>;
  62357. /**
  62358. * The pixel array for the up face.
  62359. * This is stored in format, left to right, up to down format.
  62360. */
  62361. up: Nullable<ArrayBufferView>;
  62362. /**
  62363. * The pixel array for the down face.
  62364. * This is stored in format, left to right, up to down format.
  62365. */
  62366. down: Nullable<ArrayBufferView>;
  62367. /**
  62368. * The size of the cubemap stored.
  62369. *
  62370. * Each faces will be size * size pixels.
  62371. */
  62372. size: number;
  62373. /**
  62374. * The format of the texture.
  62375. *
  62376. * RGBA, RGB.
  62377. */
  62378. format: number;
  62379. /**
  62380. * The type of the texture data.
  62381. *
  62382. * UNSIGNED_INT, FLOAT.
  62383. */
  62384. type: number;
  62385. /**
  62386. * Specifies whether the texture is in gamma space.
  62387. */
  62388. gammaSpace: boolean;
  62389. }
  62390. /**
  62391. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62392. */
  62393. export class PanoramaToCubeMapTools {
  62394. private static FACE_FRONT;
  62395. private static FACE_BACK;
  62396. private static FACE_RIGHT;
  62397. private static FACE_LEFT;
  62398. private static FACE_DOWN;
  62399. private static FACE_UP;
  62400. /**
  62401. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62402. *
  62403. * @param float32Array The source data.
  62404. * @param inputWidth The width of the input panorama.
  62405. * @param inputHeight The height of the input panorama.
  62406. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62407. * @return The cubemap data
  62408. */
  62409. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62410. private static CreateCubemapTexture;
  62411. private static CalcProjectionSpherical;
  62412. }
  62413. }
  62414. declare module BABYLON {
  62415. /**
  62416. * Helper class dealing with the extraction of spherical polynomial dataArray
  62417. * from a cube map.
  62418. */
  62419. export class CubeMapToSphericalPolynomialTools {
  62420. private static FileFaces;
  62421. /**
  62422. * Converts a texture to the according Spherical Polynomial data.
  62423. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62424. *
  62425. * @param texture The texture to extract the information from.
  62426. * @return The Spherical Polynomial data.
  62427. */
  62428. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62429. /**
  62430. * Converts a cubemap to the according Spherical Polynomial data.
  62431. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62432. *
  62433. * @param cubeInfo The Cube map to extract the information from.
  62434. * @return The Spherical Polynomial data.
  62435. */
  62436. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62442. * during the life time of the application.
  62443. */
  62444. export class EngineStore {
  62445. /** Gets the list of created engines */
  62446. static Instances: Engine[];
  62447. /**
  62448. * Gets the latest created engine
  62449. */
  62450. static readonly LastCreatedEngine: Nullable<Engine>;
  62451. /**
  62452. * Gets the latest created scene
  62453. */
  62454. static readonly LastCreatedScene: Nullable<Scene>;
  62455. }
  62456. }
  62457. declare module BABYLON {
  62458. /**
  62459. * Define options used to create a render target texture
  62460. */
  62461. export class RenderTargetCreationOptions {
  62462. /**
  62463. * Specifies is mipmaps must be generated
  62464. */
  62465. generateMipMaps?: boolean;
  62466. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62467. generateDepthBuffer?: boolean;
  62468. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62469. generateStencilBuffer?: boolean;
  62470. /** Defines texture type (int by default) */
  62471. type?: number;
  62472. /** Defines sampling mode (trilinear by default) */
  62473. samplingMode?: number;
  62474. /** Defines format (RGBA by default) */
  62475. format?: number;
  62476. }
  62477. }
  62478. declare module BABYLON {
  62479. /**
  62480. * @hidden
  62481. **/
  62482. export class _AlphaState {
  62483. private _isAlphaBlendDirty;
  62484. private _isBlendFunctionParametersDirty;
  62485. private _isBlendEquationParametersDirty;
  62486. private _isBlendConstantsDirty;
  62487. private _alphaBlend;
  62488. private _blendFunctionParameters;
  62489. private _blendEquationParameters;
  62490. private _blendConstants;
  62491. /**
  62492. * Initializes the state.
  62493. */
  62494. constructor();
  62495. readonly isDirty: boolean;
  62496. alphaBlend: boolean;
  62497. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62498. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62499. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62500. reset(): void;
  62501. apply(gl: WebGLRenderingContext): void;
  62502. }
  62503. }
  62504. declare module BABYLON {
  62505. /**
  62506. * @hidden
  62507. **/
  62508. export class _DepthCullingState {
  62509. private _isDepthTestDirty;
  62510. private _isDepthMaskDirty;
  62511. private _isDepthFuncDirty;
  62512. private _isCullFaceDirty;
  62513. private _isCullDirty;
  62514. private _isZOffsetDirty;
  62515. private _isFrontFaceDirty;
  62516. private _depthTest;
  62517. private _depthMask;
  62518. private _depthFunc;
  62519. private _cull;
  62520. private _cullFace;
  62521. private _zOffset;
  62522. private _frontFace;
  62523. /**
  62524. * Initializes the state.
  62525. */
  62526. constructor();
  62527. readonly isDirty: boolean;
  62528. zOffset: number;
  62529. cullFace: Nullable<number>;
  62530. cull: Nullable<boolean>;
  62531. depthFunc: Nullable<number>;
  62532. depthMask: boolean;
  62533. depthTest: boolean;
  62534. frontFace: Nullable<number>;
  62535. reset(): void;
  62536. apply(gl: WebGLRenderingContext): void;
  62537. }
  62538. }
  62539. declare module BABYLON {
  62540. /**
  62541. * @hidden
  62542. **/
  62543. export class _StencilState {
  62544. /** 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 */
  62545. static readonly ALWAYS: number;
  62546. /** Passed to stencilOperation to specify that stencil value must be kept */
  62547. static readonly KEEP: number;
  62548. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62549. static readonly REPLACE: number;
  62550. private _isStencilTestDirty;
  62551. private _isStencilMaskDirty;
  62552. private _isStencilFuncDirty;
  62553. private _isStencilOpDirty;
  62554. private _stencilTest;
  62555. private _stencilMask;
  62556. private _stencilFunc;
  62557. private _stencilFuncRef;
  62558. private _stencilFuncMask;
  62559. private _stencilOpStencilFail;
  62560. private _stencilOpDepthFail;
  62561. private _stencilOpStencilDepthPass;
  62562. readonly isDirty: boolean;
  62563. stencilFunc: number;
  62564. stencilFuncRef: number;
  62565. stencilFuncMask: number;
  62566. stencilOpStencilFail: number;
  62567. stencilOpDepthFail: number;
  62568. stencilOpStencilDepthPass: number;
  62569. stencilMask: number;
  62570. stencilTest: boolean;
  62571. constructor();
  62572. reset(): void;
  62573. apply(gl: WebGLRenderingContext): void;
  62574. }
  62575. }
  62576. declare module BABYLON {
  62577. /**
  62578. * @hidden
  62579. **/
  62580. export class _TimeToken {
  62581. _startTimeQuery: Nullable<WebGLQuery>;
  62582. _endTimeQuery: Nullable<WebGLQuery>;
  62583. _timeElapsedQuery: Nullable<WebGLQuery>;
  62584. _timeElapsedQueryEnded: boolean;
  62585. }
  62586. }
  62587. declare module BABYLON {
  62588. /**
  62589. * Internal interface used to track InternalTexture already bound to the GL context
  62590. */
  62591. export interface IInternalTextureTracker {
  62592. /**
  62593. * Gets or set the previous tracker in the list
  62594. */
  62595. previous: Nullable<IInternalTextureTracker>;
  62596. /**
  62597. * Gets or set the next tracker in the list
  62598. */
  62599. next: Nullable<IInternalTextureTracker>;
  62600. }
  62601. /**
  62602. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62603. */
  62604. export class DummyInternalTextureTracker {
  62605. /**
  62606. * Gets or set the previous tracker in the list
  62607. */
  62608. previous: Nullable<IInternalTextureTracker>;
  62609. /**
  62610. * Gets or set the next tracker in the list
  62611. */
  62612. next: Nullable<IInternalTextureTracker>;
  62613. }
  62614. }
  62615. declare module BABYLON {
  62616. /**
  62617. * Class used to store data associated with WebGL texture data for the engine
  62618. * This class should not be used directly
  62619. */
  62620. export class InternalTexture implements IInternalTextureTracker {
  62621. /** hidden */
  62622. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62623. /**
  62624. * The source of the texture data is unknown
  62625. */
  62626. static DATASOURCE_UNKNOWN: number;
  62627. /**
  62628. * Texture data comes from an URL
  62629. */
  62630. static DATASOURCE_URL: number;
  62631. /**
  62632. * Texture data is only used for temporary storage
  62633. */
  62634. static DATASOURCE_TEMP: number;
  62635. /**
  62636. * Texture data comes from raw data (ArrayBuffer)
  62637. */
  62638. static DATASOURCE_RAW: number;
  62639. /**
  62640. * Texture content is dynamic (video or dynamic texture)
  62641. */
  62642. static DATASOURCE_DYNAMIC: number;
  62643. /**
  62644. * Texture content is generated by rendering to it
  62645. */
  62646. static DATASOURCE_RENDERTARGET: number;
  62647. /**
  62648. * Texture content is part of a multi render target process
  62649. */
  62650. static DATASOURCE_MULTIRENDERTARGET: number;
  62651. /**
  62652. * Texture data comes from a cube data file
  62653. */
  62654. static DATASOURCE_CUBE: number;
  62655. /**
  62656. * Texture data comes from a raw cube data
  62657. */
  62658. static DATASOURCE_CUBERAW: number;
  62659. /**
  62660. * Texture data come from a prefiltered cube data file
  62661. */
  62662. static DATASOURCE_CUBEPREFILTERED: number;
  62663. /**
  62664. * Texture content is raw 3D data
  62665. */
  62666. static DATASOURCE_RAW3D: number;
  62667. /**
  62668. * Texture content is a depth texture
  62669. */
  62670. static DATASOURCE_DEPTHTEXTURE: number;
  62671. /**
  62672. * Texture data comes from a raw cube data encoded with RGBD
  62673. */
  62674. static DATASOURCE_CUBERAW_RGBD: number;
  62675. /**
  62676. * Defines if the texture is ready
  62677. */
  62678. isReady: boolean;
  62679. /**
  62680. * Defines if the texture is a cube texture
  62681. */
  62682. isCube: boolean;
  62683. /**
  62684. * Defines if the texture contains 3D data
  62685. */
  62686. is3D: boolean;
  62687. /**
  62688. * Gets the URL used to load this texture
  62689. */
  62690. url: string;
  62691. /**
  62692. * Gets the sampling mode of the texture
  62693. */
  62694. samplingMode: number;
  62695. /**
  62696. * Gets a boolean indicating if the texture needs mipmaps generation
  62697. */
  62698. generateMipMaps: boolean;
  62699. /**
  62700. * Gets the number of samples used by the texture (WebGL2+ only)
  62701. */
  62702. samples: number;
  62703. /**
  62704. * Gets the type of the texture (int, float...)
  62705. */
  62706. type: number;
  62707. /**
  62708. * Gets the format of the texture (RGB, RGBA...)
  62709. */
  62710. format: number;
  62711. /**
  62712. * Observable called when the texture is loaded
  62713. */
  62714. onLoadedObservable: Observable<InternalTexture>;
  62715. /**
  62716. * Gets the width of the texture
  62717. */
  62718. width: number;
  62719. /**
  62720. * Gets the height of the texture
  62721. */
  62722. height: number;
  62723. /**
  62724. * Gets the depth of the texture
  62725. */
  62726. depth: number;
  62727. /**
  62728. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62729. */
  62730. baseWidth: number;
  62731. /**
  62732. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62733. */
  62734. baseHeight: number;
  62735. /**
  62736. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62737. */
  62738. baseDepth: number;
  62739. /**
  62740. * Gets a boolean indicating if the texture is inverted on Y axis
  62741. */
  62742. invertY: boolean;
  62743. /**
  62744. * Gets or set the previous tracker in the list
  62745. */
  62746. previous: Nullable<IInternalTextureTracker>;
  62747. /**
  62748. * Gets or set the next tracker in the list
  62749. */
  62750. next: Nullable<IInternalTextureTracker>;
  62751. /** @hidden */
  62752. _invertVScale: boolean;
  62753. /** @hidden */
  62754. _initialSlot: number;
  62755. /** @hidden */
  62756. _designatedSlot: number;
  62757. /** @hidden */
  62758. _dataSource: number;
  62759. /** @hidden */
  62760. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62761. /** @hidden */
  62762. _bufferView: Nullable<ArrayBufferView>;
  62763. /** @hidden */
  62764. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62765. /** @hidden */
  62766. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62767. /** @hidden */
  62768. _size: number;
  62769. /** @hidden */
  62770. _extension: string;
  62771. /** @hidden */
  62772. _files: Nullable<string[]>;
  62773. /** @hidden */
  62774. _workingCanvas: HTMLCanvasElement;
  62775. /** @hidden */
  62776. _workingContext: CanvasRenderingContext2D;
  62777. /** @hidden */
  62778. _framebuffer: Nullable<WebGLFramebuffer>;
  62779. /** @hidden */
  62780. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62781. /** @hidden */
  62782. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62783. /** @hidden */
  62784. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62785. /** @hidden */
  62786. _attachments: Nullable<number[]>;
  62787. /** @hidden */
  62788. _cachedCoordinatesMode: Nullable<number>;
  62789. /** @hidden */
  62790. _cachedWrapU: Nullable<number>;
  62791. /** @hidden */
  62792. _cachedWrapV: Nullable<number>;
  62793. /** @hidden */
  62794. _cachedWrapR: Nullable<number>;
  62795. /** @hidden */
  62796. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62797. /** @hidden */
  62798. _isDisabled: boolean;
  62799. /** @hidden */
  62800. _compression: Nullable<string>;
  62801. /** @hidden */
  62802. _generateStencilBuffer: boolean;
  62803. /** @hidden */
  62804. _generateDepthBuffer: boolean;
  62805. /** @hidden */
  62806. _comparisonFunction: number;
  62807. /** @hidden */
  62808. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62809. /** @hidden */
  62810. _lodGenerationScale: number;
  62811. /** @hidden */
  62812. _lodGenerationOffset: number;
  62813. /** @hidden */
  62814. _lodTextureHigh: BaseTexture;
  62815. /** @hidden */
  62816. _lodTextureMid: BaseTexture;
  62817. /** @hidden */
  62818. _lodTextureLow: BaseTexture;
  62819. /** @hidden */
  62820. _isRGBD: boolean;
  62821. /** @hidden */
  62822. _webGLTexture: Nullable<WebGLTexture>;
  62823. /** @hidden */
  62824. _references: number;
  62825. private _engine;
  62826. /**
  62827. * Gets the Engine the texture belongs to.
  62828. * @returns The babylon engine
  62829. */
  62830. getEngine(): Engine;
  62831. /**
  62832. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62833. */
  62834. readonly dataSource: number;
  62835. /**
  62836. * Creates a new InternalTexture
  62837. * @param engine defines the engine to use
  62838. * @param dataSource defines the type of data that will be used
  62839. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62840. */
  62841. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62842. /**
  62843. * Increments the number of references (ie. the number of Texture that point to it)
  62844. */
  62845. incrementReferences(): void;
  62846. /**
  62847. * Change the size of the texture (not the size of the content)
  62848. * @param width defines the new width
  62849. * @param height defines the new height
  62850. * @param depth defines the new depth (1 by default)
  62851. */
  62852. updateSize(width: int, height: int, depth?: int): void;
  62853. /** @hidden */
  62854. _rebuild(): void;
  62855. /** @hidden */
  62856. _swapAndDie(target: InternalTexture): void;
  62857. /**
  62858. * Dispose the current allocated resources
  62859. */
  62860. dispose(): void;
  62861. }
  62862. }
  62863. declare module BABYLON {
  62864. /**
  62865. * This represents the main contract an easing function should follow.
  62866. * Easing functions are used throughout the animation system.
  62867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62868. */
  62869. export interface IEasingFunction {
  62870. /**
  62871. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62872. * of the easing function.
  62873. * The link below provides some of the most common examples of easing functions.
  62874. * @see https://easings.net/
  62875. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62876. * @returns the corresponding value on the curve defined by the easing function
  62877. */
  62878. ease(gradient: number): number;
  62879. }
  62880. /**
  62881. * Base class used for every default easing function.
  62882. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62883. */
  62884. export class EasingFunction implements IEasingFunction {
  62885. /**
  62886. * Interpolation follows the mathematical formula associated with the easing function.
  62887. */
  62888. static readonly EASINGMODE_EASEIN: number;
  62889. /**
  62890. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62891. */
  62892. static readonly EASINGMODE_EASEOUT: number;
  62893. /**
  62894. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62895. */
  62896. static readonly EASINGMODE_EASEINOUT: number;
  62897. private _easingMode;
  62898. /**
  62899. * Sets the easing mode of the current function.
  62900. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62901. */
  62902. setEasingMode(easingMode: number): void;
  62903. /**
  62904. * Gets the current easing mode.
  62905. * @returns the easing mode
  62906. */
  62907. getEasingMode(): number;
  62908. /**
  62909. * @hidden
  62910. */
  62911. easeInCore(gradient: number): number;
  62912. /**
  62913. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62914. * of the easing function.
  62915. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62916. * @returns the corresponding value on the curve defined by the easing function
  62917. */
  62918. ease(gradient: number): number;
  62919. }
  62920. /**
  62921. * Easing function with a circle shape (see link below).
  62922. * @see https://easings.net/#easeInCirc
  62923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62924. */
  62925. export class CircleEase extends EasingFunction implements IEasingFunction {
  62926. /** @hidden */
  62927. easeInCore(gradient: number): number;
  62928. }
  62929. /**
  62930. * Easing function with a ease back shape (see link below).
  62931. * @see https://easings.net/#easeInBack
  62932. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62933. */
  62934. export class BackEase extends EasingFunction implements IEasingFunction {
  62935. /** Defines the amplitude of the function */
  62936. amplitude: number;
  62937. /**
  62938. * Instantiates a back ease easing
  62939. * @see https://easings.net/#easeInBack
  62940. * @param amplitude Defines the amplitude of the function
  62941. */
  62942. constructor(
  62943. /** Defines the amplitude of the function */
  62944. amplitude?: number);
  62945. /** @hidden */
  62946. easeInCore(gradient: number): number;
  62947. }
  62948. /**
  62949. * Easing function with a bouncing shape (see link below).
  62950. * @see https://easings.net/#easeInBounce
  62951. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62952. */
  62953. export class BounceEase extends EasingFunction implements IEasingFunction {
  62954. /** Defines the number of bounces */
  62955. bounces: number;
  62956. /** Defines the amplitude of the bounce */
  62957. bounciness: number;
  62958. /**
  62959. * Instantiates a bounce easing
  62960. * @see https://easings.net/#easeInBounce
  62961. * @param bounces Defines the number of bounces
  62962. * @param bounciness Defines the amplitude of the bounce
  62963. */
  62964. constructor(
  62965. /** Defines the number of bounces */
  62966. bounces?: number,
  62967. /** Defines the amplitude of the bounce */
  62968. bounciness?: number);
  62969. /** @hidden */
  62970. easeInCore(gradient: number): number;
  62971. }
  62972. /**
  62973. * Easing function with a power of 3 shape (see link below).
  62974. * @see https://easings.net/#easeInCubic
  62975. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62976. */
  62977. export class CubicEase extends EasingFunction implements IEasingFunction {
  62978. /** @hidden */
  62979. easeInCore(gradient: number): number;
  62980. }
  62981. /**
  62982. * Easing function with an elastic shape (see link below).
  62983. * @see https://easings.net/#easeInElastic
  62984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62985. */
  62986. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62987. /** Defines the number of oscillations*/
  62988. oscillations: number;
  62989. /** Defines the amplitude of the oscillations*/
  62990. springiness: number;
  62991. /**
  62992. * Instantiates an elastic easing function
  62993. * @see https://easings.net/#easeInElastic
  62994. * @param oscillations Defines the number of oscillations
  62995. * @param springiness Defines the amplitude of the oscillations
  62996. */
  62997. constructor(
  62998. /** Defines the number of oscillations*/
  62999. oscillations?: number,
  63000. /** Defines the amplitude of the oscillations*/
  63001. springiness?: number);
  63002. /** @hidden */
  63003. easeInCore(gradient: number): number;
  63004. }
  63005. /**
  63006. * Easing function with an exponential shape (see link below).
  63007. * @see https://easings.net/#easeInExpo
  63008. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63009. */
  63010. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63011. /** Defines the exponent of the function */
  63012. exponent: number;
  63013. /**
  63014. * Instantiates an exponential easing function
  63015. * @see https://easings.net/#easeInExpo
  63016. * @param exponent Defines the exponent of the function
  63017. */
  63018. constructor(
  63019. /** Defines the exponent of the function */
  63020. exponent?: number);
  63021. /** @hidden */
  63022. easeInCore(gradient: number): number;
  63023. }
  63024. /**
  63025. * Easing function with a power shape (see link below).
  63026. * @see https://easings.net/#easeInQuad
  63027. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63028. */
  63029. export class PowerEase extends EasingFunction implements IEasingFunction {
  63030. /** Defines the power of the function */
  63031. power: number;
  63032. /**
  63033. * Instantiates an power base easing function
  63034. * @see https://easings.net/#easeInQuad
  63035. * @param power Defines the power of the function
  63036. */
  63037. constructor(
  63038. /** Defines the power of the function */
  63039. power?: number);
  63040. /** @hidden */
  63041. easeInCore(gradient: number): number;
  63042. }
  63043. /**
  63044. * Easing function with a power of 2 shape (see link below).
  63045. * @see https://easings.net/#easeInQuad
  63046. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63047. */
  63048. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63049. /** @hidden */
  63050. easeInCore(gradient: number): number;
  63051. }
  63052. /**
  63053. * Easing function with a power of 4 shape (see link below).
  63054. * @see https://easings.net/#easeInQuart
  63055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63056. */
  63057. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63058. /** @hidden */
  63059. easeInCore(gradient: number): number;
  63060. }
  63061. /**
  63062. * Easing function with a power of 5 shape (see link below).
  63063. * @see https://easings.net/#easeInQuint
  63064. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63065. */
  63066. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63067. /** @hidden */
  63068. easeInCore(gradient: number): number;
  63069. }
  63070. /**
  63071. * Easing function with a sin shape (see link below).
  63072. * @see https://easings.net/#easeInSine
  63073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63074. */
  63075. export class SineEase extends EasingFunction implements IEasingFunction {
  63076. /** @hidden */
  63077. easeInCore(gradient: number): number;
  63078. }
  63079. /**
  63080. * Easing function with a bezier shape (see link below).
  63081. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63083. */
  63084. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63085. /** Defines the x component of the start tangent in the bezier curve */
  63086. x1: number;
  63087. /** Defines the y component of the start tangent in the bezier curve */
  63088. y1: number;
  63089. /** Defines the x component of the end tangent in the bezier curve */
  63090. x2: number;
  63091. /** Defines the y component of the end tangent in the bezier curve */
  63092. y2: number;
  63093. /**
  63094. * Instantiates a bezier function
  63095. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63096. * @param x1 Defines the x component of the start tangent in the bezier curve
  63097. * @param y1 Defines the y component of the start tangent in the bezier curve
  63098. * @param x2 Defines the x component of the end tangent in the bezier curve
  63099. * @param y2 Defines the y component of the end tangent in the bezier curve
  63100. */
  63101. constructor(
  63102. /** Defines the x component of the start tangent in the bezier curve */
  63103. x1?: number,
  63104. /** Defines the y component of the start tangent in the bezier curve */
  63105. y1?: number,
  63106. /** Defines the x component of the end tangent in the bezier curve */
  63107. x2?: number,
  63108. /** Defines the y component of the end tangent in the bezier curve */
  63109. y2?: number);
  63110. /** @hidden */
  63111. easeInCore(gradient: number): number;
  63112. }
  63113. }
  63114. declare module BABYLON {
  63115. /**
  63116. * Defines an interface which represents an animation key frame
  63117. */
  63118. export interface IAnimationKey {
  63119. /**
  63120. * Frame of the key frame
  63121. */
  63122. frame: number;
  63123. /**
  63124. * Value at the specifies key frame
  63125. */
  63126. value: any;
  63127. /**
  63128. * The input tangent for the cubic hermite spline
  63129. */
  63130. inTangent?: any;
  63131. /**
  63132. * The output tangent for the cubic hermite spline
  63133. */
  63134. outTangent?: any;
  63135. /**
  63136. * The animation interpolation type
  63137. */
  63138. interpolation?: AnimationKeyInterpolation;
  63139. }
  63140. /**
  63141. * Enum for the animation key frame interpolation type
  63142. */
  63143. export enum AnimationKeyInterpolation {
  63144. /**
  63145. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63146. */
  63147. STEP = 1
  63148. }
  63149. }
  63150. declare module BABYLON {
  63151. /**
  63152. * Represents the range of an animation
  63153. */
  63154. export class AnimationRange {
  63155. /**The name of the animation range**/
  63156. name: string;
  63157. /**The starting frame of the animation */
  63158. from: number;
  63159. /**The ending frame of the animation*/
  63160. to: number;
  63161. /**
  63162. * Initializes the range of an animation
  63163. * @param name The name of the animation range
  63164. * @param from The starting frame of the animation
  63165. * @param to The ending frame of the animation
  63166. */
  63167. constructor(
  63168. /**The name of the animation range**/
  63169. name: string,
  63170. /**The starting frame of the animation */
  63171. from: number,
  63172. /**The ending frame of the animation*/
  63173. to: number);
  63174. /**
  63175. * Makes a copy of the animation range
  63176. * @returns A copy of the animation range
  63177. */
  63178. clone(): AnimationRange;
  63179. }
  63180. }
  63181. declare module BABYLON {
  63182. /**
  63183. * Composed of a frame, and an action function
  63184. */
  63185. export class AnimationEvent {
  63186. /** The frame for which the event is triggered **/
  63187. frame: number;
  63188. /** The event to perform when triggered **/
  63189. action: (currentFrame: number) => void;
  63190. /** Specifies if the event should be triggered only once**/
  63191. onlyOnce?: boolean | undefined;
  63192. /**
  63193. * Specifies if the animation event is done
  63194. */
  63195. isDone: boolean;
  63196. /**
  63197. * Initializes the animation event
  63198. * @param frame The frame for which the event is triggered
  63199. * @param action The event to perform when triggered
  63200. * @param onlyOnce Specifies if the event should be triggered only once
  63201. */
  63202. constructor(
  63203. /** The frame for which the event is triggered **/
  63204. frame: number,
  63205. /** The event to perform when triggered **/
  63206. action: (currentFrame: number) => void,
  63207. /** Specifies if the event should be triggered only once**/
  63208. onlyOnce?: boolean | undefined);
  63209. /** @hidden */
  63210. _clone(): AnimationEvent;
  63211. }
  63212. }
  63213. declare module BABYLON {
  63214. /**
  63215. * Interface used to define a behavior
  63216. */
  63217. export interface Behavior<T> {
  63218. /** gets or sets behavior's name */
  63219. name: string;
  63220. /**
  63221. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63222. */
  63223. init(): void;
  63224. /**
  63225. * Called when the behavior is attached to a target
  63226. * @param target defines the target where the behavior is attached to
  63227. */
  63228. attach(target: T): void;
  63229. /**
  63230. * Called when the behavior is detached from its target
  63231. */
  63232. detach(): void;
  63233. }
  63234. /**
  63235. * Interface implemented by classes supporting behaviors
  63236. */
  63237. export interface IBehaviorAware<T> {
  63238. /**
  63239. * Attach a behavior
  63240. * @param behavior defines the behavior to attach
  63241. * @returns the current host
  63242. */
  63243. addBehavior(behavior: Behavior<T>): T;
  63244. /**
  63245. * Remove a behavior from the current object
  63246. * @param behavior defines the behavior to detach
  63247. * @returns the current host
  63248. */
  63249. removeBehavior(behavior: Behavior<T>): T;
  63250. /**
  63251. * Gets a behavior using its name to search
  63252. * @param name defines the name to search
  63253. * @returns the behavior or null if not found
  63254. */
  63255. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63256. }
  63257. }
  63258. declare module BABYLON {
  63259. /**
  63260. * Defines a runtime animation
  63261. */
  63262. export class RuntimeAnimation {
  63263. private _events;
  63264. /**
  63265. * The current frame of the runtime animation
  63266. */
  63267. private _currentFrame;
  63268. /**
  63269. * The animation used by the runtime animation
  63270. */
  63271. private _animation;
  63272. /**
  63273. * The target of the runtime animation
  63274. */
  63275. private _target;
  63276. /**
  63277. * The initiating animatable
  63278. */
  63279. private _host;
  63280. /**
  63281. * The original value of the runtime animation
  63282. */
  63283. private _originalValue;
  63284. /**
  63285. * The original blend value of the runtime animation
  63286. */
  63287. private _originalBlendValue;
  63288. /**
  63289. * The offsets cache of the runtime animation
  63290. */
  63291. private _offsetsCache;
  63292. /**
  63293. * The high limits cache of the runtime animation
  63294. */
  63295. private _highLimitsCache;
  63296. /**
  63297. * Specifies if the runtime animation has been stopped
  63298. */
  63299. private _stopped;
  63300. /**
  63301. * The blending factor of the runtime animation
  63302. */
  63303. private _blendingFactor;
  63304. /**
  63305. * The BabylonJS scene
  63306. */
  63307. private _scene;
  63308. /**
  63309. * The current value of the runtime animation
  63310. */
  63311. private _currentValue;
  63312. /** @hidden */
  63313. _workValue: any;
  63314. /**
  63315. * The active target of the runtime animation
  63316. */
  63317. private _activeTarget;
  63318. /**
  63319. * The target path of the runtime animation
  63320. */
  63321. private _targetPath;
  63322. /**
  63323. * The weight of the runtime animation
  63324. */
  63325. private _weight;
  63326. /**
  63327. * The ratio offset of the runtime animation
  63328. */
  63329. private _ratioOffset;
  63330. /**
  63331. * The previous delay of the runtime animation
  63332. */
  63333. private _previousDelay;
  63334. /**
  63335. * The previous ratio of the runtime animation
  63336. */
  63337. private _previousRatio;
  63338. /**
  63339. * Gets the current frame of the runtime animation
  63340. */
  63341. readonly currentFrame: number;
  63342. /**
  63343. * Gets the weight of the runtime animation
  63344. */
  63345. readonly weight: number;
  63346. /**
  63347. * Gets the current value of the runtime animation
  63348. */
  63349. readonly currentValue: any;
  63350. /**
  63351. * Gets the target path of the runtime animation
  63352. */
  63353. readonly targetPath: string;
  63354. /**
  63355. * Gets the actual target of the runtime animation
  63356. */
  63357. readonly target: any;
  63358. /**
  63359. * Create a new RuntimeAnimation object
  63360. * @param target defines the target of the animation
  63361. * @param animation defines the source animation object
  63362. * @param scene defines the hosting scene
  63363. * @param host defines the initiating Animatable
  63364. */
  63365. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  63366. /**
  63367. * Gets the animation from the runtime animation
  63368. */
  63369. readonly animation: Animation;
  63370. /**
  63371. * Resets the runtime animation to the beginning
  63372. * @param restoreOriginal defines whether to restore the target property to the original value
  63373. */
  63374. reset(restoreOriginal?: boolean): void;
  63375. /**
  63376. * Specifies if the runtime animation is stopped
  63377. * @returns Boolean specifying if the runtime animation is stopped
  63378. */
  63379. isStopped(): boolean;
  63380. /**
  63381. * Disposes of the runtime animation
  63382. */
  63383. dispose(): void;
  63384. /**
  63385. * Interpolates the animation from the current frame
  63386. * @param currentFrame The frame to interpolate the animation to
  63387. * @param repeatCount The number of times that the animation should loop
  63388. * @param loopMode The type of looping mode to use
  63389. * @param offsetValue Animation offset value
  63390. * @param highLimitValue The high limit value
  63391. * @returns The interpolated value
  63392. */
  63393. private _interpolate;
  63394. /**
  63395. * Apply the interpolated value to the target
  63396. * @param currentValue defines the value computed by the animation
  63397. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  63398. */
  63399. setValue(currentValue: any, weight?: number): void;
  63400. private _setValue;
  63401. /**
  63402. * Gets the loop pmode of the runtime animation
  63403. * @returns Loop Mode
  63404. */
  63405. private _getCorrectLoopMode;
  63406. /**
  63407. * Move the current animation to a given frame
  63408. * @param frame defines the frame to move to
  63409. */
  63410. goToFrame(frame: number): void;
  63411. /**
  63412. * @hidden Internal use only
  63413. */
  63414. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  63415. /**
  63416. * Execute the current animation
  63417. * @param delay defines the delay to add to the current frame
  63418. * @param from defines the lower bound of the animation range
  63419. * @param to defines the upper bound of the animation range
  63420. * @param loop defines if the current animation must loop
  63421. * @param speedRatio defines the current speed ratio
  63422. * @param weight defines the weight of the animation (default is -1 so no weight)
  63423. * @param onLoop optional callback called when animation loops
  63424. * @returns a boolean indicating if the animation is running
  63425. */
  63426. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * @hidden
  63432. */
  63433. export class IntersectionInfo {
  63434. bu: Nullable<number>;
  63435. bv: Nullable<number>;
  63436. distance: number;
  63437. faceId: number;
  63438. subMeshId: number;
  63439. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63440. }
  63441. }
  63442. declare module BABYLON {
  63443. /**
  63444. * Class used to store bounding sphere information
  63445. */
  63446. export class BoundingSphere {
  63447. /**
  63448. * Gets the center of the bounding sphere in local space
  63449. */
  63450. readonly center: Vector3;
  63451. /**
  63452. * Radius of the bounding sphere in local space
  63453. */
  63454. radius: number;
  63455. /**
  63456. * Gets the center of the bounding sphere in world space
  63457. */
  63458. readonly centerWorld: Vector3;
  63459. /**
  63460. * Radius of the bounding sphere in world space
  63461. */
  63462. radiusWorld: number;
  63463. /**
  63464. * Gets the minimum vector in local space
  63465. */
  63466. readonly minimum: Vector3;
  63467. /**
  63468. * Gets the maximum vector in local space
  63469. */
  63470. readonly maximum: Vector3;
  63471. private _worldMatrix;
  63472. private static readonly TmpVector3;
  63473. /**
  63474. * Creates a new bounding sphere
  63475. * @param min defines the minimum vector (in local space)
  63476. * @param max defines the maximum vector (in local space)
  63477. * @param worldMatrix defines the new world matrix
  63478. */
  63479. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63480. /**
  63481. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63482. * @param min defines the new minimum vector (in local space)
  63483. * @param max defines the new maximum vector (in local space)
  63484. * @param worldMatrix defines the new world matrix
  63485. */
  63486. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63487. /**
  63488. * Scale the current bounding sphere by applying a scale factor
  63489. * @param factor defines the scale factor to apply
  63490. * @returns the current bounding box
  63491. */
  63492. scale(factor: number): BoundingSphere;
  63493. /**
  63494. * Gets the world matrix of the bounding box
  63495. * @returns a matrix
  63496. */
  63497. getWorldMatrix(): DeepImmutable<Matrix>;
  63498. /** @hidden */
  63499. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63500. /**
  63501. * Tests if the bounding sphere is intersecting the frustum planes
  63502. * @param frustumPlanes defines the frustum planes to test
  63503. * @returns true if there is an intersection
  63504. */
  63505. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63506. /**
  63507. * Tests if the bounding sphere center is in between the frustum planes.
  63508. * Used for optimistic fast inclusion.
  63509. * @param frustumPlanes defines the frustum planes to test
  63510. * @returns true if the sphere center is in between the frustum planes
  63511. */
  63512. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63513. /**
  63514. * Tests if a point is inside the bounding sphere
  63515. * @param point defines the point to test
  63516. * @returns true if the point is inside the bounding sphere
  63517. */
  63518. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63519. /**
  63520. * Checks if two sphere intersct
  63521. * @param sphere0 sphere 0
  63522. * @param sphere1 sphere 1
  63523. * @returns true if the speres intersect
  63524. */
  63525. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63526. }
  63527. }
  63528. declare module BABYLON {
  63529. /**
  63530. * Class used to store bounding box information
  63531. */
  63532. export class BoundingBox implements ICullable {
  63533. /**
  63534. * Gets the 8 vectors representing the bounding box in local space
  63535. */
  63536. readonly vectors: Vector3[];
  63537. /**
  63538. * Gets the center of the bounding box in local space
  63539. */
  63540. readonly center: Vector3;
  63541. /**
  63542. * Gets the center of the bounding box in world space
  63543. */
  63544. readonly centerWorld: Vector3;
  63545. /**
  63546. * Gets the extend size in local space
  63547. */
  63548. readonly extendSize: Vector3;
  63549. /**
  63550. * Gets the extend size in world space
  63551. */
  63552. readonly extendSizeWorld: Vector3;
  63553. /**
  63554. * Gets the OBB (object bounding box) directions
  63555. */
  63556. readonly directions: Vector3[];
  63557. /**
  63558. * Gets the 8 vectors representing the bounding box in world space
  63559. */
  63560. readonly vectorsWorld: Vector3[];
  63561. /**
  63562. * Gets the minimum vector in world space
  63563. */
  63564. readonly minimumWorld: Vector3;
  63565. /**
  63566. * Gets the maximum vector in world space
  63567. */
  63568. readonly maximumWorld: Vector3;
  63569. /**
  63570. * Gets the minimum vector in local space
  63571. */
  63572. readonly minimum: Vector3;
  63573. /**
  63574. * Gets the maximum vector in local space
  63575. */
  63576. readonly maximum: Vector3;
  63577. private _worldMatrix;
  63578. private static readonly TmpVector3;
  63579. /**
  63580. * @hidden
  63581. */
  63582. _tag: number;
  63583. /**
  63584. * Creates a new bounding box
  63585. * @param min defines the minimum vector (in local space)
  63586. * @param max defines the maximum vector (in local space)
  63587. * @param worldMatrix defines the new world matrix
  63588. */
  63589. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63590. /**
  63591. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63592. * @param min defines the new minimum vector (in local space)
  63593. * @param max defines the new maximum vector (in local space)
  63594. * @param worldMatrix defines the new world matrix
  63595. */
  63596. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63597. /**
  63598. * Scale the current bounding box by applying a scale factor
  63599. * @param factor defines the scale factor to apply
  63600. * @returns the current bounding box
  63601. */
  63602. scale(factor: number): BoundingBox;
  63603. /**
  63604. * Gets the world matrix of the bounding box
  63605. * @returns a matrix
  63606. */
  63607. getWorldMatrix(): DeepImmutable<Matrix>;
  63608. /** @hidden */
  63609. _update(world: DeepImmutable<Matrix>): void;
  63610. /**
  63611. * Tests if the bounding box is intersecting the frustum planes
  63612. * @param frustumPlanes defines the frustum planes to test
  63613. * @returns true if there is an intersection
  63614. */
  63615. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63616. /**
  63617. * Tests if the bounding box is entirely inside the frustum planes
  63618. * @param frustumPlanes defines the frustum planes to test
  63619. * @returns true if there is an inclusion
  63620. */
  63621. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63622. /**
  63623. * Tests if a point is inside the bounding box
  63624. * @param point defines the point to test
  63625. * @returns true if the point is inside the bounding box
  63626. */
  63627. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63628. /**
  63629. * Tests if the bounding box intersects with a bounding sphere
  63630. * @param sphere defines the sphere to test
  63631. * @returns true if there is an intersection
  63632. */
  63633. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63634. /**
  63635. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63636. * @param min defines the min vector to use
  63637. * @param max defines the max vector to use
  63638. * @returns true if there is an intersection
  63639. */
  63640. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63641. /**
  63642. * Tests if two bounding boxes are intersections
  63643. * @param box0 defines the first box to test
  63644. * @param box1 defines the second box to test
  63645. * @returns true if there is an intersection
  63646. */
  63647. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63648. /**
  63649. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63650. * @param minPoint defines the minimum vector of the bounding box
  63651. * @param maxPoint defines the maximum vector of the bounding box
  63652. * @param sphereCenter defines the sphere center
  63653. * @param sphereRadius defines the sphere radius
  63654. * @returns true if there is an intersection
  63655. */
  63656. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63657. /**
  63658. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63659. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63660. * @param frustumPlanes defines the frustum planes to test
  63661. * @return true if there is an inclusion
  63662. */
  63663. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63664. /**
  63665. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63666. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63667. * @param frustumPlanes defines the frustum planes to test
  63668. * @return true if there is an intersection
  63669. */
  63670. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63671. }
  63672. }
  63673. declare module BABYLON {
  63674. /** @hidden */
  63675. export class Collider {
  63676. /** Define if a collision was found */
  63677. collisionFound: boolean;
  63678. /**
  63679. * Define last intersection point in local space
  63680. */
  63681. intersectionPoint: Vector3;
  63682. /**
  63683. * Define last collided mesh
  63684. */
  63685. collidedMesh: Nullable<AbstractMesh>;
  63686. private _collisionPoint;
  63687. private _planeIntersectionPoint;
  63688. private _tempVector;
  63689. private _tempVector2;
  63690. private _tempVector3;
  63691. private _tempVector4;
  63692. private _edge;
  63693. private _baseToVertex;
  63694. private _destinationPoint;
  63695. private _slidePlaneNormal;
  63696. private _displacementVector;
  63697. /** @hidden */
  63698. _radius: Vector3;
  63699. /** @hidden */
  63700. _retry: number;
  63701. private _velocity;
  63702. private _basePoint;
  63703. private _epsilon;
  63704. /** @hidden */
  63705. _velocityWorldLength: number;
  63706. /** @hidden */
  63707. _basePointWorld: Vector3;
  63708. private _velocityWorld;
  63709. private _normalizedVelocity;
  63710. /** @hidden */
  63711. _initialVelocity: Vector3;
  63712. /** @hidden */
  63713. _initialPosition: Vector3;
  63714. private _nearestDistance;
  63715. private _collisionMask;
  63716. collisionMask: number;
  63717. /**
  63718. * Gets the plane normal used to compute the sliding response (in local space)
  63719. */
  63720. readonly slidePlaneNormal: Vector3;
  63721. /** @hidden */
  63722. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63723. /** @hidden */
  63724. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63725. /** @hidden */
  63726. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63727. /** @hidden */
  63728. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63729. /** @hidden */
  63730. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63731. /** @hidden */
  63732. _getResponse(pos: Vector3, vel: Vector3): void;
  63733. }
  63734. }
  63735. declare module BABYLON {
  63736. /**
  63737. * Interface for cullable objects
  63738. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63739. */
  63740. export interface ICullable {
  63741. /**
  63742. * Checks if the object or part of the object is in the frustum
  63743. * @param frustumPlanes Camera near/planes
  63744. * @returns true if the object is in frustum otherwise false
  63745. */
  63746. isInFrustum(frustumPlanes: Plane[]): boolean;
  63747. /**
  63748. * Checks if a cullable object (mesh...) is in the camera frustum
  63749. * Unlike isInFrustum this cheks the full bounding box
  63750. * @param frustumPlanes Camera near/planes
  63751. * @returns true if the object is in frustum otherwise false
  63752. */
  63753. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63754. }
  63755. /**
  63756. * Info for a bounding data of a mesh
  63757. */
  63758. export class BoundingInfo implements ICullable {
  63759. /**
  63760. * Bounding box for the mesh
  63761. */
  63762. readonly boundingBox: BoundingBox;
  63763. /**
  63764. * Bounding sphere for the mesh
  63765. */
  63766. readonly boundingSphere: BoundingSphere;
  63767. private _isLocked;
  63768. private static readonly TmpVector3;
  63769. /**
  63770. * Constructs bounding info
  63771. * @param minimum min vector of the bounding box/sphere
  63772. * @param maximum max vector of the bounding box/sphere
  63773. * @param worldMatrix defines the new world matrix
  63774. */
  63775. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63776. /**
  63777. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63778. * @param min defines the new minimum vector (in local space)
  63779. * @param max defines the new maximum vector (in local space)
  63780. * @param worldMatrix defines the new world matrix
  63781. */
  63782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63783. /**
  63784. * min vector of the bounding box/sphere
  63785. */
  63786. readonly minimum: Vector3;
  63787. /**
  63788. * max vector of the bounding box/sphere
  63789. */
  63790. readonly maximum: Vector3;
  63791. /**
  63792. * If the info is locked and won't be updated to avoid perf overhead
  63793. */
  63794. isLocked: boolean;
  63795. /**
  63796. * Updates the bounding sphere and box
  63797. * @param world world matrix to be used to update
  63798. */
  63799. update(world: DeepImmutable<Matrix>): void;
  63800. /**
  63801. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63802. * @param center New center of the bounding info
  63803. * @param extend New extend of the bounding info
  63804. * @returns the current bounding info
  63805. */
  63806. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63807. /**
  63808. * Scale the current bounding info by applying a scale factor
  63809. * @param factor defines the scale factor to apply
  63810. * @returns the current bounding info
  63811. */
  63812. scale(factor: number): BoundingInfo;
  63813. /**
  63814. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63815. * @param frustumPlanes defines the frustum to test
  63816. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63817. * @returns true if the bounding info is in the frustum planes
  63818. */
  63819. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63820. /**
  63821. * Gets the world distance between the min and max points of the bounding box
  63822. */
  63823. readonly diagonalLength: number;
  63824. /**
  63825. * Checks if a cullable object (mesh...) is in the camera frustum
  63826. * Unlike isInFrustum this cheks the full bounding box
  63827. * @param frustumPlanes Camera near/planes
  63828. * @returns true if the object is in frustum otherwise false
  63829. */
  63830. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63831. /** @hidden */
  63832. _checkCollision(collider: Collider): boolean;
  63833. /**
  63834. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63835. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63836. * @param point the point to check intersection with
  63837. * @returns if the point intersects
  63838. */
  63839. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63840. /**
  63841. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63842. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63843. * @param boundingInfo the bounding info to check intersection with
  63844. * @param precise if the intersection should be done using OBB
  63845. * @returns if the bounding info intersects
  63846. */
  63847. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63848. }
  63849. }
  63850. declare module BABYLON {
  63851. /**
  63852. * Defines an array and its length.
  63853. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63854. */
  63855. export interface ISmartArrayLike<T> {
  63856. /**
  63857. * The data of the array.
  63858. */
  63859. data: Array<T>;
  63860. /**
  63861. * The active length of the array.
  63862. */
  63863. length: number;
  63864. }
  63865. /**
  63866. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63867. */
  63868. export class SmartArray<T> implements ISmartArrayLike<T> {
  63869. /**
  63870. * The full set of data from the array.
  63871. */
  63872. data: Array<T>;
  63873. /**
  63874. * The active length of the array.
  63875. */
  63876. length: number;
  63877. protected _id: number;
  63878. /**
  63879. * Instantiates a Smart Array.
  63880. * @param capacity defines the default capacity of the array.
  63881. */
  63882. constructor(capacity: number);
  63883. /**
  63884. * Pushes a value at the end of the active data.
  63885. * @param value defines the object to push in the array.
  63886. */
  63887. push(value: T): void;
  63888. /**
  63889. * Iterates over the active data and apply the lambda to them.
  63890. * @param func defines the action to apply on each value.
  63891. */
  63892. forEach(func: (content: T) => void): void;
  63893. /**
  63894. * Sorts the full sets of data.
  63895. * @param compareFn defines the comparison function to apply.
  63896. */
  63897. sort(compareFn: (a: T, b: T) => number): void;
  63898. /**
  63899. * Resets the active data to an empty array.
  63900. */
  63901. reset(): void;
  63902. /**
  63903. * Releases all the data from the array as well as the array.
  63904. */
  63905. dispose(): void;
  63906. /**
  63907. * Concats the active data with a given array.
  63908. * @param array defines the data to concatenate with.
  63909. */
  63910. concat(array: any): void;
  63911. /**
  63912. * Returns the position of a value in the active data.
  63913. * @param value defines the value to find the index for
  63914. * @returns the index if found in the active data otherwise -1
  63915. */
  63916. indexOf(value: T): number;
  63917. /**
  63918. * Returns whether an element is part of the active data.
  63919. * @param value defines the value to look for
  63920. * @returns true if found in the active data otherwise false
  63921. */
  63922. contains(value: T): boolean;
  63923. private static _GlobalId;
  63924. }
  63925. /**
  63926. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63927. * The data in this array can only be present once
  63928. */
  63929. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63930. private _duplicateId;
  63931. /**
  63932. * Pushes a value at the end of the active data.
  63933. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63934. * @param value defines the object to push in the array.
  63935. */
  63936. push(value: T): void;
  63937. /**
  63938. * Pushes a value at the end of the active data.
  63939. * If the data is already present, it won t be added again
  63940. * @param value defines the object to push in the array.
  63941. * @returns true if added false if it was already present
  63942. */
  63943. pushNoDuplicate(value: T): boolean;
  63944. /**
  63945. * Resets the active data to an empty array.
  63946. */
  63947. reset(): void;
  63948. /**
  63949. * Concats the active data with a given array.
  63950. * This ensures no dupplicate will be present in the result.
  63951. * @param array defines the data to concatenate with.
  63952. */
  63953. concatWithNoDuplicate(array: any): void;
  63954. }
  63955. }
  63956. declare module BABYLON {
  63957. /**
  63958. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63959. * separate meshes. This can be use to improve performances.
  63960. * @see http://doc.babylonjs.com/how_to/multi_materials
  63961. */
  63962. export class MultiMaterial extends Material {
  63963. private _subMaterials;
  63964. /**
  63965. * Gets or Sets the list of Materials used within the multi material.
  63966. * They need to be ordered according to the submeshes order in the associated mesh
  63967. */
  63968. subMaterials: Nullable<Material>[];
  63969. /**
  63970. * Function used to align with Node.getChildren()
  63971. * @returns the list of Materials used within the multi material
  63972. */
  63973. getChildren(): Nullable<Material>[];
  63974. /**
  63975. * Instantiates a new Multi Material
  63976. * A multi-material is used to apply different materials to different parts of the same object without the need of
  63977. * separate meshes. This can be use to improve performances.
  63978. * @see http://doc.babylonjs.com/how_to/multi_materials
  63979. * @param name Define the name in the scene
  63980. * @param scene Define the scene the material belongs to
  63981. */
  63982. constructor(name: string, scene: Scene);
  63983. private _hookArray;
  63984. /**
  63985. * Get one of the submaterial by its index in the submaterials array
  63986. * @param index The index to look the sub material at
  63987. * @returns The Material if the index has been defined
  63988. */
  63989. getSubMaterial(index: number): Nullable<Material>;
  63990. /**
  63991. * Get the list of active textures for the whole sub materials list.
  63992. * @returns All the textures that will be used during the rendering
  63993. */
  63994. getActiveTextures(): BaseTexture[];
  63995. /**
  63996. * Gets the current class name of the material e.g. "MultiMaterial"
  63997. * Mainly use in serialization.
  63998. * @returns the class name
  63999. */
  64000. getClassName(): string;
  64001. /**
  64002. * Checks if the material is ready to render the requested sub mesh
  64003. * @param mesh Define the mesh the submesh belongs to
  64004. * @param subMesh Define the sub mesh to look readyness for
  64005. * @param useInstances Define whether or not the material is used with instances
  64006. * @returns true if ready, otherwise false
  64007. */
  64008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64009. /**
  64010. * Clones the current material and its related sub materials
  64011. * @param name Define the name of the newly cloned material
  64012. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64013. * @returns the cloned material
  64014. */
  64015. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64016. /**
  64017. * Serializes the materials into a JSON representation.
  64018. * @returns the JSON representation
  64019. */
  64020. serialize(): any;
  64021. /**
  64022. * Dispose the material and release its associated resources
  64023. * @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)
  64024. * @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)
  64025. * @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)
  64026. */
  64027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64028. /**
  64029. * Creates a MultiMaterial from parsed MultiMaterial data.
  64030. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64031. * @param scene defines the hosting scene
  64032. * @returns a new MultiMaterial
  64033. */
  64034. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /**
  64039. * Class used to represent data loading progression
  64040. */
  64041. export class SceneLoaderFlags {
  64042. private static _ForceFullSceneLoadingForIncremental;
  64043. private static _ShowLoadingScreen;
  64044. private static _CleanBoneMatrixWeights;
  64045. private static _loggingLevel;
  64046. /**
  64047. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64048. */
  64049. static ForceFullSceneLoadingForIncremental: boolean;
  64050. /**
  64051. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64052. */
  64053. static ShowLoadingScreen: boolean;
  64054. /**
  64055. * Defines the current logging level (while loading the scene)
  64056. * @ignorenaming
  64057. */
  64058. static loggingLevel: number;
  64059. /**
  64060. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64061. */
  64062. static CleanBoneMatrixWeights: boolean;
  64063. }
  64064. }
  64065. declare module BABYLON {
  64066. /**
  64067. * Class used to override all child animations of a given target
  64068. */
  64069. export class AnimationPropertiesOverride {
  64070. /**
  64071. * Gets or sets a value indicating if animation blending must be used
  64072. */
  64073. enableBlending: boolean;
  64074. /**
  64075. * Gets or sets the blending speed to use when enableBlending is true
  64076. */
  64077. blendingSpeed: number;
  64078. /**
  64079. * Gets or sets the default loop mode to use
  64080. */
  64081. loopMode: number;
  64082. }
  64083. }
  64084. declare module BABYLON {
  64085. /**
  64086. * Defines a target to use with MorphTargetManager
  64087. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64088. */
  64089. export class MorphTarget implements IAnimatable {
  64090. /** defines the name of the target */
  64091. name: string;
  64092. /**
  64093. * Gets or sets the list of animations
  64094. */
  64095. animations: Animation[];
  64096. private _scene;
  64097. private _positions;
  64098. private _normals;
  64099. private _tangents;
  64100. private _influence;
  64101. /**
  64102. * Observable raised when the influence changes
  64103. */
  64104. onInfluenceChanged: Observable<boolean>;
  64105. /** @hidden */
  64106. _onDataLayoutChanged: Observable<void>;
  64107. /**
  64108. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  64109. */
  64110. influence: number;
  64111. /**
  64112. * Gets or sets the id of the morph Target
  64113. */
  64114. id: string;
  64115. private _animationPropertiesOverride;
  64116. /**
  64117. * Gets or sets the animation properties override
  64118. */
  64119. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64120. /**
  64121. * Creates a new MorphTarget
  64122. * @param name defines the name of the target
  64123. * @param influence defines the influence to use
  64124. * @param scene defines the scene the morphtarget belongs to
  64125. */
  64126. constructor(
  64127. /** defines the name of the target */
  64128. name: string, influence?: number, scene?: Nullable<Scene>);
  64129. /**
  64130. * Gets a boolean defining if the target contains position data
  64131. */
  64132. readonly hasPositions: boolean;
  64133. /**
  64134. * Gets a boolean defining if the target contains normal data
  64135. */
  64136. readonly hasNormals: boolean;
  64137. /**
  64138. * Gets a boolean defining if the target contains tangent data
  64139. */
  64140. readonly hasTangents: boolean;
  64141. /**
  64142. * Affects position data to this target
  64143. * @param data defines the position data to use
  64144. */
  64145. setPositions(data: Nullable<FloatArray>): void;
  64146. /**
  64147. * Gets the position data stored in this target
  64148. * @returns a FloatArray containing the position data (or null if not present)
  64149. */
  64150. getPositions(): Nullable<FloatArray>;
  64151. /**
  64152. * Affects normal data to this target
  64153. * @param data defines the normal data to use
  64154. */
  64155. setNormals(data: Nullable<FloatArray>): void;
  64156. /**
  64157. * Gets the normal data stored in this target
  64158. * @returns a FloatArray containing the normal data (or null if not present)
  64159. */
  64160. getNormals(): Nullable<FloatArray>;
  64161. /**
  64162. * Affects tangent data to this target
  64163. * @param data defines the tangent data to use
  64164. */
  64165. setTangents(data: Nullable<FloatArray>): void;
  64166. /**
  64167. * Gets the tangent data stored in this target
  64168. * @returns a FloatArray containing the tangent data (or null if not present)
  64169. */
  64170. getTangents(): Nullable<FloatArray>;
  64171. /**
  64172. * Serializes the current target into a Serialization object
  64173. * @returns the serialized object
  64174. */
  64175. serialize(): any;
  64176. /**
  64177. * Returns the string "MorphTarget"
  64178. * @returns "MorphTarget"
  64179. */
  64180. getClassName(): string;
  64181. /**
  64182. * Creates a new target from serialized data
  64183. * @param serializationObject defines the serialized data to use
  64184. * @returns a new MorphTarget
  64185. */
  64186. static Parse(serializationObject: any): MorphTarget;
  64187. /**
  64188. * Creates a MorphTarget from mesh data
  64189. * @param mesh defines the source mesh
  64190. * @param name defines the name to use for the new target
  64191. * @param influence defines the influence to attach to the target
  64192. * @returns a new MorphTarget
  64193. */
  64194. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  64195. }
  64196. }
  64197. declare module BABYLON {
  64198. /**
  64199. * This class is used to deform meshes using morphing between different targets
  64200. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  64201. */
  64202. export class MorphTargetManager {
  64203. private _targets;
  64204. private _targetInfluenceChangedObservers;
  64205. private _targetDataLayoutChangedObservers;
  64206. private _activeTargets;
  64207. private _scene;
  64208. private _influences;
  64209. private _supportsNormals;
  64210. private _supportsTangents;
  64211. private _vertexCount;
  64212. private _uniqueId;
  64213. private _tempInfluences;
  64214. /**
  64215. * Creates a new MorphTargetManager
  64216. * @param scene defines the current scene
  64217. */
  64218. constructor(scene?: Nullable<Scene>);
  64219. /**
  64220. * Gets the unique ID of this manager
  64221. */
  64222. readonly uniqueId: number;
  64223. /**
  64224. * Gets the number of vertices handled by this manager
  64225. */
  64226. readonly vertexCount: number;
  64227. /**
  64228. * Gets a boolean indicating if this manager supports morphing of normals
  64229. */
  64230. readonly supportsNormals: boolean;
  64231. /**
  64232. * Gets a boolean indicating if this manager supports morphing of tangents
  64233. */
  64234. readonly supportsTangents: boolean;
  64235. /**
  64236. * Gets the number of targets stored in this manager
  64237. */
  64238. readonly numTargets: number;
  64239. /**
  64240. * Gets the number of influencers (ie. the number of targets with influences > 0)
  64241. */
  64242. readonly numInfluencers: number;
  64243. /**
  64244. * Gets the list of influences (one per target)
  64245. */
  64246. readonly influences: Float32Array;
  64247. /**
  64248. * Gets the active target at specified index. An active target is a target with an influence > 0
  64249. * @param index defines the index to check
  64250. * @returns the requested target
  64251. */
  64252. getActiveTarget(index: number): MorphTarget;
  64253. /**
  64254. * Gets the target at specified index
  64255. * @param index defines the index to check
  64256. * @returns the requested target
  64257. */
  64258. getTarget(index: number): MorphTarget;
  64259. /**
  64260. * Add a new target to this manager
  64261. * @param target defines the target to add
  64262. */
  64263. addTarget(target: MorphTarget): void;
  64264. /**
  64265. * Removes a target from the manager
  64266. * @param target defines the target to remove
  64267. */
  64268. removeTarget(target: MorphTarget): void;
  64269. /**
  64270. * Serializes the current manager into a Serialization object
  64271. * @returns the serialized object
  64272. */
  64273. serialize(): any;
  64274. private _syncActiveTargets;
  64275. /**
  64276. * Syncrhonize the targets with all the meshes using this morph target manager
  64277. */
  64278. synchronize(): void;
  64279. /**
  64280. * Creates a new MorphTargetManager from serialized data
  64281. * @param serializationObject defines the serialized data
  64282. * @param scene defines the hosting scene
  64283. * @returns the new MorphTargetManager
  64284. */
  64285. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  64286. }
  64287. }
  64288. declare module BABYLON {
  64289. /**
  64290. * Creates an instance based on a source mesh.
  64291. */
  64292. export class InstancedMesh extends AbstractMesh {
  64293. private _sourceMesh;
  64294. private _currentLOD;
  64295. /** @hidden */
  64296. _indexInSourceMeshInstanceArray: number;
  64297. constructor(name: string, source: Mesh);
  64298. /**
  64299. * Returns the string "InstancedMesh".
  64300. */
  64301. getClassName(): string;
  64302. /**
  64303. * If the source mesh receives shadows
  64304. */
  64305. readonly receiveShadows: boolean;
  64306. /**
  64307. * The material of the source mesh
  64308. */
  64309. readonly material: Nullable<Material>;
  64310. /**
  64311. * Visibility of the source mesh
  64312. */
  64313. readonly visibility: number;
  64314. /**
  64315. * Skeleton of the source mesh
  64316. */
  64317. readonly skeleton: Nullable<Skeleton>;
  64318. /**
  64319. * Rendering ground id of the source mesh
  64320. */
  64321. renderingGroupId: number;
  64322. /**
  64323. * Returns the total number of vertices (integer).
  64324. */
  64325. getTotalVertices(): number;
  64326. /**
  64327. * Returns a positive integer : the total number of indices in this mesh geometry.
  64328. * @returns the numner of indices or zero if the mesh has no geometry.
  64329. */
  64330. getTotalIndices(): number;
  64331. /**
  64332. * The source mesh of the instance
  64333. */
  64334. readonly sourceMesh: Mesh;
  64335. /**
  64336. * Is this node ready to be used/rendered
  64337. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  64338. * @return {boolean} is it ready
  64339. */
  64340. isReady(completeCheck?: boolean): boolean;
  64341. /**
  64342. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  64343. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  64344. * @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.
  64345. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  64346. */
  64347. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  64348. /**
  64349. * Sets the vertex data of the mesh geometry for the requested `kind`.
  64350. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  64351. * The `data` are either a numeric array either a Float32Array.
  64352. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  64353. * 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).
  64354. * Note that a new underlying VertexBuffer object is created each call.
  64355. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  64356. *
  64357. * Possible `kind` values :
  64358. * - VertexBuffer.PositionKind
  64359. * - VertexBuffer.UVKind
  64360. * - VertexBuffer.UV2Kind
  64361. * - VertexBuffer.UV3Kind
  64362. * - VertexBuffer.UV4Kind
  64363. * - VertexBuffer.UV5Kind
  64364. * - VertexBuffer.UV6Kind
  64365. * - VertexBuffer.ColorKind
  64366. * - VertexBuffer.MatricesIndicesKind
  64367. * - VertexBuffer.MatricesIndicesExtraKind
  64368. * - VertexBuffer.MatricesWeightsKind
  64369. * - VertexBuffer.MatricesWeightsExtraKind
  64370. *
  64371. * Returns the Mesh.
  64372. */
  64373. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  64374. /**
  64375. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  64376. * If the mesh has no geometry, it is simply returned as it is.
  64377. * The `data` are either a numeric array either a Float32Array.
  64378. * No new underlying VertexBuffer object is created.
  64379. * 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.
  64380. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  64381. *
  64382. * Possible `kind` values :
  64383. * - VertexBuffer.PositionKind
  64384. * - VertexBuffer.UVKind
  64385. * - VertexBuffer.UV2Kind
  64386. * - VertexBuffer.UV3Kind
  64387. * - VertexBuffer.UV4Kind
  64388. * - VertexBuffer.UV5Kind
  64389. * - VertexBuffer.UV6Kind
  64390. * - VertexBuffer.ColorKind
  64391. * - VertexBuffer.MatricesIndicesKind
  64392. * - VertexBuffer.MatricesIndicesExtraKind
  64393. * - VertexBuffer.MatricesWeightsKind
  64394. * - VertexBuffer.MatricesWeightsExtraKind
  64395. *
  64396. * Returns the Mesh.
  64397. */
  64398. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  64399. /**
  64400. * Sets the mesh indices.
  64401. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  64402. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  64403. * This method creates a new index buffer each call.
  64404. * Returns the Mesh.
  64405. */
  64406. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  64407. /**
  64408. * Boolean : True if the mesh owns the requested kind of data.
  64409. */
  64410. isVerticesDataPresent(kind: string): boolean;
  64411. /**
  64412. * Returns an array of indices (IndicesArray).
  64413. */
  64414. getIndices(): Nullable<IndicesArray>;
  64415. readonly _positions: Nullable<Vector3[]>;
  64416. /**
  64417. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  64418. * This means the mesh underlying bounding box and sphere are recomputed.
  64419. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  64420. * @returns the current mesh
  64421. */
  64422. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  64423. /** @hidden */
  64424. _preActivate(): InstancedMesh;
  64425. /** @hidden */
  64426. _activate(renderId: number): InstancedMesh;
  64427. /**
  64428. * Returns the current associated LOD AbstractMesh.
  64429. */
  64430. getLOD(camera: Camera): AbstractMesh;
  64431. /** @hidden */
  64432. _syncSubMeshes(): InstancedMesh;
  64433. /** @hidden */
  64434. _generatePointsArray(): boolean;
  64435. /**
  64436. * Creates a new InstancedMesh from the current mesh.
  64437. * - name (string) : the cloned mesh name
  64438. * - newParent (optional Node) : the optional Node to parent the clone to.
  64439. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  64440. *
  64441. * Returns the clone.
  64442. */
  64443. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  64444. /**
  64445. * Disposes the InstancedMesh.
  64446. * Returns nothing.
  64447. */
  64448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64449. }
  64450. }
  64451. declare module BABYLON {
  64452. /**
  64453. * Class for creating a cube texture
  64454. */
  64455. export class CubeTexture extends BaseTexture {
  64456. private _delayedOnLoad;
  64457. /**
  64458. * The url of the texture
  64459. */
  64460. url: string;
  64461. /**
  64462. * Gets or sets the center of the bounding box associated with the cube texture.
  64463. * It must define where the camera used to render the texture was set
  64464. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64465. */
  64466. boundingBoxPosition: Vector3;
  64467. private _boundingBoxSize;
  64468. /**
  64469. * Gets or sets the size of the bounding box associated with the cube texture
  64470. * When defined, the cubemap will switch to local mode
  64471. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64472. * @example https://www.babylonjs-playground.com/#RNASML
  64473. */
  64474. /**
  64475. * Returns the bounding box size
  64476. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64477. */
  64478. boundingBoxSize: Vector3;
  64479. protected _rotationY: number;
  64480. /**
  64481. * Sets texture matrix rotation angle around Y axis in radians.
  64482. */
  64483. /**
  64484. * Gets texture matrix rotation angle around Y axis radians.
  64485. */
  64486. rotationY: number;
  64487. /**
  64488. * Are mip maps generated for this texture or not.
  64489. */
  64490. readonly noMipmap: boolean;
  64491. private _noMipmap;
  64492. private _files;
  64493. private _extensions;
  64494. private _textureMatrix;
  64495. private _format;
  64496. private _createPolynomials;
  64497. /** @hidden */
  64498. _prefiltered: boolean;
  64499. /**
  64500. * Creates a cube texture from an array of image urls
  64501. * @param files defines an array of image urls
  64502. * @param scene defines the hosting scene
  64503. * @param noMipmap specifies if mip maps are not used
  64504. * @returns a cube texture
  64505. */
  64506. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  64507. /**
  64508. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  64509. * @param url defines the url of the prefiltered texture
  64510. * @param scene defines the scene the texture is attached to
  64511. * @param forcedExtension defines the extension of the file if different from the url
  64512. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64513. * @return the prefiltered texture
  64514. */
  64515. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  64516. /**
  64517. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  64518. * as prefiltered data.
  64519. * @param rootUrl defines the url of the texture or the root name of the six images
  64520. * @param scene defines the scene the texture is attached to
  64521. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  64522. * @param noMipmap defines if mipmaps should be created or not
  64523. * @param files defines the six files to load for the different faces
  64524. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  64525. * @param onError defines a callback triggered in case of error during load
  64526. * @param format defines the internal format to use for the texture once loaded
  64527. * @param prefiltered defines whether or not the texture is created from prefiltered data
  64528. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  64529. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64530. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64531. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64532. * @return the cube texture
  64533. */
  64534. 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);
  64535. /**
  64536. * Get the current class name of the texture useful for serialization or dynamic coding.
  64537. * @returns "CubeTexture"
  64538. */
  64539. getClassName(): string;
  64540. /**
  64541. * Update the url (and optional buffer) of this texture if url was null during construction.
  64542. * @param url the url of the texture
  64543. * @param forcedExtension defines the extension to use
  64544. * @param onLoad callback called when the texture is loaded (defaults to null)
  64545. */
  64546. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  64547. /**
  64548. * Delays loading of the cube texture
  64549. * @param forcedExtension defines the extension to use
  64550. */
  64551. delayLoad(forcedExtension?: string): void;
  64552. /**
  64553. * Returns the reflection texture matrix
  64554. * @returns the reflection texture matrix
  64555. */
  64556. getReflectionTextureMatrix(): Matrix;
  64557. /**
  64558. * Sets the reflection texture matrix
  64559. * @param value Reflection texture matrix
  64560. */
  64561. setReflectionTextureMatrix(value: Matrix): void;
  64562. /**
  64563. * Parses text to create a cube texture
  64564. * @param parsedTexture define the serialized text to read from
  64565. * @param scene defines the hosting scene
  64566. * @param rootUrl defines the root url of the cube texture
  64567. * @returns a cube texture
  64568. */
  64569. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  64570. /**
  64571. * Makes a clone, or deep copy, of the cube texture
  64572. * @returns a new cube texture
  64573. */
  64574. clone(): CubeTexture;
  64575. }
  64576. }
  64577. declare module BABYLON {
  64578. /** @hidden */
  64579. export var postprocessVertexShader: {
  64580. name: string;
  64581. shader: string;
  64582. };
  64583. }
  64584. declare module BABYLON {
  64585. /**
  64586. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  64587. * This is the base of the follow, arc rotate cameras and Free camera
  64588. * @see http://doc.babylonjs.com/features/cameras
  64589. */
  64590. export class TargetCamera extends Camera {
  64591. private static _RigCamTransformMatrix;
  64592. private static _TargetTransformMatrix;
  64593. private static _TargetFocalPoint;
  64594. /**
  64595. * Define the current direction the camera is moving to
  64596. */
  64597. cameraDirection: Vector3;
  64598. /**
  64599. * Define the current rotation the camera is rotating to
  64600. */
  64601. cameraRotation: Vector2;
  64602. /**
  64603. * When set, the up vector of the camera will be updated by the rotation of the camera
  64604. */
  64605. updateUpVectorFromRotation: boolean;
  64606. private _tmpQuaternion;
  64607. /**
  64608. * Define the current rotation of the camera
  64609. */
  64610. rotation: Vector3;
  64611. /**
  64612. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  64613. */
  64614. rotationQuaternion: Quaternion;
  64615. /**
  64616. * Define the current speed of the camera
  64617. */
  64618. speed: number;
  64619. /**
  64620. * Add cconstraint to the camera to prevent it to move freely in all directions and
  64621. * around all axis.
  64622. */
  64623. noRotationConstraint: boolean;
  64624. /**
  64625. * Define the current target of the camera as an object or a position.
  64626. */
  64627. lockedTarget: any;
  64628. /** @hidden */
  64629. _currentTarget: Vector3;
  64630. /** @hidden */
  64631. _initialFocalDistance: number;
  64632. /** @hidden */
  64633. _viewMatrix: Matrix;
  64634. /** @hidden */
  64635. _camMatrix: Matrix;
  64636. /** @hidden */
  64637. _cameraTransformMatrix: Matrix;
  64638. /** @hidden */
  64639. _cameraRotationMatrix: Matrix;
  64640. /** @hidden */
  64641. _referencePoint: Vector3;
  64642. /** @hidden */
  64643. _transformedReferencePoint: Vector3;
  64644. protected _globalCurrentTarget: Vector3;
  64645. protected _globalCurrentUpVector: Vector3;
  64646. /** @hidden */
  64647. _reset: () => void;
  64648. private _defaultUp;
  64649. /**
  64650. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  64651. * This is the base of the follow, arc rotate cameras and Free camera
  64652. * @see http://doc.babylonjs.com/features/cameras
  64653. * @param name Defines the name of the camera in the scene
  64654. * @param position Defines the start position of the camera in the scene
  64655. * @param scene Defines the scene the camera belongs to
  64656. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64657. */
  64658. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64659. /**
  64660. * Gets the position in front of the camera at a given distance.
  64661. * @param distance The distance from the camera we want the position to be
  64662. * @returns the position
  64663. */
  64664. getFrontPosition(distance: number): Vector3;
  64665. /** @hidden */
  64666. _getLockedTargetPosition(): Nullable<Vector3>;
  64667. private _storedPosition;
  64668. private _storedRotation;
  64669. private _storedRotationQuaternion;
  64670. /**
  64671. * Store current camera state of the camera (fov, position, rotation, etc..)
  64672. * @returns the camera
  64673. */
  64674. storeState(): Camera;
  64675. /**
  64676. * Restored camera state. You must call storeState() first
  64677. * @returns whether it was successful or not
  64678. * @hidden
  64679. */
  64680. _restoreStateValues(): boolean;
  64681. /** @hidden */
  64682. _initCache(): void;
  64683. /** @hidden */
  64684. _updateCache(ignoreParentClass?: boolean): void;
  64685. /** @hidden */
  64686. _isSynchronizedViewMatrix(): boolean;
  64687. /** @hidden */
  64688. _computeLocalCameraSpeed(): number;
  64689. /** @hidden */
  64690. setTarget(target: Vector3): void;
  64691. /**
  64692. * Return the current target position of the camera. This value is expressed in local space.
  64693. * @returns the target position
  64694. */
  64695. getTarget(): Vector3;
  64696. /** @hidden */
  64697. _decideIfNeedsToMove(): boolean;
  64698. /** @hidden */
  64699. _updatePosition(): void;
  64700. /** @hidden */
  64701. _checkInputs(): void;
  64702. protected _updateCameraRotationMatrix(): void;
  64703. /**
  64704. * 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)
  64705. * @returns the current camera
  64706. */
  64707. private _rotateUpVectorWithCameraRotationMatrix;
  64708. private _cachedRotationZ;
  64709. private _cachedQuaternionRotationZ;
  64710. /** @hidden */
  64711. _getViewMatrix(): Matrix;
  64712. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  64713. /**
  64714. * @hidden
  64715. */
  64716. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  64717. /**
  64718. * @hidden
  64719. */
  64720. _updateRigCameras(): void;
  64721. private _getRigCamPositionAndTarget;
  64722. /**
  64723. * Gets the current object class name.
  64724. * @return the class name
  64725. */
  64726. getClassName(): string;
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /**
  64731. * @ignore
  64732. * This is a list of all the different input types that are available in the application.
  64733. * Fo instance: ArcRotateCameraGamepadInput...
  64734. */
  64735. export var CameraInputTypes: {};
  64736. /**
  64737. * This is the contract to implement in order to create a new input class.
  64738. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  64739. */
  64740. export interface ICameraInput<TCamera extends Camera> {
  64741. /**
  64742. * Defines the camera the input is attached to.
  64743. */
  64744. camera: Nullable<TCamera>;
  64745. /**
  64746. * Gets the class name of the current intput.
  64747. * @returns the class name
  64748. */
  64749. getClassName(): string;
  64750. /**
  64751. * Get the friendly name associated with the input class.
  64752. * @returns the input friendly name
  64753. */
  64754. getSimpleName(): string;
  64755. /**
  64756. * Attach the input controls to a specific dom element to get the input from.
  64757. * @param element Defines the element the controls should be listened from
  64758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64759. */
  64760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64761. /**
  64762. * Detach the current controls from the specified dom element.
  64763. * @param element Defines the element to stop listening the inputs from
  64764. */
  64765. detachControl(element: Nullable<HTMLElement>): void;
  64766. /**
  64767. * Update the current camera state depending on the inputs that have been used this frame.
  64768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64769. */
  64770. checkInputs?: () => void;
  64771. }
  64772. /**
  64773. * Represents a map of input types to input instance or input index to input instance.
  64774. */
  64775. export interface CameraInputsMap<TCamera extends Camera> {
  64776. /**
  64777. * Accessor to the input by input type.
  64778. */
  64779. [name: string]: ICameraInput<TCamera>;
  64780. /**
  64781. * Accessor to the input by input index.
  64782. */
  64783. [idx: number]: ICameraInput<TCamera>;
  64784. }
  64785. /**
  64786. * This represents the input manager used within a camera.
  64787. * It helps dealing with all the different kind of input attached to a camera.
  64788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64789. */
  64790. export class CameraInputsManager<TCamera extends Camera> {
  64791. /**
  64792. * Defines the list of inputs attahed to the camera.
  64793. */
  64794. attached: CameraInputsMap<TCamera>;
  64795. /**
  64796. * Defines the dom element the camera is collecting inputs from.
  64797. * This is null if the controls have not been attached.
  64798. */
  64799. attachedElement: Nullable<HTMLElement>;
  64800. /**
  64801. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64802. */
  64803. noPreventDefault: boolean;
  64804. /**
  64805. * Defined the camera the input manager belongs to.
  64806. */
  64807. camera: TCamera;
  64808. /**
  64809. * Update the current camera state depending on the inputs that have been used this frame.
  64810. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64811. */
  64812. checkInputs: () => void;
  64813. /**
  64814. * Instantiate a new Camera Input Manager.
  64815. * @param camera Defines the camera the input manager blongs to
  64816. */
  64817. constructor(camera: TCamera);
  64818. /**
  64819. * Add an input method to a camera
  64820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64821. * @param input camera input method
  64822. */
  64823. add(input: ICameraInput<TCamera>): void;
  64824. /**
  64825. * Remove a specific input method from a camera
  64826. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  64827. * @param inputToRemove camera input method
  64828. */
  64829. remove(inputToRemove: ICameraInput<TCamera>): void;
  64830. /**
  64831. * Remove a specific input type from a camera
  64832. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  64833. * @param inputType the type of the input to remove
  64834. */
  64835. removeByType(inputType: string): void;
  64836. private _addCheckInputs;
  64837. /**
  64838. * Attach the input controls to the currently attached dom element to listen the events from.
  64839. * @param input Defines the input to attach
  64840. */
  64841. attachInput(input: ICameraInput<TCamera>): void;
  64842. /**
  64843. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  64844. * @param element Defines the dom element to collect the events from
  64845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64846. */
  64847. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  64848. /**
  64849. * Detach the current manager inputs controls from a specific dom element.
  64850. * @param element Defines the dom element to collect the events from
  64851. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  64852. */
  64853. detachElement(element: HTMLElement, disconnect?: boolean): void;
  64854. /**
  64855. * Rebuild the dynamic inputCheck function from the current list of
  64856. * defined inputs in the manager.
  64857. */
  64858. rebuildInputCheck(): void;
  64859. /**
  64860. * Remove all attached input methods from a camera
  64861. */
  64862. clear(): void;
  64863. /**
  64864. * Serialize the current input manager attached to a camera.
  64865. * This ensures than once parsed,
  64866. * the input associated to the camera will be identical to the current ones
  64867. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  64868. */
  64869. serialize(serializedCamera: any): void;
  64870. /**
  64871. * Parses an input manager serialized JSON to restore the previous list of inputs
  64872. * and states associated to a camera.
  64873. * @param parsedCamera Defines the JSON to parse
  64874. */
  64875. parse(parsedCamera: any): void;
  64876. }
  64877. }
  64878. declare module BABYLON {
  64879. /**
  64880. * Gather the list of keyboard event types as constants.
  64881. */
  64882. export class KeyboardEventTypes {
  64883. /**
  64884. * The keydown event is fired when a key becomes active (pressed).
  64885. */
  64886. static readonly KEYDOWN: number;
  64887. /**
  64888. * The keyup event is fired when a key has been released.
  64889. */
  64890. static readonly KEYUP: number;
  64891. }
  64892. /**
  64893. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64894. */
  64895. export class KeyboardInfo {
  64896. /**
  64897. * Defines the type of event (KeyboardEventTypes)
  64898. */
  64899. type: number;
  64900. /**
  64901. * Defines the related dom event
  64902. */
  64903. event: KeyboardEvent;
  64904. /**
  64905. * Instantiates a new keyboard info.
  64906. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64907. * @param type Defines the type of event (KeyboardEventTypes)
  64908. * @param event Defines the related dom event
  64909. */
  64910. constructor(
  64911. /**
  64912. * Defines the type of event (KeyboardEventTypes)
  64913. */
  64914. type: number,
  64915. /**
  64916. * Defines the related dom event
  64917. */
  64918. event: KeyboardEvent);
  64919. }
  64920. /**
  64921. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64922. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  64923. */
  64924. export class KeyboardInfoPre extends KeyboardInfo {
  64925. /**
  64926. * Defines the type of event (KeyboardEventTypes)
  64927. */
  64928. type: number;
  64929. /**
  64930. * Defines the related dom event
  64931. */
  64932. event: KeyboardEvent;
  64933. /**
  64934. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  64935. */
  64936. skipOnPointerObservable: boolean;
  64937. /**
  64938. * Instantiates a new keyboard pre info.
  64939. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64940. * @param type Defines the type of event (KeyboardEventTypes)
  64941. * @param event Defines the related dom event
  64942. */
  64943. constructor(
  64944. /**
  64945. * Defines the type of event (KeyboardEventTypes)
  64946. */
  64947. type: number,
  64948. /**
  64949. * Defines the related dom event
  64950. */
  64951. event: KeyboardEvent);
  64952. }
  64953. }
  64954. declare module BABYLON {
  64955. /**
  64956. * Manage the keyboard inputs to control the movement of a free camera.
  64957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64958. */
  64959. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64960. /**
  64961. * Defines the camera the input is attached to.
  64962. */
  64963. camera: FreeCamera;
  64964. /**
  64965. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64966. */
  64967. keysUp: number[];
  64968. /**
  64969. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64970. */
  64971. keysDown: number[];
  64972. /**
  64973. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64974. */
  64975. keysLeft: number[];
  64976. /**
  64977. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64978. */
  64979. keysRight: number[];
  64980. private _keys;
  64981. private _onCanvasBlurObserver;
  64982. private _onKeyboardObserver;
  64983. private _engine;
  64984. private _scene;
  64985. /**
  64986. * Attach the input controls to a specific dom element to get the input from.
  64987. * @param element Defines the element the controls should be listened from
  64988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64989. */
  64990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64991. /**
  64992. * Detach the current controls from the specified dom element.
  64993. * @param element Defines the element to stop listening the inputs from
  64994. */
  64995. detachControl(element: Nullable<HTMLElement>): void;
  64996. /**
  64997. * Update the current camera state depending on the inputs that have been used this frame.
  64998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64999. */
  65000. checkInputs(): void;
  65001. /**
  65002. * Gets the class name of the current intput.
  65003. * @returns the class name
  65004. */
  65005. getClassName(): string;
  65006. /** @hidden */
  65007. _onLostFocus(): void;
  65008. /**
  65009. * Get the friendly name associated with the input class.
  65010. * @returns the input friendly name
  65011. */
  65012. getSimpleName(): string;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /**
  65017. * Interface used to define ActionEvent
  65018. */
  65019. export interface IActionEvent {
  65020. /** The mesh or sprite that triggered the action */
  65021. source: any;
  65022. /** The X mouse cursor position at the time of the event */
  65023. pointerX: number;
  65024. /** The Y mouse cursor position at the time of the event */
  65025. pointerY: number;
  65026. /** The mesh that is currently pointed at (can be null) */
  65027. meshUnderPointer: Nullable<AbstractMesh>;
  65028. /** the original (browser) event that triggered the ActionEvent */
  65029. sourceEvent?: any;
  65030. /** additional data for the event */
  65031. additionalData?: any;
  65032. }
  65033. /**
  65034. * ActionEvent is the event being sent when an action is triggered.
  65035. */
  65036. export class ActionEvent implements IActionEvent {
  65037. /** The mesh or sprite that triggered the action */
  65038. source: any;
  65039. /** The X mouse cursor position at the time of the event */
  65040. pointerX: number;
  65041. /** The Y mouse cursor position at the time of the event */
  65042. pointerY: number;
  65043. /** The mesh that is currently pointed at (can be null) */
  65044. meshUnderPointer: Nullable<AbstractMesh>;
  65045. /** the original (browser) event that triggered the ActionEvent */
  65046. sourceEvent?: any;
  65047. /** additional data for the event */
  65048. additionalData?: any;
  65049. /**
  65050. * Creates a new ActionEvent
  65051. * @param source The mesh or sprite that triggered the action
  65052. * @param pointerX The X mouse cursor position at the time of the event
  65053. * @param pointerY The Y mouse cursor position at the time of the event
  65054. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  65055. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  65056. * @param additionalData additional data for the event
  65057. */
  65058. constructor(
  65059. /** The mesh or sprite that triggered the action */
  65060. source: any,
  65061. /** The X mouse cursor position at the time of the event */
  65062. pointerX: number,
  65063. /** The Y mouse cursor position at the time of the event */
  65064. pointerY: number,
  65065. /** The mesh that is currently pointed at (can be null) */
  65066. meshUnderPointer: Nullable<AbstractMesh>,
  65067. /** the original (browser) event that triggered the ActionEvent */
  65068. sourceEvent?: any,
  65069. /** additional data for the event */
  65070. additionalData?: any);
  65071. /**
  65072. * Helper function to auto-create an ActionEvent from a source mesh.
  65073. * @param source The source mesh that triggered the event
  65074. * @param evt The original (browser) event
  65075. * @param additionalData additional data for the event
  65076. * @returns the new ActionEvent
  65077. */
  65078. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  65079. /**
  65080. * Helper function to auto-create an ActionEvent from a source sprite
  65081. * @param source The source sprite that triggered the event
  65082. * @param scene Scene associated with the sprite
  65083. * @param evt The original (browser) event
  65084. * @param additionalData additional data for the event
  65085. * @returns the new ActionEvent
  65086. */
  65087. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  65088. /**
  65089. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  65090. * @param scene the scene where the event occurred
  65091. * @param evt The original (browser) event
  65092. * @returns the new ActionEvent
  65093. */
  65094. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  65095. /**
  65096. * Helper function to auto-create an ActionEvent from a primitive
  65097. * @param prim defines the target primitive
  65098. * @param pointerPos defines the pointer position
  65099. * @param evt The original (browser) event
  65100. * @param additionalData additional data for the event
  65101. * @returns the new ActionEvent
  65102. */
  65103. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  65104. }
  65105. }
  65106. declare module BABYLON {
  65107. /**
  65108. * Interface describing all the common properties and methods a shadow light needs to implement.
  65109. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65110. * as well as binding the different shadow properties to the effects.
  65111. */
  65112. export interface IShadowLight extends Light {
  65113. /**
  65114. * The light id in the scene (used in scene.findLighById for instance)
  65115. */
  65116. id: string;
  65117. /**
  65118. * The position the shdow will be casted from.
  65119. */
  65120. position: Vector3;
  65121. /**
  65122. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65123. */
  65124. direction: Vector3;
  65125. /**
  65126. * The transformed position. Position of the light in world space taking parenting in account.
  65127. */
  65128. transformedPosition: Vector3;
  65129. /**
  65130. * The transformed direction. Direction of the light in world space taking parenting in account.
  65131. */
  65132. transformedDirection: Vector3;
  65133. /**
  65134. * The friendly name of the light in the scene.
  65135. */
  65136. name: string;
  65137. /**
  65138. * Defines the shadow projection clipping minimum z value.
  65139. */
  65140. shadowMinZ: number;
  65141. /**
  65142. * Defines the shadow projection clipping maximum z value.
  65143. */
  65144. shadowMaxZ: number;
  65145. /**
  65146. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65147. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65148. */
  65149. computeTransformedInformation(): boolean;
  65150. /**
  65151. * Gets the scene the light belongs to.
  65152. * @returns The scene
  65153. */
  65154. getScene(): Scene;
  65155. /**
  65156. * Callback defining a custom Projection Matrix Builder.
  65157. * This can be used to override the default projection matrix computation.
  65158. */
  65159. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65160. /**
  65161. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65162. * @param matrix The materix to updated with the projection information
  65163. * @param viewMatrix The transform matrix of the light
  65164. * @param renderList The list of mesh to render in the map
  65165. * @returns The current light
  65166. */
  65167. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65168. /**
  65169. * Gets the current depth scale used in ESM.
  65170. * @returns The scale
  65171. */
  65172. getDepthScale(): number;
  65173. /**
  65174. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65175. * @returns true if a cube texture needs to be use
  65176. */
  65177. needCube(): boolean;
  65178. /**
  65179. * Detects if the projection matrix requires to be recomputed this frame.
  65180. * @returns true if it requires to be recomputed otherwise, false.
  65181. */
  65182. needProjectionMatrixCompute(): boolean;
  65183. /**
  65184. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65185. */
  65186. forceProjectionMatrixCompute(): void;
  65187. /**
  65188. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65189. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65190. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65191. */
  65192. getShadowDirection(faceIndex?: number): Vector3;
  65193. /**
  65194. * Gets the minZ used for shadow according to both the scene and the light.
  65195. * @param activeCamera The camera we are returning the min for
  65196. * @returns the depth min z
  65197. */
  65198. getDepthMinZ(activeCamera: Camera): number;
  65199. /**
  65200. * Gets the maxZ used for shadow according to both the scene and the light.
  65201. * @param activeCamera The camera we are returning the max for
  65202. * @returns the depth max z
  65203. */
  65204. getDepthMaxZ(activeCamera: Camera): number;
  65205. }
  65206. /**
  65207. * Base implementation IShadowLight
  65208. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65209. */
  65210. export abstract class ShadowLight extends Light implements IShadowLight {
  65211. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65212. protected _position: Vector3;
  65213. protected _setPosition(value: Vector3): void;
  65214. /**
  65215. * Sets the position the shadow will be casted from. Also use as the light position for both
  65216. * point and spot lights.
  65217. */
  65218. /**
  65219. * Sets the position the shadow will be casted from. Also use as the light position for both
  65220. * point and spot lights.
  65221. */
  65222. position: Vector3;
  65223. protected _direction: Vector3;
  65224. protected _setDirection(value: Vector3): void;
  65225. /**
  65226. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65227. * Also use as the light direction on spot and directional lights.
  65228. */
  65229. /**
  65230. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65231. * Also use as the light direction on spot and directional lights.
  65232. */
  65233. direction: Vector3;
  65234. private _shadowMinZ;
  65235. /**
  65236. * Gets the shadow projection clipping minimum z value.
  65237. */
  65238. /**
  65239. * Sets the shadow projection clipping minimum z value.
  65240. */
  65241. shadowMinZ: number;
  65242. private _shadowMaxZ;
  65243. /**
  65244. * Sets the shadow projection clipping maximum z value.
  65245. */
  65246. /**
  65247. * Gets the shadow projection clipping maximum z value.
  65248. */
  65249. shadowMaxZ: number;
  65250. /**
  65251. * Callback defining a custom Projection Matrix Builder.
  65252. * This can be used to override the default projection matrix computation.
  65253. */
  65254. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65255. /**
  65256. * The transformed position. Position of the light in world space taking parenting in account.
  65257. */
  65258. transformedPosition: Vector3;
  65259. /**
  65260. * The transformed direction. Direction of the light in world space taking parenting in account.
  65261. */
  65262. transformedDirection: Vector3;
  65263. private _needProjectionMatrixCompute;
  65264. /**
  65265. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65266. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65267. */
  65268. computeTransformedInformation(): boolean;
  65269. /**
  65270. * Return the depth scale used for the shadow map.
  65271. * @returns the depth scale.
  65272. */
  65273. getDepthScale(): number;
  65274. /**
  65275. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65276. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65277. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65278. */
  65279. getShadowDirection(faceIndex?: number): Vector3;
  65280. /**
  65281. * Returns the ShadowLight absolute position in the World.
  65282. * @returns the position vector in world space
  65283. */
  65284. getAbsolutePosition(): Vector3;
  65285. /**
  65286. * Sets the ShadowLight direction toward the passed target.
  65287. * @param target The point to target in local space
  65288. * @returns the updated ShadowLight direction
  65289. */
  65290. setDirectionToTarget(target: Vector3): Vector3;
  65291. /**
  65292. * Returns the light rotation in euler definition.
  65293. * @returns the x y z rotation in local space.
  65294. */
  65295. getRotation(): Vector3;
  65296. /**
  65297. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65298. * @returns true if a cube texture needs to be use
  65299. */
  65300. needCube(): boolean;
  65301. /**
  65302. * Detects if the projection matrix requires to be recomputed this frame.
  65303. * @returns true if it requires to be recomputed otherwise, false.
  65304. */
  65305. needProjectionMatrixCompute(): boolean;
  65306. /**
  65307. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65308. */
  65309. forceProjectionMatrixCompute(): void;
  65310. /** @hidden */
  65311. _initCache(): void;
  65312. /** @hidden */
  65313. _isSynchronized(): boolean;
  65314. /**
  65315. * Computes the world matrix of the node
  65316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65317. * @returns the world matrix
  65318. */
  65319. computeWorldMatrix(force?: boolean): Matrix;
  65320. /**
  65321. * Gets the minZ used for shadow according to both the scene and the light.
  65322. * @param activeCamera The camera we are returning the min for
  65323. * @returns the depth min z
  65324. */
  65325. getDepthMinZ(activeCamera: Camera): number;
  65326. /**
  65327. * Gets the maxZ used for shadow according to both the scene and the light.
  65328. * @param activeCamera The camera we are returning the max for
  65329. * @returns the depth max z
  65330. */
  65331. getDepthMaxZ(activeCamera: Camera): number;
  65332. /**
  65333. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65334. * @param matrix The materix to updated with the projection information
  65335. * @param viewMatrix The transform matrix of the light
  65336. * @param renderList The list of mesh to render in the map
  65337. * @returns The current light
  65338. */
  65339. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65340. }
  65341. }
  65342. declare module BABYLON {
  65343. /**
  65344. * "Static Class" containing the most commonly used helper while dealing with material for
  65345. * rendering purpose.
  65346. *
  65347. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65348. *
  65349. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65350. */
  65351. export class MaterialHelper {
  65352. /**
  65353. * Bind the current view position to an effect.
  65354. * @param effect The effect to be bound
  65355. * @param scene The scene the eyes position is used from
  65356. */
  65357. static BindEyePosition(effect: Effect, scene: Scene): void;
  65358. /**
  65359. * Helps preparing the defines values about the UVs in used in the effect.
  65360. * UVs are shared as much as we can accross channels in the shaders.
  65361. * @param texture The texture we are preparing the UVs for
  65362. * @param defines The defines to update
  65363. * @param key The channel key "diffuse", "specular"... used in the shader
  65364. */
  65365. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65366. /**
  65367. * Binds a texture matrix value to its corrsponding uniform
  65368. * @param texture The texture to bind the matrix for
  65369. * @param uniformBuffer The uniform buffer receivin the data
  65370. * @param key The channel key "diffuse", "specular"... used in the shader
  65371. */
  65372. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65373. /**
  65374. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65375. * @param mesh defines the current mesh
  65376. * @param scene defines the current scene
  65377. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65378. * @param pointsCloud defines if point cloud rendering has to be turned on
  65379. * @param fogEnabled defines if fog has to be turned on
  65380. * @param alphaTest defines if alpha testing has to be turned on
  65381. * @param defines defines the current list of defines
  65382. */
  65383. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65384. /**
  65385. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65386. * @param scene defines the current scene
  65387. * @param engine defines the current engine
  65388. * @param defines specifies the list of active defines
  65389. * @param useInstances defines if instances have to be turned on
  65390. * @param useClipPlane defines if clip plane have to be turned on
  65391. */
  65392. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65393. /**
  65394. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65395. * @param mesh The mesh containing the geometry data we will draw
  65396. * @param defines The defines to update
  65397. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65398. * @param useBones Precise whether bones should be used or not (override mesh info)
  65399. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65400. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65401. * @returns false if defines are considered not dirty and have not been checked
  65402. */
  65403. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65404. /**
  65405. * Prepares the defines related to the light information passed in parameter
  65406. * @param scene The scene we are intending to draw
  65407. * @param mesh The mesh the effect is compiling for
  65408. * @param defines The defines to update
  65409. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65410. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65411. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65412. * @returns true if normals will be required for the rest of the effect
  65413. */
  65414. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65415. /**
  65416. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65417. * that won t be acctive due to defines being turned off.
  65418. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  65419. * @param samplersList The samplers list
  65420. * @param defines The defines helping in the list generation
  65421. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  65422. */
  65423. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  65424. /**
  65425. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  65426. * @param defines The defines to update while falling back
  65427. * @param fallbacks The authorized effect fallbacks
  65428. * @param maxSimultaneousLights The maximum number of lights allowed
  65429. * @param rank the current rank of the Effect
  65430. * @returns The newly affected rank
  65431. */
  65432. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  65433. /**
  65434. * Prepares the list of attributes required for morph targets according to the effect defines.
  65435. * @param attribs The current list of supported attribs
  65436. * @param mesh The mesh to prepare the morph targets attributes for
  65437. * @param defines The current Defines of the effect
  65438. */
  65439. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  65440. /**
  65441. * Prepares the list of attributes required for bones according to the effect defines.
  65442. * @param attribs The current list of supported attribs
  65443. * @param mesh The mesh to prepare the bones attributes for
  65444. * @param defines The current Defines of the effect
  65445. * @param fallbacks The current efffect fallback strategy
  65446. */
  65447. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  65448. /**
  65449. * Prepares the list of attributes required for instances according to the effect defines.
  65450. * @param attribs The current list of supported attribs
  65451. * @param defines The current Defines of the effect
  65452. */
  65453. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  65454. /**
  65455. * Binds the light shadow information to the effect for the given mesh.
  65456. * @param light The light containing the generator
  65457. * @param scene The scene the lights belongs to
  65458. * @param mesh The mesh we are binding the information to render
  65459. * @param lightIndex The light index in the effect used to render the mesh
  65460. * @param effect The effect we are binding the data to
  65461. */
  65462. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  65463. /**
  65464. * Binds the light information to the effect.
  65465. * @param light The light containing the generator
  65466. * @param effect The effect we are binding the data to
  65467. * @param lightIndex The light index in the effect used to render
  65468. */
  65469. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  65470. /**
  65471. * Binds the lights information from the scene to the effect for the given mesh.
  65472. * @param scene The scene the lights belongs to
  65473. * @param mesh The mesh we are binding the information to render
  65474. * @param effect The effect we are binding the data to
  65475. * @param defines The generated defines for the effect
  65476. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  65477. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  65478. */
  65479. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  65480. private static _tempFogColor;
  65481. /**
  65482. * Binds the fog information from the scene to the effect for the given mesh.
  65483. * @param scene The scene the lights belongs to
  65484. * @param mesh The mesh we are binding the information to render
  65485. * @param effect The effect we are binding the data to
  65486. * @param linearSpace Defines if the fog effect is applied in linear space
  65487. */
  65488. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  65489. /**
  65490. * Binds the bones information from the mesh to the effect.
  65491. * @param mesh The mesh we are binding the information to render
  65492. * @param effect The effect we are binding the data to
  65493. */
  65494. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  65495. /**
  65496. * Binds the morph targets information from the mesh to the effect.
  65497. * @param abstractMesh The mesh we are binding the information to render
  65498. * @param effect The effect we are binding the data to
  65499. */
  65500. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  65501. /**
  65502. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  65503. * @param defines The generated defines used in the effect
  65504. * @param effect The effect we are binding the data to
  65505. * @param scene The scene we are willing to render with logarithmic scale for
  65506. */
  65507. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  65508. /**
  65509. * Binds the clip plane information from the scene to the effect.
  65510. * @param scene The scene the clip plane information are extracted from
  65511. * @param effect The effect we are binding the data to
  65512. */
  65513. static BindClipPlane(effect: Effect, scene: Scene): void;
  65514. }
  65515. }
  65516. declare module BABYLON {
  65517. /** @hidden */
  65518. export var kernelBlurVaryingDeclaration: {
  65519. name: string;
  65520. shader: string;
  65521. };
  65522. }
  65523. declare module BABYLON {
  65524. /** @hidden */
  65525. export var kernelBlurFragment: {
  65526. name: string;
  65527. shader: string;
  65528. };
  65529. }
  65530. declare module BABYLON {
  65531. /** @hidden */
  65532. export var kernelBlurFragment2: {
  65533. name: string;
  65534. shader: string;
  65535. };
  65536. }
  65537. declare module BABYLON {
  65538. /** @hidden */
  65539. export var kernelBlurPixelShader: {
  65540. name: string;
  65541. shader: string;
  65542. };
  65543. }
  65544. declare module BABYLON {
  65545. /** @hidden */
  65546. export var kernelBlurVertex: {
  65547. name: string;
  65548. shader: string;
  65549. };
  65550. }
  65551. declare module BABYLON {
  65552. /** @hidden */
  65553. export var kernelBlurVertexShader: {
  65554. name: string;
  65555. shader: string;
  65556. };
  65557. }
  65558. declare module BABYLON {
  65559. /**
  65560. * The Blur Post Process which blurs an image based on a kernel and direction.
  65561. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  65562. */
  65563. export class BlurPostProcess extends PostProcess {
  65564. /** The direction in which to blur the image. */
  65565. direction: Vector2;
  65566. private blockCompilation;
  65567. protected _kernel: number;
  65568. protected _idealKernel: number;
  65569. protected _packedFloat: boolean;
  65570. private _staticDefines;
  65571. /**
  65572. * Sets the length in pixels of the blur sample region
  65573. */
  65574. /**
  65575. * Gets the length in pixels of the blur sample region
  65576. */
  65577. kernel: number;
  65578. /**
  65579. * Sets wether or not the blur needs to unpack/repack floats
  65580. */
  65581. /**
  65582. * Gets wether or not the blur is unpacking/repacking floats
  65583. */
  65584. packedFloat: boolean;
  65585. /**
  65586. * Creates a new instance BlurPostProcess
  65587. * @param name The name of the effect.
  65588. * @param direction The direction in which to blur the image.
  65589. * @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.
  65590. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  65591. * @param camera The camera to apply the render pass to.
  65592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65593. * @param engine The engine which the post process will be applied. (default: current engine)
  65594. * @param reusable If the post process can be reused on the same frame. (default: false)
  65595. * @param textureType Type of textures used when performing the post process. (default: 0)
  65596. * @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)
  65597. */
  65598. constructor(name: string,
  65599. /** The direction in which to blur the image. */
  65600. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  65601. /**
  65602. * Updates the effect with the current post process compile time values and recompiles the shader.
  65603. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65604. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65605. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65606. * @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
  65607. * @param onCompiled Called when the shader has been compiled.
  65608. * @param onError Called if there is an error when compiling a shader.
  65609. */
  65610. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65611. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65612. /**
  65613. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  65614. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  65615. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  65616. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  65617. * The gaps between physical kernels are compensated for in the weighting of the samples
  65618. * @param idealKernel Ideal blur kernel.
  65619. * @return Nearest best kernel.
  65620. */
  65621. protected _nearestBestKernel(idealKernel: number): number;
  65622. /**
  65623. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  65624. * @param x The point on the Gaussian distribution to sample.
  65625. * @return the value of the Gaussian function at x.
  65626. */
  65627. protected _gaussianWeight(x: number): number;
  65628. /**
  65629. * Generates a string that can be used as a floating point number in GLSL.
  65630. * @param x Value to print.
  65631. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  65632. * @return GLSL float string.
  65633. */
  65634. protected _glslFloat(x: number, decimalFigures?: number): string;
  65635. }
  65636. }
  65637. declare module BABYLON {
  65638. /** @hidden */
  65639. export var shadowMapPixelShader: {
  65640. name: string;
  65641. shader: string;
  65642. };
  65643. }
  65644. declare module BABYLON {
  65645. /** @hidden */
  65646. export var bonesDeclaration: {
  65647. name: string;
  65648. shader: string;
  65649. };
  65650. }
  65651. declare module BABYLON {
  65652. /** @hidden */
  65653. export var morphTargetsVertexGlobalDeclaration: {
  65654. name: string;
  65655. shader: string;
  65656. };
  65657. }
  65658. declare module BABYLON {
  65659. /** @hidden */
  65660. export var morphTargetsVertexDeclaration: {
  65661. name: string;
  65662. shader: string;
  65663. };
  65664. }
  65665. declare module BABYLON {
  65666. /** @hidden */
  65667. export var instancesDeclaration: {
  65668. name: string;
  65669. shader: string;
  65670. };
  65671. }
  65672. declare module BABYLON {
  65673. /** @hidden */
  65674. export var helperFunctions: {
  65675. name: string;
  65676. shader: string;
  65677. };
  65678. }
  65679. declare module BABYLON {
  65680. /** @hidden */
  65681. export var morphTargetsVertex: {
  65682. name: string;
  65683. shader: string;
  65684. };
  65685. }
  65686. declare module BABYLON {
  65687. /** @hidden */
  65688. export var instancesVertex: {
  65689. name: string;
  65690. shader: string;
  65691. };
  65692. }
  65693. declare module BABYLON {
  65694. /** @hidden */
  65695. export var bonesVertex: {
  65696. name: string;
  65697. shader: string;
  65698. };
  65699. }
  65700. declare module BABYLON {
  65701. /** @hidden */
  65702. export var shadowMapVertexShader: {
  65703. name: string;
  65704. shader: string;
  65705. };
  65706. }
  65707. declare module BABYLON {
  65708. /** @hidden */
  65709. export var depthBoxBlurPixelShader: {
  65710. name: string;
  65711. shader: string;
  65712. };
  65713. }
  65714. declare module BABYLON {
  65715. /**
  65716. * Defines the options associated with the creation of a custom shader for a shadow generator.
  65717. */
  65718. export interface ICustomShaderOptions {
  65719. /**
  65720. * Gets or sets the custom shader name to use
  65721. */
  65722. shaderName: string;
  65723. /**
  65724. * The list of attribute names used in the shader
  65725. */
  65726. attributes?: string[];
  65727. /**
  65728. * The list of unifrom names used in the shader
  65729. */
  65730. uniforms?: string[];
  65731. /**
  65732. * The list of sampler names used in the shader
  65733. */
  65734. samplers?: string[];
  65735. /**
  65736. * The list of defines used in the shader
  65737. */
  65738. defines?: string[];
  65739. }
  65740. /**
  65741. * Interface to implement to create a shadow generator compatible with BJS.
  65742. */
  65743. export interface IShadowGenerator {
  65744. /**
  65745. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  65746. * @returns The render target texture if present otherwise, null
  65747. */
  65748. getShadowMap(): Nullable<RenderTargetTexture>;
  65749. /**
  65750. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  65751. * @returns The render target texture if the shadow map is present otherwise, null
  65752. */
  65753. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  65754. /**
  65755. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  65756. * @param subMesh The submesh we want to render in the shadow map
  65757. * @param useInstances Defines wether will draw in the map using instances
  65758. * @returns true if ready otherwise, false
  65759. */
  65760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65761. /**
  65762. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  65763. * @param defines Defines of the material we want to update
  65764. * @param lightIndex Index of the light in the enabled light list of the material
  65765. */
  65766. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  65767. /**
  65768. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  65769. * defined in the generator but impacting the effect).
  65770. * It implies the unifroms available on the materials are the standard BJS ones.
  65771. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  65772. * @param effect The effect we are binfing the information for
  65773. */
  65774. bindShadowLight(lightIndex: string, effect: Effect): void;
  65775. /**
  65776. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  65777. * (eq to shadow prjection matrix * light transform matrix)
  65778. * @returns The transform matrix used to create the shadow map
  65779. */
  65780. getTransformMatrix(): Matrix;
  65781. /**
  65782. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  65783. * Cube and 2D textures for instance.
  65784. */
  65785. recreateShadowMap(): void;
  65786. /**
  65787. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65788. * @param onCompiled Callback triggered at the and of the effects compilation
  65789. * @param options Sets of optional options forcing the compilation with different modes
  65790. */
  65791. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  65792. useInstances: boolean;
  65793. }>): void;
  65794. /**
  65795. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  65796. * @param options Sets of optional options forcing the compilation with different modes
  65797. * @returns A promise that resolves when the compilation completes
  65798. */
  65799. forceCompilationAsync(options?: Partial<{
  65800. useInstances: boolean;
  65801. }>): Promise<void>;
  65802. /**
  65803. * Serializes the shadow generator setup to a json object.
  65804. * @returns The serialized JSON object
  65805. */
  65806. serialize(): any;
  65807. /**
  65808. * Disposes the Shadow map and related Textures and effects.
  65809. */
  65810. dispose(): void;
  65811. }
  65812. /**
  65813. * Default implementation IShadowGenerator.
  65814. * This is the main object responsible of generating shadows in the framework.
  65815. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  65816. */
  65817. export class ShadowGenerator implements IShadowGenerator {
  65818. /**
  65819. * Shadow generator mode None: no filtering applied.
  65820. */
  65821. static readonly FILTER_NONE: number;
  65822. /**
  65823. * Shadow generator mode ESM: Exponential Shadow Mapping.
  65824. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65825. */
  65826. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  65827. /**
  65828. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  65829. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  65830. */
  65831. static readonly FILTER_POISSONSAMPLING: number;
  65832. /**
  65833. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  65834. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65835. */
  65836. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  65837. /**
  65838. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  65839. * edge artifacts on steep falloff.
  65840. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65841. */
  65842. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  65843. /**
  65844. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  65845. * edge artifacts on steep falloff.
  65846. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  65847. */
  65848. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  65849. /**
  65850. * Shadow generator mode PCF: Percentage Closer Filtering
  65851. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65852. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  65853. */
  65854. static readonly FILTER_PCF: number;
  65855. /**
  65856. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  65857. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  65858. * Contact Hardening
  65859. */
  65860. static readonly FILTER_PCSS: number;
  65861. /**
  65862. * Reserved for PCF and PCSS
  65863. * Highest Quality.
  65864. *
  65865. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  65866. *
  65867. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  65868. */
  65869. static readonly QUALITY_HIGH: number;
  65870. /**
  65871. * Reserved for PCF and PCSS
  65872. * Good tradeoff for quality/perf cross devices
  65873. *
  65874. * Execute PCF on a 3*3 kernel.
  65875. *
  65876. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  65877. */
  65878. static readonly QUALITY_MEDIUM: number;
  65879. /**
  65880. * Reserved for PCF and PCSS
  65881. * The lowest quality but the fastest.
  65882. *
  65883. * Execute PCF on a 1*1 kernel.
  65884. *
  65885. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  65886. */
  65887. static readonly QUALITY_LOW: number;
  65888. /** Gets or sets the custom shader name to use */
  65889. customShaderOptions: ICustomShaderOptions;
  65890. /**
  65891. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  65892. */
  65893. onBeforeShadowMapRenderObservable: Observable<Effect>;
  65894. private _bias;
  65895. /**
  65896. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  65897. */
  65898. /**
  65899. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  65900. */
  65901. bias: number;
  65902. private _normalBias;
  65903. /**
  65904. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65905. */
  65906. /**
  65907. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  65908. */
  65909. normalBias: number;
  65910. private _blurBoxOffset;
  65911. /**
  65912. * Gets the blur box offset: offset applied during the blur pass.
  65913. * Only useful if useKernelBlur = false
  65914. */
  65915. /**
  65916. * Sets the blur box offset: offset applied during the blur pass.
  65917. * Only useful if useKernelBlur = false
  65918. */
  65919. blurBoxOffset: number;
  65920. private _blurScale;
  65921. /**
  65922. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  65923. * 2 means half of the size.
  65924. */
  65925. /**
  65926. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  65927. * 2 means half of the size.
  65928. */
  65929. blurScale: number;
  65930. private _blurKernel;
  65931. /**
  65932. * Gets the blur kernel: kernel size of the blur pass.
  65933. * Only useful if useKernelBlur = true
  65934. */
  65935. /**
  65936. * Sets the blur kernel: kernel size of the blur pass.
  65937. * Only useful if useKernelBlur = true
  65938. */
  65939. blurKernel: number;
  65940. private _useKernelBlur;
  65941. /**
  65942. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  65943. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65944. */
  65945. /**
  65946. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  65947. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  65948. */
  65949. useKernelBlur: boolean;
  65950. private _depthScale;
  65951. /**
  65952. * Gets the depth scale used in ESM mode.
  65953. */
  65954. /**
  65955. * Sets the depth scale used in ESM mode.
  65956. * This can override the scale stored on the light.
  65957. */
  65958. depthScale: number;
  65959. private _filter;
  65960. /**
  65961. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  65962. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65963. */
  65964. /**
  65965. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  65966. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  65967. */
  65968. filter: number;
  65969. /**
  65970. * Gets if the current filter is set to Poisson Sampling.
  65971. */
  65972. /**
  65973. * Sets the current filter to Poisson Sampling.
  65974. */
  65975. usePoissonSampling: boolean;
  65976. /**
  65977. * Gets if the current filter is set to ESM.
  65978. */
  65979. /**
  65980. * Sets the current filter is to ESM.
  65981. */
  65982. useExponentialShadowMap: boolean;
  65983. /**
  65984. * Gets if the current filter is set to filtered ESM.
  65985. */
  65986. /**
  65987. * Gets if the current filter is set to filtered ESM.
  65988. */
  65989. useBlurExponentialShadowMap: boolean;
  65990. /**
  65991. * Gets if the current filter is set to "close ESM" (using the inverse of the
  65992. * exponential to prevent steep falloff artifacts).
  65993. */
  65994. /**
  65995. * Sets the current filter to "close ESM" (using the inverse of the
  65996. * exponential to prevent steep falloff artifacts).
  65997. */
  65998. useCloseExponentialShadowMap: boolean;
  65999. /**
  66000. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66001. * exponential to prevent steep falloff artifacts).
  66002. */
  66003. /**
  66004. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66005. * exponential to prevent steep falloff artifacts).
  66006. */
  66007. useBlurCloseExponentialShadowMap: boolean;
  66008. /**
  66009. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66010. */
  66011. /**
  66012. * Sets the current filter to "PCF" (percentage closer filtering).
  66013. */
  66014. usePercentageCloserFiltering: boolean;
  66015. private _filteringQuality;
  66016. /**
  66017. * Gets the PCF or PCSS Quality.
  66018. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66019. */
  66020. /**
  66021. * Sets the PCF or PCSS Quality.
  66022. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66023. */
  66024. filteringQuality: number;
  66025. /**
  66026. * Gets if the current filter is set to "PCSS" (contact hardening).
  66027. */
  66028. /**
  66029. * Sets the current filter to "PCSS" (contact hardening).
  66030. */
  66031. useContactHardeningShadow: boolean;
  66032. private _contactHardeningLightSizeUVRatio;
  66033. /**
  66034. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66035. * Using a ratio helps keeping shape stability independently of the map size.
  66036. *
  66037. * It does not account for the light projection as it was having too much
  66038. * instability during the light setup or during light position changes.
  66039. *
  66040. * Only valid if useContactHardeningShadow is true.
  66041. */
  66042. /**
  66043. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66044. * Using a ratio helps keeping shape stability independently of the map size.
  66045. *
  66046. * It does not account for the light projection as it was having too much
  66047. * instability during the light setup or during light position changes.
  66048. *
  66049. * Only valid if useContactHardeningShadow is true.
  66050. */
  66051. contactHardeningLightSizeUVRatio: number;
  66052. private _darkness;
  66053. /**
  66054. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66055. * 0 means strongest and 1 would means no shadow.
  66056. * @returns the darkness.
  66057. */
  66058. getDarkness(): number;
  66059. /**
  66060. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66061. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66062. * @returns the shadow generator allowing fluent coding.
  66063. */
  66064. setDarkness(darkness: number): ShadowGenerator;
  66065. private _transparencyShadow;
  66066. /**
  66067. * Sets the ability to have transparent shadow (boolean).
  66068. * @param transparent True if transparent else False
  66069. * @returns the shadow generator allowing fluent coding
  66070. */
  66071. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66072. private _shadowMap;
  66073. private _shadowMap2;
  66074. /**
  66075. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66076. * @returns The render target texture if present otherwise, null
  66077. */
  66078. getShadowMap(): Nullable<RenderTargetTexture>;
  66079. /**
  66080. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66081. * @returns The render target texture if the shadow map is present otherwise, null
  66082. */
  66083. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66084. /**
  66085. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66086. * @param mesh Mesh to add
  66087. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66088. * @returns the Shadow Generator itself
  66089. */
  66090. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66091. /**
  66092. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66093. * @param mesh Mesh to remove
  66094. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66095. * @returns the Shadow Generator itself
  66096. */
  66097. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66098. /**
  66099. * Controls the extent to which the shadows fade out at the edge of the frustum
  66100. * Used only by directionals and spots
  66101. */
  66102. frustumEdgeFalloff: number;
  66103. private _light;
  66104. /**
  66105. * Returns the associated light object.
  66106. * @returns the light generating the shadow
  66107. */
  66108. getLight(): IShadowLight;
  66109. /**
  66110. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66111. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66112. * It might on the other hand introduce peter panning.
  66113. */
  66114. forceBackFacesOnly: boolean;
  66115. private _scene;
  66116. private _lightDirection;
  66117. private _effect;
  66118. private _viewMatrix;
  66119. private _projectionMatrix;
  66120. private _transformMatrix;
  66121. private _cachedPosition;
  66122. private _cachedDirection;
  66123. private _cachedDefines;
  66124. private _currentRenderID;
  66125. private _boxBlurPostprocess;
  66126. private _kernelBlurXPostprocess;
  66127. private _kernelBlurYPostprocess;
  66128. private _blurPostProcesses;
  66129. private _mapSize;
  66130. private _currentFaceIndex;
  66131. private _currentFaceIndexCache;
  66132. private _textureType;
  66133. private _defaultTextureMatrix;
  66134. /** @hidden */
  66135. static _SceneComponentInitialization: (scene: Scene) => void;
  66136. /**
  66137. * Creates a ShadowGenerator object.
  66138. * A ShadowGenerator is the required tool to use the shadows.
  66139. * Each light casting shadows needs to use its own ShadowGenerator.
  66140. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66141. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66142. * @param light The light object generating the shadows.
  66143. * @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.
  66144. */
  66145. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66146. private _initializeGenerator;
  66147. private _initializeShadowMap;
  66148. private _initializeBlurRTTAndPostProcesses;
  66149. private _renderForShadowMap;
  66150. private _renderSubMeshForShadowMap;
  66151. private _applyFilterValues;
  66152. /**
  66153. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66154. * @param onCompiled Callback triggered at the and of the effects compilation
  66155. * @param options Sets of optional options forcing the compilation with different modes
  66156. */
  66157. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66158. useInstances: boolean;
  66159. }>): void;
  66160. /**
  66161. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66162. * @param options Sets of optional options forcing the compilation with different modes
  66163. * @returns A promise that resolves when the compilation completes
  66164. */
  66165. forceCompilationAsync(options?: Partial<{
  66166. useInstances: boolean;
  66167. }>): Promise<void>;
  66168. /**
  66169. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66170. * @param subMesh The submesh we want to render in the shadow map
  66171. * @param useInstances Defines wether will draw in the map using instances
  66172. * @returns true if ready otherwise, false
  66173. */
  66174. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66175. /**
  66176. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66177. * @param defines Defines of the material we want to update
  66178. * @param lightIndex Index of the light in the enabled light list of the material
  66179. */
  66180. prepareDefines(defines: any, lightIndex: number): void;
  66181. /**
  66182. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66183. * defined in the generator but impacting the effect).
  66184. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66185. * @param effect The effect we are binfing the information for
  66186. */
  66187. bindShadowLight(lightIndex: string, effect: Effect): void;
  66188. /**
  66189. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66190. * (eq to shadow prjection matrix * light transform matrix)
  66191. * @returns The transform matrix used to create the shadow map
  66192. */
  66193. getTransformMatrix(): Matrix;
  66194. /**
  66195. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66196. * Cube and 2D textures for instance.
  66197. */
  66198. recreateShadowMap(): void;
  66199. private _disposeBlurPostProcesses;
  66200. private _disposeRTTandPostProcesses;
  66201. /**
  66202. * Disposes the ShadowGenerator.
  66203. * Returns nothing.
  66204. */
  66205. dispose(): void;
  66206. /**
  66207. * Serializes the shadow generator setup to a json object.
  66208. * @returns The serialized JSON object
  66209. */
  66210. serialize(): any;
  66211. /**
  66212. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66213. * @param parsedShadowGenerator The JSON object to parse
  66214. * @param scene The scene to create the shadow map for
  66215. * @returns The parsed shadow generator
  66216. */
  66217. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66218. }
  66219. }
  66220. declare module BABYLON {
  66221. /**
  66222. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66223. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66224. * 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.
  66225. */
  66226. export abstract class Light extends Node {
  66227. /**
  66228. * Falloff Default: light is falling off following the material specification:
  66229. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66230. */
  66231. static readonly FALLOFF_DEFAULT: number;
  66232. /**
  66233. * Falloff Physical: light is falling off following the inverse squared distance law.
  66234. */
  66235. static readonly FALLOFF_PHYSICAL: number;
  66236. /**
  66237. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66238. * to enhance interoperability with other engines.
  66239. */
  66240. static readonly FALLOFF_GLTF: number;
  66241. /**
  66242. * Falloff Standard: light is falling off like in the standard material
  66243. * to enhance interoperability with other materials.
  66244. */
  66245. static readonly FALLOFF_STANDARD: number;
  66246. /**
  66247. * If every light affecting the material is in this lightmapMode,
  66248. * material.lightmapTexture adds or multiplies
  66249. * (depends on material.useLightmapAsShadowmap)
  66250. * after every other light calculations.
  66251. */
  66252. static readonly LIGHTMAP_DEFAULT: number;
  66253. /**
  66254. * material.lightmapTexture as only diffuse lighting from this light
  66255. * adds only specular lighting from this light
  66256. * adds dynamic shadows
  66257. */
  66258. static readonly LIGHTMAP_SPECULAR: number;
  66259. /**
  66260. * material.lightmapTexture as only lighting
  66261. * no light calculation from this light
  66262. * only adds dynamic shadows from this light
  66263. */
  66264. static readonly LIGHTMAP_SHADOWSONLY: number;
  66265. /**
  66266. * Each light type uses the default quantity according to its type:
  66267. * point/spot lights use luminous intensity
  66268. * directional lights use illuminance
  66269. */
  66270. static readonly INTENSITYMODE_AUTOMATIC: number;
  66271. /**
  66272. * lumen (lm)
  66273. */
  66274. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66275. /**
  66276. * candela (lm/sr)
  66277. */
  66278. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66279. /**
  66280. * lux (lm/m^2)
  66281. */
  66282. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66283. /**
  66284. * nit (cd/m^2)
  66285. */
  66286. static readonly INTENSITYMODE_LUMINANCE: number;
  66287. /**
  66288. * Light type const id of the point light.
  66289. */
  66290. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66291. /**
  66292. * Light type const id of the directional light.
  66293. */
  66294. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66295. /**
  66296. * Light type const id of the spot light.
  66297. */
  66298. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66299. /**
  66300. * Light type const id of the hemispheric light.
  66301. */
  66302. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66303. /**
  66304. * Diffuse gives the basic color to an object.
  66305. */
  66306. diffuse: Color3;
  66307. /**
  66308. * Specular produces a highlight color on an object.
  66309. * Note: This is note affecting PBR materials.
  66310. */
  66311. specular: Color3;
  66312. /**
  66313. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66314. * falling off base on range or angle.
  66315. * This can be set to any values in Light.FALLOFF_x.
  66316. *
  66317. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66318. * other types of materials.
  66319. */
  66320. falloffType: number;
  66321. /**
  66322. * Strength of the light.
  66323. * Note: By default it is define in the framework own unit.
  66324. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66325. */
  66326. intensity: number;
  66327. private _range;
  66328. protected _inverseSquaredRange: number;
  66329. /**
  66330. * Defines how far from the source the light is impacting in scene units.
  66331. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66332. */
  66333. /**
  66334. * Defines how far from the source the light is impacting in scene units.
  66335. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66336. */
  66337. range: number;
  66338. /**
  66339. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66340. * of light.
  66341. */
  66342. private _photometricScale;
  66343. private _intensityMode;
  66344. /**
  66345. * Gets the photometric scale used to interpret the intensity.
  66346. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66347. */
  66348. /**
  66349. * Sets the photometric scale used to interpret the intensity.
  66350. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66351. */
  66352. intensityMode: number;
  66353. private _radius;
  66354. /**
  66355. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66356. */
  66357. /**
  66358. * sets the light radius used by PBR Materials to simulate soft area lights.
  66359. */
  66360. radius: number;
  66361. private _renderPriority;
  66362. /**
  66363. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66364. * exceeding the number allowed of the materials.
  66365. */
  66366. renderPriority: number;
  66367. private _shadowEnabled;
  66368. /**
  66369. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66370. * the current shadow generator.
  66371. */
  66372. /**
  66373. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66374. * the current shadow generator.
  66375. */
  66376. shadowEnabled: boolean;
  66377. private _includedOnlyMeshes;
  66378. /**
  66379. * Gets the only meshes impacted by this light.
  66380. */
  66381. /**
  66382. * Sets the only meshes impacted by this light.
  66383. */
  66384. includedOnlyMeshes: AbstractMesh[];
  66385. private _excludedMeshes;
  66386. /**
  66387. * Gets the meshes not impacted by this light.
  66388. */
  66389. /**
  66390. * Sets the meshes not impacted by this light.
  66391. */
  66392. excludedMeshes: AbstractMesh[];
  66393. private _excludeWithLayerMask;
  66394. /**
  66395. * Gets the layer id use to find what meshes are not impacted by the light.
  66396. * Inactive if 0
  66397. */
  66398. /**
  66399. * Sets the layer id use to find what meshes are not impacted by the light.
  66400. * Inactive if 0
  66401. */
  66402. excludeWithLayerMask: number;
  66403. private _includeOnlyWithLayerMask;
  66404. /**
  66405. * Gets the layer id use to find what meshes are impacted by the light.
  66406. * Inactive if 0
  66407. */
  66408. /**
  66409. * Sets the layer id use to find what meshes are impacted by the light.
  66410. * Inactive if 0
  66411. */
  66412. includeOnlyWithLayerMask: number;
  66413. private _lightmapMode;
  66414. /**
  66415. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66416. */
  66417. /**
  66418. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66419. */
  66420. lightmapMode: number;
  66421. /**
  66422. * Shadow generator associted to the light.
  66423. * @hidden Internal use only.
  66424. */
  66425. _shadowGenerator: Nullable<IShadowGenerator>;
  66426. /**
  66427. * @hidden Internal use only.
  66428. */
  66429. _excludedMeshesIds: string[];
  66430. /**
  66431. * @hidden Internal use only.
  66432. */
  66433. _includedOnlyMeshesIds: string[];
  66434. /**
  66435. * The current light unifom buffer.
  66436. * @hidden Internal use only.
  66437. */
  66438. _uniformBuffer: UniformBuffer;
  66439. /**
  66440. * Creates a Light object in the scene.
  66441. * Documentation : https://doc.babylonjs.com/babylon101/lights
  66442. * @param name The firendly name of the light
  66443. * @param scene The scene the light belongs too
  66444. */
  66445. constructor(name: string, scene: Scene);
  66446. protected abstract _buildUniformLayout(): void;
  66447. /**
  66448. * Sets the passed Effect "effect" with the Light information.
  66449. * @param effect The effect to update
  66450. * @param lightIndex The index of the light in the effect to update
  66451. * @returns The light
  66452. */
  66453. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  66454. /**
  66455. * Returns the string "Light".
  66456. * @returns the class name
  66457. */
  66458. getClassName(): string;
  66459. /** @hidden */
  66460. readonly _isLight: boolean;
  66461. /**
  66462. * Converts the light information to a readable string for debug purpose.
  66463. * @param fullDetails Supports for multiple levels of logging within scene loading
  66464. * @returns the human readable light info
  66465. */
  66466. toString(fullDetails?: boolean): string;
  66467. /** @hidden */
  66468. protected _syncParentEnabledState(): void;
  66469. /**
  66470. * Set the enabled state of this node.
  66471. * @param value - the new enabled state
  66472. */
  66473. setEnabled(value: boolean): void;
  66474. /**
  66475. * Returns the Light associated shadow generator if any.
  66476. * @return the associated shadow generator.
  66477. */
  66478. getShadowGenerator(): Nullable<IShadowGenerator>;
  66479. /**
  66480. * Returns a Vector3, the absolute light position in the World.
  66481. * @returns the world space position of the light
  66482. */
  66483. getAbsolutePosition(): Vector3;
  66484. /**
  66485. * Specifies if the light will affect the passed mesh.
  66486. * @param mesh The mesh to test against the light
  66487. * @return true the mesh is affected otherwise, false.
  66488. */
  66489. canAffectMesh(mesh: AbstractMesh): boolean;
  66490. /**
  66491. * Sort function to order lights for rendering.
  66492. * @param a First Light object to compare to second.
  66493. * @param b Second Light object to compare first.
  66494. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  66495. */
  66496. static CompareLightsPriority(a: Light, b: Light): number;
  66497. /**
  66498. * Releases resources associated with this node.
  66499. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66500. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66501. */
  66502. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66503. /**
  66504. * Returns the light type ID (integer).
  66505. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  66506. */
  66507. getTypeID(): number;
  66508. /**
  66509. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  66510. * @returns the scaled intensity in intensity mode unit
  66511. */
  66512. getScaledIntensity(): number;
  66513. /**
  66514. * Returns a new Light object, named "name", from the current one.
  66515. * @param name The name of the cloned light
  66516. * @returns the new created light
  66517. */
  66518. clone(name: string): Nullable<Light>;
  66519. /**
  66520. * Serializes the current light into a Serialization object.
  66521. * @returns the serialized object.
  66522. */
  66523. serialize(): any;
  66524. /**
  66525. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  66526. * This new light is named "name" and added to the passed scene.
  66527. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  66528. * @param name The friendly name of the light
  66529. * @param scene The scene the new light will belong to
  66530. * @returns the constructor function
  66531. */
  66532. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  66533. /**
  66534. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  66535. * @param parsedLight The JSON representation of the light
  66536. * @param scene The scene to create the parsed light in
  66537. * @returns the created light after parsing
  66538. */
  66539. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  66540. private _hookArrayForExcluded;
  66541. private _hookArrayForIncludedOnly;
  66542. private _resyncMeshes;
  66543. /**
  66544. * Forces the meshes to update their light related information in their rendering used effects
  66545. * @hidden Internal Use Only
  66546. */
  66547. _markMeshesAsLightDirty(): void;
  66548. /**
  66549. * Recomputes the cached photometric scale if needed.
  66550. */
  66551. private _computePhotometricScale;
  66552. /**
  66553. * Returns the Photometric Scale according to the light type and intensity mode.
  66554. */
  66555. private _getPhotometricScale;
  66556. /**
  66557. * Reorder the light in the scene according to their defined priority.
  66558. * @hidden Internal Use Only
  66559. */
  66560. _reorderLightsInScene(): void;
  66561. /**
  66562. * Prepares the list of defines specific to the light type.
  66563. * @param defines the list of defines
  66564. * @param lightIndex defines the index of the light for the effect
  66565. */
  66566. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  66567. }
  66568. }
  66569. declare module BABYLON {
  66570. /**
  66571. * Interface used to define Action
  66572. */
  66573. export interface IAction {
  66574. /**
  66575. * Trigger for the action
  66576. */
  66577. trigger: number;
  66578. /** the trigger, with or without parameters, for the action */
  66579. triggerOptions: any;
  66580. /**
  66581. * Gets the trigger parameters
  66582. * @returns the trigger parameters
  66583. */
  66584. getTriggerParameter(): any;
  66585. /**
  66586. * Internal only - executes current action event
  66587. * @hidden
  66588. */
  66589. _executeCurrent(evt?: ActionEvent): void;
  66590. /**
  66591. * Serialize placeholder for child classes
  66592. * @param parent of child
  66593. * @returns the serialized object
  66594. */
  66595. serialize(parent: any): any;
  66596. }
  66597. /**
  66598. * The action to be carried out following a trigger
  66599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  66600. */
  66601. export class Action implements IAction {
  66602. /** the trigger, with or without parameters, for the action */
  66603. triggerOptions: any;
  66604. /**
  66605. * Trigger for the action
  66606. */
  66607. trigger: number;
  66608. /**
  66609. * Internal only - manager for action
  66610. * @hidden
  66611. */
  66612. _actionManager: ActionManager;
  66613. private _nextActiveAction;
  66614. private _child;
  66615. private _condition?;
  66616. private _triggerParameter;
  66617. /**
  66618. * An event triggered prior to action being executed.
  66619. */
  66620. onBeforeExecuteObservable: Observable<Action>;
  66621. /**
  66622. * Creates a new Action
  66623. * @param triggerOptions the trigger, with or without parameters, for the action
  66624. * @param condition an optional determinant of action
  66625. */
  66626. constructor(
  66627. /** the trigger, with or without parameters, for the action */
  66628. triggerOptions: any, condition?: Condition);
  66629. /**
  66630. * Internal only
  66631. * @hidden
  66632. */
  66633. _prepare(): void;
  66634. /**
  66635. * Gets the trigger parameters
  66636. * @returns the trigger parameters
  66637. */
  66638. getTriggerParameter(): any;
  66639. /**
  66640. * Internal only - executes current action event
  66641. * @hidden
  66642. */
  66643. _executeCurrent(evt?: ActionEvent): void;
  66644. /**
  66645. * Execute placeholder for child classes
  66646. * @param evt optional action event
  66647. */
  66648. execute(evt?: ActionEvent): void;
  66649. /**
  66650. * Skips to next active action
  66651. */
  66652. skipToNextActiveAction(): void;
  66653. /**
  66654. * Adds action to chain of actions, may be a DoNothingAction
  66655. * @param action defines the next action to execute
  66656. * @returns The action passed in
  66657. * @see https://www.babylonjs-playground.com/#1T30HR#0
  66658. */
  66659. then(action: Action): Action;
  66660. /**
  66661. * Internal only
  66662. * @hidden
  66663. */
  66664. _getProperty(propertyPath: string): string;
  66665. /**
  66666. * Internal only
  66667. * @hidden
  66668. */
  66669. _getEffectiveTarget(target: any, propertyPath: string): any;
  66670. /**
  66671. * Serialize placeholder for child classes
  66672. * @param parent of child
  66673. * @returns the serialized object
  66674. */
  66675. serialize(parent: any): any;
  66676. /**
  66677. * Internal only called by serialize
  66678. * @hidden
  66679. */
  66680. protected _serialize(serializedAction: any, parent?: any): any;
  66681. /**
  66682. * Internal only
  66683. * @hidden
  66684. */
  66685. static _SerializeValueAsString: (value: any) => string;
  66686. /**
  66687. * Internal only
  66688. * @hidden
  66689. */
  66690. static _GetTargetProperty: (target: Scene | Node) => {
  66691. name: string;
  66692. targetType: string;
  66693. value: string;
  66694. };
  66695. }
  66696. }
  66697. declare module BABYLON {
  66698. /**
  66699. * A Condition applied to an Action
  66700. */
  66701. export class Condition {
  66702. /**
  66703. * Internal only - manager for action
  66704. * @hidden
  66705. */
  66706. _actionManager: ActionManager;
  66707. /**
  66708. * Internal only
  66709. * @hidden
  66710. */
  66711. _evaluationId: number;
  66712. /**
  66713. * Internal only
  66714. * @hidden
  66715. */
  66716. _currentResult: boolean;
  66717. /**
  66718. * Creates a new Condition
  66719. * @param actionManager the manager of the action the condition is applied to
  66720. */
  66721. constructor(actionManager: ActionManager);
  66722. /**
  66723. * Check if the current condition is valid
  66724. * @returns a boolean
  66725. */
  66726. isValid(): boolean;
  66727. /**
  66728. * Internal only
  66729. * @hidden
  66730. */
  66731. _getProperty(propertyPath: string): string;
  66732. /**
  66733. * Internal only
  66734. * @hidden
  66735. */
  66736. _getEffectiveTarget(target: any, propertyPath: string): any;
  66737. /**
  66738. * Serialize placeholder for child classes
  66739. * @returns the serialized object
  66740. */
  66741. serialize(): any;
  66742. /**
  66743. * Internal only
  66744. * @hidden
  66745. */
  66746. protected _serialize(serializedCondition: any): any;
  66747. }
  66748. /**
  66749. * Defines specific conditional operators as extensions of Condition
  66750. */
  66751. export class ValueCondition extends Condition {
  66752. /** path to specify the property of the target the conditional operator uses */
  66753. propertyPath: string;
  66754. /** the value compared by the conditional operator against the current value of the property */
  66755. value: any;
  66756. /** the conditional operator, default ValueCondition.IsEqual */
  66757. operator: number;
  66758. /**
  66759. * Internal only
  66760. * @hidden
  66761. */
  66762. private static _IsEqual;
  66763. /**
  66764. * Internal only
  66765. * @hidden
  66766. */
  66767. private static _IsDifferent;
  66768. /**
  66769. * Internal only
  66770. * @hidden
  66771. */
  66772. private static _IsGreater;
  66773. /**
  66774. * Internal only
  66775. * @hidden
  66776. */
  66777. private static _IsLesser;
  66778. /**
  66779. * returns the number for IsEqual
  66780. */
  66781. static readonly IsEqual: number;
  66782. /**
  66783. * Returns the number for IsDifferent
  66784. */
  66785. static readonly IsDifferent: number;
  66786. /**
  66787. * Returns the number for IsGreater
  66788. */
  66789. static readonly IsGreater: number;
  66790. /**
  66791. * Returns the number for IsLesser
  66792. */
  66793. static readonly IsLesser: number;
  66794. /**
  66795. * Internal only The action manager for the condition
  66796. * @hidden
  66797. */
  66798. _actionManager: ActionManager;
  66799. /**
  66800. * Internal only
  66801. * @hidden
  66802. */
  66803. private _target;
  66804. /**
  66805. * Internal only
  66806. * @hidden
  66807. */
  66808. private _effectiveTarget;
  66809. /**
  66810. * Internal only
  66811. * @hidden
  66812. */
  66813. private _property;
  66814. /**
  66815. * Creates a new ValueCondition
  66816. * @param actionManager manager for the action the condition applies to
  66817. * @param target for the action
  66818. * @param propertyPath path to specify the property of the target the conditional operator uses
  66819. * @param value the value compared by the conditional operator against the current value of the property
  66820. * @param operator the conditional operator, default ValueCondition.IsEqual
  66821. */
  66822. constructor(actionManager: ActionManager, target: any,
  66823. /** path to specify the property of the target the conditional operator uses */
  66824. propertyPath: string,
  66825. /** the value compared by the conditional operator against the current value of the property */
  66826. value: any,
  66827. /** the conditional operator, default ValueCondition.IsEqual */
  66828. operator?: number);
  66829. /**
  66830. * Compares the given value with the property value for the specified conditional operator
  66831. * @returns the result of the comparison
  66832. */
  66833. isValid(): boolean;
  66834. /**
  66835. * Serialize the ValueCondition into a JSON compatible object
  66836. * @returns serialization object
  66837. */
  66838. serialize(): any;
  66839. /**
  66840. * Gets the name of the conditional operator for the ValueCondition
  66841. * @param operator the conditional operator
  66842. * @returns the name
  66843. */
  66844. static GetOperatorName(operator: number): string;
  66845. }
  66846. /**
  66847. * Defines a predicate condition as an extension of Condition
  66848. */
  66849. export class PredicateCondition extends Condition {
  66850. /** defines the predicate function used to validate the condition */
  66851. predicate: () => boolean;
  66852. /**
  66853. * Internal only - manager for action
  66854. * @hidden
  66855. */
  66856. _actionManager: ActionManager;
  66857. /**
  66858. * Creates a new PredicateCondition
  66859. * @param actionManager manager for the action the condition applies to
  66860. * @param predicate defines the predicate function used to validate the condition
  66861. */
  66862. constructor(actionManager: ActionManager,
  66863. /** defines the predicate function used to validate the condition */
  66864. predicate: () => boolean);
  66865. /**
  66866. * @returns the validity of the predicate condition
  66867. */
  66868. isValid(): boolean;
  66869. }
  66870. /**
  66871. * Defines a state condition as an extension of Condition
  66872. */
  66873. export class StateCondition extends Condition {
  66874. /** Value to compare with target state */
  66875. value: string;
  66876. /**
  66877. * Internal only - manager for action
  66878. * @hidden
  66879. */
  66880. _actionManager: ActionManager;
  66881. /**
  66882. * Internal only
  66883. * @hidden
  66884. */
  66885. private _target;
  66886. /**
  66887. * Creates a new StateCondition
  66888. * @param actionManager manager for the action the condition applies to
  66889. * @param target of the condition
  66890. * @param value to compare with target state
  66891. */
  66892. constructor(actionManager: ActionManager, target: any,
  66893. /** Value to compare with target state */
  66894. value: string);
  66895. /**
  66896. * Gets a boolean indicating if the current condition is met
  66897. * @returns the validity of the state
  66898. */
  66899. isValid(): boolean;
  66900. /**
  66901. * Serialize the StateCondition into a JSON compatible object
  66902. * @returns serialization object
  66903. */
  66904. serialize(): any;
  66905. }
  66906. }
  66907. declare module BABYLON {
  66908. /**
  66909. * This defines an action responsible to toggle a boolean once triggered.
  66910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66911. */
  66912. export class SwitchBooleanAction extends Action {
  66913. /**
  66914. * The path to the boolean property in the target object
  66915. */
  66916. propertyPath: string;
  66917. private _target;
  66918. private _effectiveTarget;
  66919. private _property;
  66920. /**
  66921. * Instantiate the action
  66922. * @param triggerOptions defines the trigger options
  66923. * @param target defines the object containing the boolean
  66924. * @param propertyPath defines the path to the boolean property in the target object
  66925. * @param condition defines the trigger related conditions
  66926. */
  66927. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  66928. /** @hidden */
  66929. _prepare(): void;
  66930. /**
  66931. * Execute the action toggle the boolean value.
  66932. */
  66933. execute(): void;
  66934. /**
  66935. * Serializes the actions and its related information.
  66936. * @param parent defines the object to serialize in
  66937. * @returns the serialized object
  66938. */
  66939. serialize(parent: any): any;
  66940. }
  66941. /**
  66942. * This defines an action responsible to set a the state field of the target
  66943. * to a desired value once triggered.
  66944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66945. */
  66946. export class SetStateAction extends Action {
  66947. /**
  66948. * The value to store in the state field.
  66949. */
  66950. value: string;
  66951. private _target;
  66952. /**
  66953. * Instantiate the action
  66954. * @param triggerOptions defines the trigger options
  66955. * @param target defines the object containing the state property
  66956. * @param value defines the value to store in the state field
  66957. * @param condition defines the trigger related conditions
  66958. */
  66959. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  66960. /**
  66961. * Execute the action and store the value on the target state property.
  66962. */
  66963. execute(): void;
  66964. /**
  66965. * Serializes the actions and its related information.
  66966. * @param parent defines the object to serialize in
  66967. * @returns the serialized object
  66968. */
  66969. serialize(parent: any): any;
  66970. }
  66971. /**
  66972. * This defines an action responsible to set a property of the target
  66973. * to a desired value once triggered.
  66974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  66975. */
  66976. export class SetValueAction extends Action {
  66977. /**
  66978. * The path of the property to set in the target.
  66979. */
  66980. propertyPath: string;
  66981. /**
  66982. * The value to set in the property
  66983. */
  66984. value: any;
  66985. private _target;
  66986. private _effectiveTarget;
  66987. private _property;
  66988. /**
  66989. * Instantiate the action
  66990. * @param triggerOptions defines the trigger options
  66991. * @param target defines the object containing the property
  66992. * @param propertyPath defines the path of the property to set in the target
  66993. * @param value defines the value to set in the property
  66994. * @param condition defines the trigger related conditions
  66995. */
  66996. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  66997. /** @hidden */
  66998. _prepare(): void;
  66999. /**
  67000. * Execute the action and set the targetted property to the desired value.
  67001. */
  67002. execute(): void;
  67003. /**
  67004. * Serializes the actions and its related information.
  67005. * @param parent defines the object to serialize in
  67006. * @returns the serialized object
  67007. */
  67008. serialize(parent: any): any;
  67009. }
  67010. /**
  67011. * This defines an action responsible to increment the target value
  67012. * to a desired value once triggered.
  67013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67014. */
  67015. export class IncrementValueAction extends Action {
  67016. /**
  67017. * The path of the property to increment in the target.
  67018. */
  67019. propertyPath: string;
  67020. /**
  67021. * The value we should increment the property by.
  67022. */
  67023. value: any;
  67024. private _target;
  67025. private _effectiveTarget;
  67026. private _property;
  67027. /**
  67028. * Instantiate the action
  67029. * @param triggerOptions defines the trigger options
  67030. * @param target defines the object containing the property
  67031. * @param propertyPath defines the path of the property to increment in the target
  67032. * @param value defines the value value we should increment the property by
  67033. * @param condition defines the trigger related conditions
  67034. */
  67035. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67036. /** @hidden */
  67037. _prepare(): void;
  67038. /**
  67039. * Execute the action and increment the target of the value amount.
  67040. */
  67041. execute(): void;
  67042. /**
  67043. * Serializes the actions and its related information.
  67044. * @param parent defines the object to serialize in
  67045. * @returns the serialized object
  67046. */
  67047. serialize(parent: any): any;
  67048. }
  67049. /**
  67050. * This defines an action responsible to start an animation once triggered.
  67051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67052. */
  67053. export class PlayAnimationAction extends Action {
  67054. /**
  67055. * Where the animation should start (animation frame)
  67056. */
  67057. from: number;
  67058. /**
  67059. * Where the animation should stop (animation frame)
  67060. */
  67061. to: number;
  67062. /**
  67063. * Define if the animation should loop or stop after the first play.
  67064. */
  67065. loop?: boolean;
  67066. private _target;
  67067. /**
  67068. * Instantiate the action
  67069. * @param triggerOptions defines the trigger options
  67070. * @param target defines the target animation or animation name
  67071. * @param from defines from where the animation should start (animation frame)
  67072. * @param end defines where the animation should stop (animation frame)
  67073. * @param loop defines if the animation should loop or stop after the first play
  67074. * @param condition defines the trigger related conditions
  67075. */
  67076. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  67077. /** @hidden */
  67078. _prepare(): void;
  67079. /**
  67080. * Execute the action and play the animation.
  67081. */
  67082. execute(): void;
  67083. /**
  67084. * Serializes the actions and its related information.
  67085. * @param parent defines the object to serialize in
  67086. * @returns the serialized object
  67087. */
  67088. serialize(parent: any): any;
  67089. }
  67090. /**
  67091. * This defines an action responsible to stop an animation once triggered.
  67092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67093. */
  67094. export class StopAnimationAction extends Action {
  67095. private _target;
  67096. /**
  67097. * Instantiate the action
  67098. * @param triggerOptions defines the trigger options
  67099. * @param target defines the target animation or animation name
  67100. * @param condition defines the trigger related conditions
  67101. */
  67102. constructor(triggerOptions: any, target: any, condition?: Condition);
  67103. /** @hidden */
  67104. _prepare(): void;
  67105. /**
  67106. * Execute the action and stop the animation.
  67107. */
  67108. execute(): void;
  67109. /**
  67110. * Serializes the actions and its related information.
  67111. * @param parent defines the object to serialize in
  67112. * @returns the serialized object
  67113. */
  67114. serialize(parent: any): any;
  67115. }
  67116. /**
  67117. * This defines an action responsible that does nothing once triggered.
  67118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67119. */
  67120. export class DoNothingAction extends Action {
  67121. /**
  67122. * Instantiate the action
  67123. * @param triggerOptions defines the trigger options
  67124. * @param condition defines the trigger related conditions
  67125. */
  67126. constructor(triggerOptions?: any, condition?: Condition);
  67127. /**
  67128. * Execute the action and do nothing.
  67129. */
  67130. execute(): void;
  67131. /**
  67132. * Serializes the actions and its related information.
  67133. * @param parent defines the object to serialize in
  67134. * @returns the serialized object
  67135. */
  67136. serialize(parent: any): any;
  67137. }
  67138. /**
  67139. * This defines an action responsible to trigger several actions once triggered.
  67140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67141. */
  67142. export class CombineAction extends Action {
  67143. /**
  67144. * The list of aggregated animations to run.
  67145. */
  67146. children: Action[];
  67147. /**
  67148. * Instantiate the action
  67149. * @param triggerOptions defines the trigger options
  67150. * @param children defines the list of aggregated animations to run
  67151. * @param condition defines the trigger related conditions
  67152. */
  67153. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  67154. /** @hidden */
  67155. _prepare(): void;
  67156. /**
  67157. * Execute the action and executes all the aggregated actions.
  67158. */
  67159. execute(evt: ActionEvent): void;
  67160. /**
  67161. * Serializes the actions and its related information.
  67162. * @param parent defines the object to serialize in
  67163. * @returns the serialized object
  67164. */
  67165. serialize(parent: any): any;
  67166. }
  67167. /**
  67168. * This defines an action responsible to run code (external event) once triggered.
  67169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67170. */
  67171. export class ExecuteCodeAction extends Action {
  67172. /**
  67173. * The callback function to run.
  67174. */
  67175. func: (evt: ActionEvent) => void;
  67176. /**
  67177. * Instantiate the action
  67178. * @param triggerOptions defines the trigger options
  67179. * @param func defines the callback function to run
  67180. * @param condition defines the trigger related conditions
  67181. */
  67182. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67183. /**
  67184. * Execute the action and run the attached code.
  67185. */
  67186. execute(evt: ActionEvent): void;
  67187. }
  67188. /**
  67189. * This defines an action responsible to set the parent property of the target once triggered.
  67190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67191. */
  67192. export class SetParentAction extends Action {
  67193. private _parent;
  67194. private _target;
  67195. /**
  67196. * Instantiate the action
  67197. * @param triggerOptions defines the trigger options
  67198. * @param target defines the target containing the parent property
  67199. * @param parent defines from where the animation should start (animation frame)
  67200. * @param condition defines the trigger related conditions
  67201. */
  67202. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67203. /** @hidden */
  67204. _prepare(): void;
  67205. /**
  67206. * Execute the action and set the parent property.
  67207. */
  67208. execute(): void;
  67209. /**
  67210. * Serializes the actions and its related information.
  67211. * @param parent defines the object to serialize in
  67212. * @returns the serialized object
  67213. */
  67214. serialize(parent: any): any;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * Abstract class used to decouple action Manager from scene and meshes.
  67220. * Do not instantiate.
  67221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67222. */
  67223. export abstract class AbstractActionManager implements IDisposable {
  67224. /** Gets the list of active triggers */
  67225. static Triggers: {
  67226. [key: string]: number;
  67227. };
  67228. /** Gets the cursor to use when hovering items */
  67229. hoverCursor: string;
  67230. /** Gets the list of actions */
  67231. actions: IAction[];
  67232. /**
  67233. * Releases all associated resources
  67234. */
  67235. abstract dispose(): void;
  67236. /**
  67237. * Does this action manager has pointer triggers
  67238. */
  67239. abstract readonly hasPointerTriggers: boolean;
  67240. /**
  67241. * Does this action manager has pick triggers
  67242. */
  67243. abstract readonly hasPickTriggers: boolean;
  67244. /**
  67245. * Process a specific trigger
  67246. * @param trigger defines the trigger to process
  67247. * @param evt defines the event details to be processed
  67248. */
  67249. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  67250. /**
  67251. * Does this action manager handles actions of any of the given triggers
  67252. * @param triggers defines the triggers to be tested
  67253. * @return a boolean indicating whether one (or more) of the triggers is handled
  67254. */
  67255. abstract hasSpecificTriggers(triggers: number[]): boolean;
  67256. /**
  67257. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67258. * speed.
  67259. * @param triggerA defines the trigger to be tested
  67260. * @param triggerB defines the trigger to be tested
  67261. * @return a boolean indicating whether one (or more) of the triggers is handled
  67262. */
  67263. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67264. /**
  67265. * Does this action manager handles actions of a given trigger
  67266. * @param trigger defines the trigger to be tested
  67267. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67268. * @return whether the trigger is handled
  67269. */
  67270. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67271. /**
  67272. * Serialize this manager to a JSON object
  67273. * @param name defines the property name to store this manager
  67274. * @returns a JSON representation of this manager
  67275. */
  67276. abstract serialize(name: string): any;
  67277. /**
  67278. * Does exist one action manager with at least one trigger
  67279. **/
  67280. static readonly HasTriggers: boolean;
  67281. /**
  67282. * Does exist one action manager with at least one pick trigger
  67283. **/
  67284. static readonly HasPickTriggers: boolean;
  67285. /**
  67286. * Does exist one action manager that handles actions of a given trigger
  67287. * @param trigger defines the trigger to be tested
  67288. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  67289. **/
  67290. static HasSpecificTrigger(trigger: number): boolean;
  67291. }
  67292. }
  67293. declare module BABYLON {
  67294. /**
  67295. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67296. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67298. */
  67299. export class ActionManager extends AbstractActionManager {
  67300. /**
  67301. * Nothing
  67302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67303. */
  67304. static readonly NothingTrigger: number;
  67305. /**
  67306. * On pick
  67307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67308. */
  67309. static readonly OnPickTrigger: number;
  67310. /**
  67311. * On left pick
  67312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67313. */
  67314. static readonly OnLeftPickTrigger: number;
  67315. /**
  67316. * On right pick
  67317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67318. */
  67319. static readonly OnRightPickTrigger: number;
  67320. /**
  67321. * On center pick
  67322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67323. */
  67324. static readonly OnCenterPickTrigger: number;
  67325. /**
  67326. * On pick down
  67327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67328. */
  67329. static readonly OnPickDownTrigger: number;
  67330. /**
  67331. * On double pick
  67332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67333. */
  67334. static readonly OnDoublePickTrigger: number;
  67335. /**
  67336. * On pick up
  67337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67338. */
  67339. static readonly OnPickUpTrigger: number;
  67340. /**
  67341. * On pick out.
  67342. * This trigger will only be raised if you also declared a OnPickDown
  67343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67344. */
  67345. static readonly OnPickOutTrigger: number;
  67346. /**
  67347. * On long press
  67348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67349. */
  67350. static readonly OnLongPressTrigger: number;
  67351. /**
  67352. * On pointer over
  67353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67354. */
  67355. static readonly OnPointerOverTrigger: number;
  67356. /**
  67357. * On pointer out
  67358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67359. */
  67360. static readonly OnPointerOutTrigger: number;
  67361. /**
  67362. * On every frame
  67363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67364. */
  67365. static readonly OnEveryFrameTrigger: number;
  67366. /**
  67367. * On intersection enter
  67368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67369. */
  67370. static readonly OnIntersectionEnterTrigger: number;
  67371. /**
  67372. * On intersection exit
  67373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67374. */
  67375. static readonly OnIntersectionExitTrigger: number;
  67376. /**
  67377. * On key down
  67378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67379. */
  67380. static readonly OnKeyDownTrigger: number;
  67381. /**
  67382. * On key up
  67383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67384. */
  67385. static readonly OnKeyUpTrigger: number;
  67386. private _scene;
  67387. /**
  67388. * Creates a new action manager
  67389. * @param scene defines the hosting scene
  67390. */
  67391. constructor(scene: Scene);
  67392. /**
  67393. * Releases all associated resources
  67394. */
  67395. dispose(): void;
  67396. /**
  67397. * Gets hosting scene
  67398. * @returns the hosting scene
  67399. */
  67400. getScene(): Scene;
  67401. /**
  67402. * Does this action manager handles actions of any of the given triggers
  67403. * @param triggers defines the triggers to be tested
  67404. * @return a boolean indicating whether one (or more) of the triggers is handled
  67405. */
  67406. hasSpecificTriggers(triggers: number[]): boolean;
  67407. /**
  67408. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67409. * speed.
  67410. * @param triggerA defines the trigger to be tested
  67411. * @param triggerB defines the trigger to be tested
  67412. * @return a boolean indicating whether one (or more) of the triggers is handled
  67413. */
  67414. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67415. /**
  67416. * Does this action manager handles actions of a given trigger
  67417. * @param trigger defines the trigger to be tested
  67418. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67419. * @return whether the trigger is handled
  67420. */
  67421. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67422. /**
  67423. * Does this action manager has pointer triggers
  67424. */
  67425. readonly hasPointerTriggers: boolean;
  67426. /**
  67427. * Does this action manager has pick triggers
  67428. */
  67429. readonly hasPickTriggers: boolean;
  67430. /**
  67431. * Registers an action to this action manager
  67432. * @param action defines the action to be registered
  67433. * @return the action amended (prepared) after registration
  67434. */
  67435. registerAction(action: Action): Nullable<Action>;
  67436. /**
  67437. * Unregisters an action to this action manager
  67438. * @param action defines the action to be unregistered
  67439. * @return a boolean indicating whether the action has been unregistered
  67440. */
  67441. unregisterAction(action: Action): Boolean;
  67442. /**
  67443. * Process a specific trigger
  67444. * @param trigger defines the trigger to process
  67445. * @param evt defines the event details to be processed
  67446. */
  67447. processTrigger(trigger: number, evt?: IActionEvent): void;
  67448. /** @hidden */
  67449. _getEffectiveTarget(target: any, propertyPath: string): any;
  67450. /** @hidden */
  67451. _getProperty(propertyPath: string): string;
  67452. /**
  67453. * Serialize this manager to a JSON object
  67454. * @param name defines the property name to store this manager
  67455. * @returns a JSON representation of this manager
  67456. */
  67457. serialize(name: string): any;
  67458. /**
  67459. * Creates a new ActionManager from a JSON data
  67460. * @param parsedActions defines the JSON data to read from
  67461. * @param object defines the hosting mesh
  67462. * @param scene defines the hosting scene
  67463. */
  67464. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67465. /**
  67466. * Get a trigger name by index
  67467. * @param trigger defines the trigger index
  67468. * @returns a trigger name
  67469. */
  67470. static GetTriggerName(trigger: number): string;
  67471. }
  67472. }
  67473. declare module BABYLON {
  67474. /**
  67475. * Class representing a ray with position and direction
  67476. */
  67477. export class Ray {
  67478. /** origin point */
  67479. origin: Vector3;
  67480. /** direction */
  67481. direction: Vector3;
  67482. /** length of the ray */
  67483. length: number;
  67484. private static readonly TmpVector3;
  67485. private _tmpRay;
  67486. /**
  67487. * Creates a new ray
  67488. * @param origin origin point
  67489. * @param direction direction
  67490. * @param length length of the ray
  67491. */
  67492. constructor(
  67493. /** origin point */
  67494. origin: Vector3,
  67495. /** direction */
  67496. direction: Vector3,
  67497. /** length of the ray */
  67498. length?: number);
  67499. /**
  67500. * Checks if the ray intersects a box
  67501. * @param minimum bound of the box
  67502. * @param maximum bound of the box
  67503. * @param intersectionTreshold extra extend to be added to the box in all direction
  67504. * @returns if the box was hit
  67505. */
  67506. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  67507. /**
  67508. * Checks if the ray intersects a box
  67509. * @param box the bounding box to check
  67510. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  67511. * @returns if the box was hit
  67512. */
  67513. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  67514. /**
  67515. * If the ray hits a sphere
  67516. * @param sphere the bounding sphere to check
  67517. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  67518. * @returns true if it hits the sphere
  67519. */
  67520. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  67521. /**
  67522. * If the ray hits a triange
  67523. * @param vertex0 triangle vertex
  67524. * @param vertex1 triangle vertex
  67525. * @param vertex2 triangle vertex
  67526. * @returns intersection information if hit
  67527. */
  67528. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  67529. /**
  67530. * Checks if ray intersects a plane
  67531. * @param plane the plane to check
  67532. * @returns the distance away it was hit
  67533. */
  67534. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  67535. /**
  67536. * Checks if ray intersects a mesh
  67537. * @param mesh the mesh to check
  67538. * @param fastCheck if only the bounding box should checked
  67539. * @returns picking info of the intersecton
  67540. */
  67541. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  67542. /**
  67543. * Checks if ray intersects a mesh
  67544. * @param meshes the meshes to check
  67545. * @param fastCheck if only the bounding box should checked
  67546. * @param results array to store result in
  67547. * @returns Array of picking infos
  67548. */
  67549. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  67550. private _comparePickingInfo;
  67551. private static smallnum;
  67552. private static rayl;
  67553. /**
  67554. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  67555. * @param sega the first point of the segment to test the intersection against
  67556. * @param segb the second point of the segment to test the intersection against
  67557. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  67558. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  67559. */
  67560. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  67561. /**
  67562. * Update the ray from viewport position
  67563. * @param x position
  67564. * @param y y position
  67565. * @param viewportWidth viewport width
  67566. * @param viewportHeight viewport height
  67567. * @param world world matrix
  67568. * @param view view matrix
  67569. * @param projection projection matrix
  67570. * @returns this ray updated
  67571. */
  67572. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67573. /**
  67574. * Creates a ray with origin and direction of 0,0,0
  67575. * @returns the new ray
  67576. */
  67577. static Zero(): Ray;
  67578. /**
  67579. * Creates a new ray from screen space and viewport
  67580. * @param x position
  67581. * @param y y position
  67582. * @param viewportWidth viewport width
  67583. * @param viewportHeight viewport height
  67584. * @param world world matrix
  67585. * @param view view matrix
  67586. * @param projection projection matrix
  67587. * @returns new ray
  67588. */
  67589. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  67590. /**
  67591. * 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
  67592. * transformed to the given world matrix.
  67593. * @param origin The origin point
  67594. * @param end The end point
  67595. * @param world a matrix to transform the ray to. Default is the identity matrix.
  67596. * @returns the new ray
  67597. */
  67598. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  67599. /**
  67600. * Transforms a ray by a matrix
  67601. * @param ray ray to transform
  67602. * @param matrix matrix to apply
  67603. * @returns the resulting new ray
  67604. */
  67605. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  67606. /**
  67607. * Transforms a ray by a matrix
  67608. * @param ray ray to transform
  67609. * @param matrix matrix to apply
  67610. * @param result ray to store result in
  67611. */
  67612. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  67613. /**
  67614. * Unproject a ray from screen space to object space
  67615. * @param sourceX defines the screen space x coordinate to use
  67616. * @param sourceY defines the screen space y coordinate to use
  67617. * @param viewportWidth defines the current width of the viewport
  67618. * @param viewportHeight defines the current height of the viewport
  67619. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67620. * @param view defines the view matrix to use
  67621. * @param projection defines the projection matrix to use
  67622. */
  67623. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  67624. }
  67625. interface Scene {
  67626. /** @hidden */
  67627. _tempPickingRay: Nullable<Ray>;
  67628. /** @hidden */
  67629. _cachedRayForTransform: Ray;
  67630. /** @hidden */
  67631. _pickWithRayInverseMatrix: Matrix;
  67632. /** @hidden */
  67633. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67634. /** @hidden */
  67635. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  67636. }
  67637. }
  67638. declare module BABYLON {
  67639. /**
  67640. * Groups all the scene component constants in one place to ease maintenance.
  67641. * @hidden
  67642. */
  67643. export class SceneComponentConstants {
  67644. static readonly NAME_EFFECTLAYER: string;
  67645. static readonly NAME_LAYER: string;
  67646. static readonly NAME_LENSFLARESYSTEM: string;
  67647. static readonly NAME_BOUNDINGBOXRENDERER: string;
  67648. static readonly NAME_PARTICLESYSTEM: string;
  67649. static readonly NAME_GAMEPAD: string;
  67650. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  67651. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  67652. static readonly NAME_DEPTHRENDERER: string;
  67653. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  67654. static readonly NAME_SPRITE: string;
  67655. static readonly NAME_OUTLINERENDERER: string;
  67656. static readonly NAME_PROCEDURALTEXTURE: string;
  67657. static readonly NAME_SHADOWGENERATOR: string;
  67658. static readonly NAME_OCTREE: string;
  67659. static readonly NAME_PHYSICSENGINE: string;
  67660. static readonly NAME_AUDIO: string;
  67661. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  67662. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67663. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  67664. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  67665. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  67666. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  67667. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  67668. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  67669. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  67670. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  67671. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  67672. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  67673. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  67674. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  67675. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  67676. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  67677. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  67678. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  67679. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  67680. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  67681. static readonly STEP_AFTERRENDER_AUDIO: number;
  67682. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  67683. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  67684. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  67685. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  67686. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  67687. static readonly STEP_POINTERMOVE_SPRITE: number;
  67688. static readonly STEP_POINTERDOWN_SPRITE: number;
  67689. static readonly STEP_POINTERUP_SPRITE: number;
  67690. }
  67691. /**
  67692. * This represents a scene component.
  67693. *
  67694. * This is used to decouple the dependency the scene is having on the different workloads like
  67695. * layers, post processes...
  67696. */
  67697. export interface ISceneComponent {
  67698. /**
  67699. * The name of the component. Each component must have a unique name.
  67700. */
  67701. name: string;
  67702. /**
  67703. * The scene the component belongs to.
  67704. */
  67705. scene: Scene;
  67706. /**
  67707. * Register the component to one instance of a scene.
  67708. */
  67709. register(): void;
  67710. /**
  67711. * Rebuilds the elements related to this component in case of
  67712. * context lost for instance.
  67713. */
  67714. rebuild(): void;
  67715. /**
  67716. * Disposes the component and the associated ressources.
  67717. */
  67718. dispose(): void;
  67719. }
  67720. /**
  67721. * This represents a SERIALIZABLE scene component.
  67722. *
  67723. * This extends Scene Component to add Serialization methods on top.
  67724. */
  67725. export interface ISceneSerializableComponent extends ISceneComponent {
  67726. /**
  67727. * Adds all the element from the container to the scene
  67728. * @param container the container holding the elements
  67729. */
  67730. addFromContainer(container: AbstractScene): void;
  67731. /**
  67732. * Removes all the elements in the container from the scene
  67733. * @param container contains the elements to remove
  67734. */
  67735. removeFromContainer(container: AbstractScene): void;
  67736. /**
  67737. * Serializes the component data to the specified json object
  67738. * @param serializationObject The object to serialize to
  67739. */
  67740. serialize(serializationObject: any): void;
  67741. }
  67742. /**
  67743. * Strong typing of a Mesh related stage step action
  67744. */
  67745. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  67746. /**
  67747. * Strong typing of a Evaluate Sub Mesh related stage step action
  67748. */
  67749. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  67750. /**
  67751. * Strong typing of a Active Mesh related stage step action
  67752. */
  67753. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  67754. /**
  67755. * Strong typing of a Camera related stage step action
  67756. */
  67757. export type CameraStageAction = (camera: Camera) => void;
  67758. /**
  67759. * Strong typing of a Render Target related stage step action
  67760. */
  67761. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  67762. /**
  67763. * Strong typing of a RenderingGroup related stage step action
  67764. */
  67765. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  67766. /**
  67767. * Strong typing of a Mesh Render related stage step action
  67768. */
  67769. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  67770. /**
  67771. * Strong typing of a simple stage step action
  67772. */
  67773. export type SimpleStageAction = () => void;
  67774. /**
  67775. * Strong typing of a render target action.
  67776. */
  67777. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  67778. /**
  67779. * Strong typing of a pointer move action.
  67780. */
  67781. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  67782. /**
  67783. * Strong typing of a pointer up/down action.
  67784. */
  67785. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  67786. /**
  67787. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  67788. * @hidden
  67789. */
  67790. export class Stage<T extends Function> extends Array<{
  67791. index: number;
  67792. component: ISceneComponent;
  67793. action: T;
  67794. }> {
  67795. /**
  67796. * Hide ctor from the rest of the world.
  67797. * @param items The items to add.
  67798. */
  67799. private constructor();
  67800. /**
  67801. * Creates a new Stage.
  67802. * @returns A new instance of a Stage
  67803. */
  67804. static Create<T extends Function>(): Stage<T>;
  67805. /**
  67806. * Registers a step in an ordered way in the targeted stage.
  67807. * @param index Defines the position to register the step in
  67808. * @param component Defines the component attached to the step
  67809. * @param action Defines the action to launch during the step
  67810. */
  67811. registerStep(index: number, component: ISceneComponent, action: T): void;
  67812. /**
  67813. * Clears all the steps from the stage.
  67814. */
  67815. clear(): void;
  67816. }
  67817. }
  67818. declare module BABYLON {
  67819. interface Scene {
  67820. /** @hidden */
  67821. _pointerOverSprite: Nullable<Sprite>;
  67822. /** @hidden */
  67823. _pickedDownSprite: Nullable<Sprite>;
  67824. /** @hidden */
  67825. _tempSpritePickingRay: Nullable<Ray>;
  67826. /**
  67827. * All of the sprite managers added to this scene
  67828. * @see http://doc.babylonjs.com/babylon101/sprites
  67829. */
  67830. spriteManagers: Array<ISpriteManager>;
  67831. /**
  67832. * An event triggered when sprites rendering is about to start
  67833. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67834. */
  67835. onBeforeSpritesRenderingObservable: Observable<Scene>;
  67836. /**
  67837. * An event triggered when sprites rendering is done
  67838. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  67839. */
  67840. onAfterSpritesRenderingObservable: Observable<Scene>;
  67841. /** @hidden */
  67842. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67843. /** Launch a ray to try to pick a sprite in the scene
  67844. * @param x position on screen
  67845. * @param y position on screen
  67846. * @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
  67847. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67848. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  67849. * @returns a PickingInfo
  67850. */
  67851. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67852. /** Use the given ray to pick a sprite in the scene
  67853. * @param ray The ray (in world space) to use to pick meshes
  67854. * @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
  67855. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  67856. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  67857. * @returns a PickingInfo
  67858. */
  67859. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  67860. /**
  67861. * Force the sprite under the pointer
  67862. * @param sprite defines the sprite to use
  67863. */
  67864. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  67865. /**
  67866. * Gets the sprite under the pointer
  67867. * @returns a Sprite or null if no sprite is under the pointer
  67868. */
  67869. getPointerOverSprite(): Nullable<Sprite>;
  67870. }
  67871. /**
  67872. * Defines the sprite scene component responsible to manage sprites
  67873. * in a given scene.
  67874. */
  67875. export class SpriteSceneComponent implements ISceneComponent {
  67876. /**
  67877. * The component name helpfull to identify the component in the list of scene components.
  67878. */
  67879. readonly name: string;
  67880. /**
  67881. * The scene the component belongs to.
  67882. */
  67883. scene: Scene;
  67884. /** @hidden */
  67885. private _spritePredicate;
  67886. /**
  67887. * Creates a new instance of the component for the given scene
  67888. * @param scene Defines the scene to register the component in
  67889. */
  67890. constructor(scene: Scene);
  67891. /**
  67892. * Registers the component in a given scene
  67893. */
  67894. register(): void;
  67895. /**
  67896. * Rebuilds the elements related to this component in case of
  67897. * context lost for instance.
  67898. */
  67899. rebuild(): void;
  67900. /**
  67901. * Disposes the component and the associated ressources.
  67902. */
  67903. dispose(): void;
  67904. private _pickSpriteButKeepRay;
  67905. private _pointerMove;
  67906. private _pointerDown;
  67907. private _pointerUp;
  67908. }
  67909. }
  67910. declare module BABYLON {
  67911. /** @hidden */
  67912. export var fogFragmentDeclaration: {
  67913. name: string;
  67914. shader: string;
  67915. };
  67916. }
  67917. declare module BABYLON {
  67918. /** @hidden */
  67919. export var fogFragment: {
  67920. name: string;
  67921. shader: string;
  67922. };
  67923. }
  67924. declare module BABYLON {
  67925. /** @hidden */
  67926. export var spritesPixelShader: {
  67927. name: string;
  67928. shader: string;
  67929. };
  67930. }
  67931. declare module BABYLON {
  67932. /** @hidden */
  67933. export var fogVertexDeclaration: {
  67934. name: string;
  67935. shader: string;
  67936. };
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export var spritesVertexShader: {
  67941. name: string;
  67942. shader: string;
  67943. };
  67944. }
  67945. declare module BABYLON {
  67946. /**
  67947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  67948. */
  67949. export interface ISpriteManager extends IDisposable {
  67950. /**
  67951. * Restricts the camera to viewing objects with the same layerMask.
  67952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  67953. */
  67954. layerMask: number;
  67955. /**
  67956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  67957. */
  67958. isPickable: boolean;
  67959. /**
  67960. * Specifies the rendering group id for this mesh (0 by default)
  67961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  67962. */
  67963. renderingGroupId: number;
  67964. /**
  67965. * Defines the list of sprites managed by the manager.
  67966. */
  67967. sprites: Array<Sprite>;
  67968. /**
  67969. * Tests the intersection of a sprite with a specific ray.
  67970. * @param ray The ray we are sending to test the collision
  67971. * @param camera The camera space we are sending rays in
  67972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  67973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  67974. * @returns picking info or null.
  67975. */
  67976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  67977. /**
  67978. * Renders the list of sprites on screen.
  67979. */
  67980. render(): void;
  67981. }
  67982. /**
  67983. * Class used to manage multiple sprites on the same spritesheet
  67984. * @see http://doc.babylonjs.com/babylon101/sprites
  67985. */
  67986. export class SpriteManager implements ISpriteManager {
  67987. /** defines the manager's name */
  67988. name: string;
  67989. /** Gets the list of sprites */
  67990. sprites: Sprite[];
  67991. /** Gets or sets the rendering group id (0 by default) */
  67992. renderingGroupId: number;
  67993. /** Gets or sets camera layer mask */
  67994. layerMask: number;
  67995. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  67996. fogEnabled: boolean;
  67997. /** Gets or sets a boolean indicating if the sprites are pickable */
  67998. isPickable: boolean;
  67999. /** Defines the default width of a cell in the spritesheet */
  68000. cellWidth: number;
  68001. /** Defines the default height of a cell in the spritesheet */
  68002. cellHeight: number;
  68003. /**
  68004. * An event triggered when the manager is disposed.
  68005. */
  68006. onDisposeObservable: Observable<SpriteManager>;
  68007. private _onDisposeObserver;
  68008. /**
  68009. * Callback called when the manager is disposed
  68010. */
  68011. onDispose: () => void;
  68012. private _capacity;
  68013. private _spriteTexture;
  68014. private _epsilon;
  68015. private _scene;
  68016. private _vertexData;
  68017. private _buffer;
  68018. private _vertexBuffers;
  68019. private _indexBuffer;
  68020. private _effectBase;
  68021. private _effectFog;
  68022. /**
  68023. * Gets or sets the spritesheet texture
  68024. */
  68025. texture: Texture;
  68026. /**
  68027. * Creates a new sprite manager
  68028. * @param name defines the manager's name
  68029. * @param imgUrl defines the sprite sheet url
  68030. * @param capacity defines the maximum allowed number of sprites
  68031. * @param cellSize defines the size of a sprite cell
  68032. * @param scene defines the hosting scene
  68033. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68034. * @param samplingMode defines the smapling mode to use with spritesheet
  68035. */
  68036. constructor(
  68037. /** defines the manager's name */
  68038. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68039. private _appendSpriteVertex;
  68040. /**
  68041. * Intersects the sprites with a ray
  68042. * @param ray defines the ray to intersect with
  68043. * @param camera defines the current active camera
  68044. * @param predicate defines a predicate used to select candidate sprites
  68045. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68046. * @returns null if no hit or a PickingInfo
  68047. */
  68048. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68049. /**
  68050. * Render all child sprites
  68051. */
  68052. render(): void;
  68053. /**
  68054. * Release associated resources
  68055. */
  68056. dispose(): void;
  68057. }
  68058. }
  68059. declare module BABYLON {
  68060. /**
  68061. * Class used to represent a sprite
  68062. * @see http://doc.babylonjs.com/babylon101/sprites
  68063. */
  68064. export class Sprite {
  68065. /** defines the name */
  68066. name: string;
  68067. /** Gets or sets the current world position */
  68068. position: Vector3;
  68069. /** Gets or sets the main color */
  68070. color: Color4;
  68071. /** Gets or sets the width */
  68072. width: number;
  68073. /** Gets or sets the height */
  68074. height: number;
  68075. /** Gets or sets rotation angle */
  68076. angle: number;
  68077. /** Gets or sets the cell index in the sprite sheet */
  68078. cellIndex: number;
  68079. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68080. invertU: number;
  68081. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68082. invertV: number;
  68083. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68084. disposeWhenFinishedAnimating: boolean;
  68085. /** Gets the list of attached animations */
  68086. animations: Animation[];
  68087. /** Gets or sets a boolean indicating if the sprite can be picked */
  68088. isPickable: boolean;
  68089. /**
  68090. * Gets or sets the associated action manager
  68091. */
  68092. actionManager: Nullable<ActionManager>;
  68093. private _animationStarted;
  68094. private _loopAnimation;
  68095. private _fromIndex;
  68096. private _toIndex;
  68097. private _delay;
  68098. private _direction;
  68099. private _manager;
  68100. private _time;
  68101. private _onAnimationEnd;
  68102. /**
  68103. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  68104. */
  68105. isVisible: boolean;
  68106. /**
  68107. * Gets or sets the sprite size
  68108. */
  68109. size: number;
  68110. /**
  68111. * Creates a new Sprite
  68112. * @param name defines the name
  68113. * @param manager defines the manager
  68114. */
  68115. constructor(
  68116. /** defines the name */
  68117. name: string, manager: ISpriteManager);
  68118. /**
  68119. * Starts an animation
  68120. * @param from defines the initial key
  68121. * @param to defines the end key
  68122. * @param loop defines if the animation must loop
  68123. * @param delay defines the start delay (in ms)
  68124. * @param onAnimationEnd defines a callback to call when animation ends
  68125. */
  68126. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  68127. /** Stops current animation (if any) */
  68128. stopAnimation(): void;
  68129. /** @hidden */
  68130. _animate(deltaTime: number): void;
  68131. /** Release associated resources */
  68132. dispose(): void;
  68133. }
  68134. }
  68135. declare module BABYLON {
  68136. /**
  68137. * Information about the result of picking within a scene
  68138. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  68139. */
  68140. export class PickingInfo {
  68141. /** @hidden */
  68142. _pickingUnavailable: boolean;
  68143. /**
  68144. * If the pick collided with an object
  68145. */
  68146. hit: boolean;
  68147. /**
  68148. * Distance away where the pick collided
  68149. */
  68150. distance: number;
  68151. /**
  68152. * The location of pick collision
  68153. */
  68154. pickedPoint: Nullable<Vector3>;
  68155. /**
  68156. * The mesh corresponding the the pick collision
  68157. */
  68158. pickedMesh: Nullable<AbstractMesh>;
  68159. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68160. bu: number;
  68161. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68162. bv: number;
  68163. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68164. faceId: number;
  68165. /** Id of the the submesh that was picked */
  68166. subMeshId: number;
  68167. /** If a sprite was picked, this will be the sprite the pick collided with */
  68168. pickedSprite: Nullable<Sprite>;
  68169. /**
  68170. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68171. */
  68172. originMesh: Nullable<AbstractMesh>;
  68173. /**
  68174. * The ray that was used to perform the picking.
  68175. */
  68176. ray: Nullable<Ray>;
  68177. /**
  68178. * Gets the normal correspodning to the face the pick collided with
  68179. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68180. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68181. * @returns The normal correspodning to the face the pick collided with
  68182. */
  68183. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68184. /**
  68185. * Gets the texture coordinates of where the pick occured
  68186. * @returns the vector containing the coordnates of the texture
  68187. */
  68188. getTextureCoordinates(): Nullable<Vector2>;
  68189. }
  68190. }
  68191. declare module BABYLON {
  68192. /**
  68193. * Gather the list of pointer event types as constants.
  68194. */
  68195. export class PointerEventTypes {
  68196. /**
  68197. * 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.
  68198. */
  68199. static readonly POINTERDOWN: number;
  68200. /**
  68201. * The pointerup event is fired when a pointer is no longer active.
  68202. */
  68203. static readonly POINTERUP: number;
  68204. /**
  68205. * The pointermove event is fired when a pointer changes coordinates.
  68206. */
  68207. static readonly POINTERMOVE: number;
  68208. /**
  68209. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68210. */
  68211. static readonly POINTERWHEEL: number;
  68212. /**
  68213. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68214. */
  68215. static readonly POINTERPICK: number;
  68216. /**
  68217. * The pointertap event is fired when a the object has been touched and released without drag.
  68218. */
  68219. static readonly POINTERTAP: number;
  68220. /**
  68221. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68222. */
  68223. static readonly POINTERDOUBLETAP: number;
  68224. }
  68225. /**
  68226. * Base class of pointer info types.
  68227. */
  68228. export class PointerInfoBase {
  68229. /**
  68230. * Defines the type of event (PointerEventTypes)
  68231. */
  68232. type: number;
  68233. /**
  68234. * Defines the related dom event
  68235. */
  68236. event: PointerEvent | MouseWheelEvent;
  68237. /**
  68238. * Instantiates the base class of pointers info.
  68239. * @param type Defines the type of event (PointerEventTypes)
  68240. * @param event Defines the related dom event
  68241. */
  68242. constructor(
  68243. /**
  68244. * Defines the type of event (PointerEventTypes)
  68245. */
  68246. type: number,
  68247. /**
  68248. * Defines the related dom event
  68249. */
  68250. event: PointerEvent | MouseWheelEvent);
  68251. }
  68252. /**
  68253. * This class is used to store pointer related info for the onPrePointerObservable event.
  68254. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68255. */
  68256. export class PointerInfoPre extends PointerInfoBase {
  68257. /**
  68258. * Ray from a pointer if availible (eg. 6dof controller)
  68259. */
  68260. ray: Nullable<Ray>;
  68261. /**
  68262. * Defines the local position of the pointer on the canvas.
  68263. */
  68264. localPosition: Vector2;
  68265. /**
  68266. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68267. */
  68268. skipOnPointerObservable: boolean;
  68269. /**
  68270. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68271. * @param type Defines the type of event (PointerEventTypes)
  68272. * @param event Defines the related dom event
  68273. * @param localX Defines the local x coordinates of the pointer when the event occured
  68274. * @param localY Defines the local y coordinates of the pointer when the event occured
  68275. */
  68276. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68277. }
  68278. /**
  68279. * This type contains all the data related to a pointer event in Babylon.js.
  68280. * 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.
  68281. */
  68282. export class PointerInfo extends PointerInfoBase {
  68283. /**
  68284. * Defines the picking info associated to the info (if any)\
  68285. */
  68286. pickInfo: Nullable<PickingInfo>;
  68287. /**
  68288. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68289. * @param type Defines the type of event (PointerEventTypes)
  68290. * @param event Defines the related dom event
  68291. * @param pickInfo Defines the picking info associated to the info (if any)\
  68292. */
  68293. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68294. /**
  68295. * Defines the picking info associated to the info (if any)\
  68296. */
  68297. pickInfo: Nullable<PickingInfo>);
  68298. }
  68299. }
  68300. declare module BABYLON {
  68301. /**
  68302. * Manage the mouse inputs to control the movement of a free camera.
  68303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68304. */
  68305. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68306. /**
  68307. * Define if touch is enabled in the mouse input
  68308. */
  68309. touchEnabled: boolean;
  68310. /**
  68311. * Defines the camera the input is attached to.
  68312. */
  68313. camera: FreeCamera;
  68314. /**
  68315. * Defines the buttons associated with the input to handle camera move.
  68316. */
  68317. buttons: number[];
  68318. /**
  68319. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68320. */
  68321. angularSensibility: number;
  68322. private _pointerInput;
  68323. private _onMouseMove;
  68324. private _observer;
  68325. private previousPosition;
  68326. /**
  68327. * Manage the mouse inputs to control the movement of a free camera.
  68328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68329. * @param touchEnabled Defines if touch is enabled or not
  68330. */
  68331. constructor(
  68332. /**
  68333. * Define if touch is enabled in the mouse input
  68334. */
  68335. touchEnabled?: boolean);
  68336. /**
  68337. * Attach the input controls to a specific dom element to get the input from.
  68338. * @param element Defines the element the controls should be listened from
  68339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68340. */
  68341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68342. /**
  68343. * Detach the current controls from the specified dom element.
  68344. * @param element Defines the element to stop listening the inputs from
  68345. */
  68346. detachControl(element: Nullable<HTMLElement>): void;
  68347. /**
  68348. * Gets the class name of the current intput.
  68349. * @returns the class name
  68350. */
  68351. getClassName(): string;
  68352. /**
  68353. * Get the friendly name associated with the input class.
  68354. * @returns the input friendly name
  68355. */
  68356. getSimpleName(): string;
  68357. }
  68358. }
  68359. declare module BABYLON {
  68360. /**
  68361. * Manage the touch inputs to control the movement of a free camera.
  68362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68363. */
  68364. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68365. /**
  68366. * Defines the camera the input is attached to.
  68367. */
  68368. camera: FreeCamera;
  68369. /**
  68370. * Defines the touch sensibility for rotation.
  68371. * The higher the faster.
  68372. */
  68373. touchAngularSensibility: number;
  68374. /**
  68375. * Defines the touch sensibility for move.
  68376. * The higher the faster.
  68377. */
  68378. touchMoveSensibility: number;
  68379. private _offsetX;
  68380. private _offsetY;
  68381. private _pointerPressed;
  68382. private _pointerInput;
  68383. private _observer;
  68384. private _onLostFocus;
  68385. /**
  68386. * Attach the input controls to a specific dom element to get the input from.
  68387. * @param element Defines the element the controls should be listened from
  68388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68389. */
  68390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68391. /**
  68392. * Detach the current controls from the specified dom element.
  68393. * @param element Defines the element to stop listening the inputs from
  68394. */
  68395. detachControl(element: Nullable<HTMLElement>): void;
  68396. /**
  68397. * Update the current camera state depending on the inputs that have been used this frame.
  68398. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68399. */
  68400. checkInputs(): void;
  68401. /**
  68402. * Gets the class name of the current intput.
  68403. * @returns the class name
  68404. */
  68405. getClassName(): string;
  68406. /**
  68407. * Get the friendly name associated with the input class.
  68408. * @returns the input friendly name
  68409. */
  68410. getSimpleName(): string;
  68411. }
  68412. }
  68413. declare module BABYLON {
  68414. /**
  68415. * Default Inputs manager for the FreeCamera.
  68416. * It groups all the default supported inputs for ease of use.
  68417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68418. */
  68419. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68420. /**
  68421. * Instantiates a new FreeCameraInputsManager.
  68422. * @param camera Defines the camera the inputs belong to
  68423. */
  68424. constructor(camera: FreeCamera);
  68425. /**
  68426. * Add keyboard input support to the input manager.
  68427. * @returns the current input manager
  68428. */
  68429. addKeyboard(): FreeCameraInputsManager;
  68430. /**
  68431. * Add mouse input support to the input manager.
  68432. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68433. * @returns the current input manager
  68434. */
  68435. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68436. /**
  68437. * Add touch input support to the input manager.
  68438. * @returns the current input manager
  68439. */
  68440. addTouch(): FreeCameraInputsManager;
  68441. }
  68442. }
  68443. declare module BABYLON {
  68444. /**
  68445. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68446. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68447. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68448. */
  68449. export class FreeCamera extends TargetCamera {
  68450. /**
  68451. * Define the collision ellipsoid of the camera.
  68452. * This is helpful to simulate a camera body like the player body around the camera
  68453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68454. */
  68455. ellipsoid: Vector3;
  68456. /**
  68457. * Define an offset for the position of the ellipsoid around the camera.
  68458. * This can be helpful to determine the center of the body near the gravity center of the body
  68459. * instead of its head.
  68460. */
  68461. ellipsoidOffset: Vector3;
  68462. /**
  68463. * Enable or disable collisions of the camera with the rest of the scene objects.
  68464. */
  68465. checkCollisions: boolean;
  68466. /**
  68467. * Enable or disable gravity on the camera.
  68468. */
  68469. applyGravity: boolean;
  68470. /**
  68471. * Define the input manager associated to the camera.
  68472. */
  68473. inputs: FreeCameraInputsManager;
  68474. /**
  68475. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68476. * Higher values reduce sensitivity.
  68477. */
  68478. /**
  68479. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68480. * Higher values reduce sensitivity.
  68481. */
  68482. angularSensibility: number;
  68483. /**
  68484. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68485. */
  68486. keysUp: number[];
  68487. /**
  68488. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68489. */
  68490. keysDown: number[];
  68491. /**
  68492. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68493. */
  68494. keysLeft: number[];
  68495. /**
  68496. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68497. */
  68498. keysRight: number[];
  68499. /**
  68500. * Event raised when the camera collide with a mesh in the scene.
  68501. */
  68502. onCollide: (collidedMesh: AbstractMesh) => void;
  68503. private _collider;
  68504. private _needMoveForGravity;
  68505. private _oldPosition;
  68506. private _diffPosition;
  68507. private _newPosition;
  68508. /** @hidden */
  68509. _localDirection: Vector3;
  68510. /** @hidden */
  68511. _transformedDirection: Vector3;
  68512. /**
  68513. * Instantiates a Free Camera.
  68514. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68515. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  68516. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68517. * @param name Define the name of the camera in the scene
  68518. * @param position Define the start position of the camera in the scene
  68519. * @param scene Define the scene the camera belongs to
  68520. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68521. */
  68522. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68523. /**
  68524. * Attached controls to the current camera.
  68525. * @param element Defines the element the controls should be listened from
  68526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68527. */
  68528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68529. /**
  68530. * Detach the current controls from the camera.
  68531. * The camera will stop reacting to inputs.
  68532. * @param element Defines the element to stop listening the inputs from
  68533. */
  68534. detachControl(element: HTMLElement): void;
  68535. private _collisionMask;
  68536. /**
  68537. * Define a collision mask to limit the list of object the camera can collide with
  68538. */
  68539. collisionMask: number;
  68540. /** @hidden */
  68541. _collideWithWorld(displacement: Vector3): void;
  68542. private _onCollisionPositionChange;
  68543. /** @hidden */
  68544. _checkInputs(): void;
  68545. /** @hidden */
  68546. _decideIfNeedsToMove(): boolean;
  68547. /** @hidden */
  68548. _updatePosition(): void;
  68549. /**
  68550. * Destroy the camera and release the current resources hold by it.
  68551. */
  68552. dispose(): void;
  68553. /**
  68554. * Gets the current object class name.
  68555. * @return the class name
  68556. */
  68557. getClassName(): string;
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * Represents a gamepad control stick position
  68563. */
  68564. export class StickValues {
  68565. /**
  68566. * The x component of the control stick
  68567. */
  68568. x: number;
  68569. /**
  68570. * The y component of the control stick
  68571. */
  68572. y: number;
  68573. /**
  68574. * Initializes the gamepad x and y control stick values
  68575. * @param x The x component of the gamepad control stick value
  68576. * @param y The y component of the gamepad control stick value
  68577. */
  68578. constructor(
  68579. /**
  68580. * The x component of the control stick
  68581. */
  68582. x: number,
  68583. /**
  68584. * The y component of the control stick
  68585. */
  68586. y: number);
  68587. }
  68588. /**
  68589. * An interface which manages callbacks for gamepad button changes
  68590. */
  68591. export interface GamepadButtonChanges {
  68592. /**
  68593. * Called when a gamepad has been changed
  68594. */
  68595. changed: boolean;
  68596. /**
  68597. * Called when a gamepad press event has been triggered
  68598. */
  68599. pressChanged: boolean;
  68600. /**
  68601. * Called when a touch event has been triggered
  68602. */
  68603. touchChanged: boolean;
  68604. /**
  68605. * Called when a value has changed
  68606. */
  68607. valueChanged: boolean;
  68608. }
  68609. /**
  68610. * Represents a gamepad
  68611. */
  68612. export class Gamepad {
  68613. /**
  68614. * The id of the gamepad
  68615. */
  68616. id: string;
  68617. /**
  68618. * The index of the gamepad
  68619. */
  68620. index: number;
  68621. /**
  68622. * The browser gamepad
  68623. */
  68624. browserGamepad: any;
  68625. /**
  68626. * Specifies what type of gamepad this represents
  68627. */
  68628. type: number;
  68629. private _leftStick;
  68630. private _rightStick;
  68631. /** @hidden */
  68632. _isConnected: boolean;
  68633. private _leftStickAxisX;
  68634. private _leftStickAxisY;
  68635. private _rightStickAxisX;
  68636. private _rightStickAxisY;
  68637. /**
  68638. * Triggered when the left control stick has been changed
  68639. */
  68640. private _onleftstickchanged;
  68641. /**
  68642. * Triggered when the right control stick has been changed
  68643. */
  68644. private _onrightstickchanged;
  68645. /**
  68646. * Represents a gamepad controller
  68647. */
  68648. static GAMEPAD: number;
  68649. /**
  68650. * Represents a generic controller
  68651. */
  68652. static GENERIC: number;
  68653. /**
  68654. * Represents an XBox controller
  68655. */
  68656. static XBOX: number;
  68657. /**
  68658. * Represents a pose-enabled controller
  68659. */
  68660. static POSE_ENABLED: number;
  68661. /**
  68662. * Specifies whether the left control stick should be Y-inverted
  68663. */
  68664. protected _invertLeftStickY: boolean;
  68665. /**
  68666. * Specifies if the gamepad has been connected
  68667. */
  68668. readonly isConnected: boolean;
  68669. /**
  68670. * Initializes the gamepad
  68671. * @param id The id of the gamepad
  68672. * @param index The index of the gamepad
  68673. * @param browserGamepad The browser gamepad
  68674. * @param leftStickX The x component of the left joystick
  68675. * @param leftStickY The y component of the left joystick
  68676. * @param rightStickX The x component of the right joystick
  68677. * @param rightStickY The y component of the right joystick
  68678. */
  68679. constructor(
  68680. /**
  68681. * The id of the gamepad
  68682. */
  68683. id: string,
  68684. /**
  68685. * The index of the gamepad
  68686. */
  68687. index: number,
  68688. /**
  68689. * The browser gamepad
  68690. */
  68691. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  68692. /**
  68693. * Callback triggered when the left joystick has changed
  68694. * @param callback
  68695. */
  68696. onleftstickchanged(callback: (values: StickValues) => void): void;
  68697. /**
  68698. * Callback triggered when the right joystick has changed
  68699. * @param callback
  68700. */
  68701. onrightstickchanged(callback: (values: StickValues) => void): void;
  68702. /**
  68703. * Gets the left joystick
  68704. */
  68705. /**
  68706. * Sets the left joystick values
  68707. */
  68708. leftStick: StickValues;
  68709. /**
  68710. * Gets the right joystick
  68711. */
  68712. /**
  68713. * Sets the right joystick value
  68714. */
  68715. rightStick: StickValues;
  68716. /**
  68717. * Updates the gamepad joystick positions
  68718. */
  68719. update(): void;
  68720. /**
  68721. * Disposes the gamepad
  68722. */
  68723. dispose(): void;
  68724. }
  68725. /**
  68726. * Represents a generic gamepad
  68727. */
  68728. export class GenericPad extends Gamepad {
  68729. private _buttons;
  68730. private _onbuttondown;
  68731. private _onbuttonup;
  68732. /**
  68733. * Observable triggered when a button has been pressed
  68734. */
  68735. onButtonDownObservable: Observable<number>;
  68736. /**
  68737. * Observable triggered when a button has been released
  68738. */
  68739. onButtonUpObservable: Observable<number>;
  68740. /**
  68741. * Callback triggered when a button has been pressed
  68742. * @param callback Called when a button has been pressed
  68743. */
  68744. onbuttondown(callback: (buttonPressed: number) => void): void;
  68745. /**
  68746. * Callback triggered when a button has been released
  68747. * @param callback Called when a button has been released
  68748. */
  68749. onbuttonup(callback: (buttonReleased: number) => void): void;
  68750. /**
  68751. * Initializes the generic gamepad
  68752. * @param id The id of the generic gamepad
  68753. * @param index The index of the generic gamepad
  68754. * @param browserGamepad The browser gamepad
  68755. */
  68756. constructor(id: string, index: number, browserGamepad: any);
  68757. private _setButtonValue;
  68758. /**
  68759. * Updates the generic gamepad
  68760. */
  68761. update(): void;
  68762. /**
  68763. * Disposes the generic gamepad
  68764. */
  68765. dispose(): void;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * 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.
  68771. * @see https://doc.babylonjs.com/how_to/transformnode
  68772. */
  68773. export class TransformNode extends Node {
  68774. /**
  68775. * Object will not rotate to face the camera
  68776. */
  68777. static BILLBOARDMODE_NONE: number;
  68778. /**
  68779. * Object will rotate to face the camera but only on the x axis
  68780. */
  68781. static BILLBOARDMODE_X: number;
  68782. /**
  68783. * Object will rotate to face the camera but only on the y axis
  68784. */
  68785. static BILLBOARDMODE_Y: number;
  68786. /**
  68787. * Object will rotate to face the camera but only on the z axis
  68788. */
  68789. static BILLBOARDMODE_Z: number;
  68790. /**
  68791. * Object will rotate to face the camera
  68792. */
  68793. static BILLBOARDMODE_ALL: number;
  68794. private _forward;
  68795. private _forwardInverted;
  68796. private _up;
  68797. private _right;
  68798. private _rightInverted;
  68799. private _position;
  68800. private _rotation;
  68801. private _rotationQuaternion;
  68802. protected _scaling: Vector3;
  68803. protected _isDirty: boolean;
  68804. private _transformToBoneReferal;
  68805. /**
  68806. * Set the billboard mode. Default is 0.
  68807. *
  68808. * | Value | Type | Description |
  68809. * | --- | --- | --- |
  68810. * | 0 | BILLBOARDMODE_NONE | |
  68811. * | 1 | BILLBOARDMODE_X | |
  68812. * | 2 | BILLBOARDMODE_Y | |
  68813. * | 4 | BILLBOARDMODE_Z | |
  68814. * | 7 | BILLBOARDMODE_ALL | |
  68815. *
  68816. */
  68817. billboardMode: number;
  68818. /**
  68819. * 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
  68820. */
  68821. scalingDeterminant: number;
  68822. /**
  68823. * Sets the distance of the object to max, often used by skybox
  68824. */
  68825. infiniteDistance: boolean;
  68826. /**
  68827. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  68828. * By default the system will update normals to compensate
  68829. */
  68830. ignoreNonUniformScaling: boolean;
  68831. /** @hidden */
  68832. _poseMatrix: Matrix;
  68833. /** @hidden */
  68834. _localMatrix: Matrix;
  68835. private _absolutePosition;
  68836. private _pivotMatrix;
  68837. private _pivotMatrixInverse;
  68838. protected _postMultiplyPivotMatrix: boolean;
  68839. protected _isWorldMatrixFrozen: boolean;
  68840. /** @hidden */
  68841. _indexInSceneTransformNodesArray: number;
  68842. /**
  68843. * An event triggered after the world matrix is updated
  68844. */
  68845. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  68846. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  68847. /**
  68848. * Gets a string identifying the name of the class
  68849. * @returns "TransformNode" string
  68850. */
  68851. getClassName(): string;
  68852. /**
  68853. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  68854. */
  68855. position: Vector3;
  68856. /**
  68857. * 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)).
  68858. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  68859. */
  68860. rotation: Vector3;
  68861. /**
  68862. * 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)).
  68863. */
  68864. scaling: Vector3;
  68865. /**
  68866. * 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).
  68867. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  68868. */
  68869. rotationQuaternion: Nullable<Quaternion>;
  68870. /**
  68871. * The forward direction of that transform in world space.
  68872. */
  68873. readonly forward: Vector3;
  68874. /**
  68875. * The up direction of that transform in world space.
  68876. */
  68877. readonly up: Vector3;
  68878. /**
  68879. * The right direction of that transform in world space.
  68880. */
  68881. readonly right: Vector3;
  68882. /**
  68883. * Copies the parameter passed Matrix into the mesh Pose matrix.
  68884. * @param matrix the matrix to copy the pose from
  68885. * @returns this TransformNode.
  68886. */
  68887. updatePoseMatrix(matrix: Matrix): TransformNode;
  68888. /**
  68889. * Returns the mesh Pose matrix.
  68890. * @returns the pose matrix
  68891. */
  68892. getPoseMatrix(): Matrix;
  68893. /** @hidden */
  68894. _isSynchronized(): boolean;
  68895. /** @hidden */
  68896. _initCache(): void;
  68897. /**
  68898. * Flag the transform node as dirty (Forcing it to update everything)
  68899. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  68900. * @returns this transform node
  68901. */
  68902. markAsDirty(property: string): TransformNode;
  68903. /**
  68904. * Returns the current mesh absolute position.
  68905. * Returns a Vector3.
  68906. */
  68907. readonly absolutePosition: Vector3;
  68908. /**
  68909. * Sets a new matrix to apply before all other transformation
  68910. * @param matrix defines the transform matrix
  68911. * @returns the current TransformNode
  68912. */
  68913. setPreTransformMatrix(matrix: Matrix): TransformNode;
  68914. /**
  68915. * Sets a new pivot matrix to the current node
  68916. * @param matrix defines the new pivot matrix to use
  68917. * @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
  68918. * @returns the current TransformNode
  68919. */
  68920. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  68921. /**
  68922. * Returns the mesh pivot matrix.
  68923. * Default : Identity.
  68924. * @returns the matrix
  68925. */
  68926. getPivotMatrix(): Matrix;
  68927. /**
  68928. * Prevents the World matrix to be computed any longer.
  68929. * @returns the TransformNode.
  68930. */
  68931. freezeWorldMatrix(): TransformNode;
  68932. /**
  68933. * Allows back the World matrix computation.
  68934. * @returns the TransformNode.
  68935. */
  68936. unfreezeWorldMatrix(): this;
  68937. /**
  68938. * True if the World matrix has been frozen.
  68939. */
  68940. readonly isWorldMatrixFrozen: boolean;
  68941. /**
  68942. * Retuns the mesh absolute position in the World.
  68943. * @returns a Vector3.
  68944. */
  68945. getAbsolutePosition(): Vector3;
  68946. /**
  68947. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  68948. * @param absolutePosition the absolute position to set
  68949. * @returns the TransformNode.
  68950. */
  68951. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  68952. /**
  68953. * Sets the mesh position in its local space.
  68954. * @param vector3 the position to set in localspace
  68955. * @returns the TransformNode.
  68956. */
  68957. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  68958. /**
  68959. * Returns the mesh position in the local space from the current World matrix values.
  68960. * @returns a new Vector3.
  68961. */
  68962. getPositionExpressedInLocalSpace(): Vector3;
  68963. /**
  68964. * Translates the mesh along the passed Vector3 in its local space.
  68965. * @param vector3 the distance to translate in localspace
  68966. * @returns the TransformNode.
  68967. */
  68968. locallyTranslate(vector3: Vector3): TransformNode;
  68969. private static _lookAtVectorCache;
  68970. /**
  68971. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  68972. * @param targetPoint the position (must be in same space as current mesh) to look at
  68973. * @param yawCor optional yaw (y-axis) correction in radians
  68974. * @param pitchCor optional pitch (x-axis) correction in radians
  68975. * @param rollCor optional roll (z-axis) correction in radians
  68976. * @param space the choosen space of the target
  68977. * @returns the TransformNode.
  68978. */
  68979. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  68980. /**
  68981. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68982. * This Vector3 is expressed in the World space.
  68983. * @param localAxis axis to rotate
  68984. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  68985. */
  68986. getDirection(localAxis: Vector3): Vector3;
  68987. /**
  68988. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  68989. * localAxis is expressed in the mesh local space.
  68990. * result is computed in the Wordl space from the mesh World matrix.
  68991. * @param localAxis axis to rotate
  68992. * @param result the resulting transformnode
  68993. * @returns this TransformNode.
  68994. */
  68995. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  68996. /**
  68997. * Sets this transform node rotation to the given local axis.
  68998. * @param localAxis the axis in local space
  68999. * @param yawCor optional yaw (y-axis) correction in radians
  69000. * @param pitchCor optional pitch (x-axis) correction in radians
  69001. * @param rollCor optional roll (z-axis) correction in radians
  69002. * @returns this TransformNode
  69003. */
  69004. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  69005. /**
  69006. * Sets a new pivot point to the current node
  69007. * @param point defines the new pivot point to use
  69008. * @param space defines if the point is in world or local space (local by default)
  69009. * @returns the current TransformNode
  69010. */
  69011. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  69012. /**
  69013. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  69014. * @returns the pivot point
  69015. */
  69016. getPivotPoint(): Vector3;
  69017. /**
  69018. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  69019. * @param result the vector3 to store the result
  69020. * @returns this TransformNode.
  69021. */
  69022. getPivotPointToRef(result: Vector3): TransformNode;
  69023. /**
  69024. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  69025. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  69026. */
  69027. getAbsolutePivotPoint(): Vector3;
  69028. /**
  69029. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  69030. * @param result vector3 to store the result
  69031. * @returns this TransformNode.
  69032. */
  69033. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  69034. /**
  69035. * Defines the passed node as the parent of the current node.
  69036. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  69037. * @param node the node ot set as the parent
  69038. * @returns this TransformNode.
  69039. */
  69040. setParent(node: Nullable<Node>): TransformNode;
  69041. private _nonUniformScaling;
  69042. /**
  69043. * True if the scaling property of this object is non uniform eg. (1,2,1)
  69044. */
  69045. readonly nonUniformScaling: boolean;
  69046. /** @hidden */
  69047. _updateNonUniformScalingState(value: boolean): boolean;
  69048. /**
  69049. * Attach the current TransformNode to another TransformNode associated with a bone
  69050. * @param bone Bone affecting the TransformNode
  69051. * @param affectedTransformNode TransformNode associated with the bone
  69052. * @returns this object
  69053. */
  69054. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  69055. /**
  69056. * Detach the transform node if its associated with a bone
  69057. * @returns this object
  69058. */
  69059. detachFromBone(): TransformNode;
  69060. private static _rotationAxisCache;
  69061. /**
  69062. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  69063. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69064. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69065. * The passed axis is also normalized.
  69066. * @param axis the axis to rotate around
  69067. * @param amount the amount to rotate in radians
  69068. * @param space Space to rotate in (Default: local)
  69069. * @returns the TransformNode.
  69070. */
  69071. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  69072. /**
  69073. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  69074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69075. * The passed axis is also normalized. .
  69076. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  69077. * @param point the point to rotate around
  69078. * @param axis the axis to rotate around
  69079. * @param amount the amount to rotate in radians
  69080. * @returns the TransformNode
  69081. */
  69082. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  69083. /**
  69084. * Translates the mesh along the axis vector for the passed distance in the given space.
  69085. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69086. * @param axis the axis to translate in
  69087. * @param distance the distance to translate
  69088. * @param space Space to rotate in (Default: local)
  69089. * @returns the TransformNode.
  69090. */
  69091. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  69092. /**
  69093. * Adds a rotation step to the mesh current rotation.
  69094. * x, y, z are Euler angles expressed in radians.
  69095. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  69096. * This means this rotation is made in the mesh local space only.
  69097. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  69098. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  69099. * ```javascript
  69100. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  69101. * ```
  69102. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  69103. * 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.
  69104. * @param x Rotation to add
  69105. * @param y Rotation to add
  69106. * @param z Rotation to add
  69107. * @returns the TransformNode.
  69108. */
  69109. addRotation(x: number, y: number, z: number): TransformNode;
  69110. /**
  69111. * Computes the world matrix of the node
  69112. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69113. * @returns the world matrix
  69114. */
  69115. computeWorldMatrix(force?: boolean): Matrix;
  69116. protected _afterComputeWorldMatrix(): void;
  69117. /**
  69118. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  69119. * @param func callback function to add
  69120. *
  69121. * @returns the TransformNode.
  69122. */
  69123. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69124. /**
  69125. * Removes a registered callback function.
  69126. * @param func callback function to remove
  69127. * @returns the TransformNode.
  69128. */
  69129. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  69130. /**
  69131. * Gets the position of the current mesh in camera space
  69132. * @param camera defines the camera to use
  69133. * @returns a position
  69134. */
  69135. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  69136. /**
  69137. * Returns the distance from the mesh to the active camera
  69138. * @param camera defines the camera to use
  69139. * @returns the distance
  69140. */
  69141. getDistanceToCamera(camera?: Nullable<Camera>): number;
  69142. /**
  69143. * Clone the current transform node
  69144. * @param name Name of the new clone
  69145. * @param newParent New parent for the clone
  69146. * @param doNotCloneChildren Do not clone children hierarchy
  69147. * @returns the new transform node
  69148. */
  69149. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  69150. /**
  69151. * Serializes the objects information.
  69152. * @param currentSerializationObject defines the object to serialize in
  69153. * @returns the serialized object
  69154. */
  69155. serialize(currentSerializationObject?: any): any;
  69156. /**
  69157. * Returns a new TransformNode object parsed from the source provided.
  69158. * @param parsedTransformNode is the source.
  69159. * @param scene the scne the object belongs to
  69160. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  69161. * @returns a new TransformNode object parsed from the source provided.
  69162. */
  69163. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  69164. /**
  69165. * Get all child-transformNodes of this node
  69166. * @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
  69167. * @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
  69168. * @returns an array of TransformNode
  69169. */
  69170. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  69171. /**
  69172. * Releases resources associated with this transform node.
  69173. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69174. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69175. */
  69176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69177. }
  69178. }
  69179. declare module BABYLON {
  69180. /**
  69181. * Defines the types of pose enabled controllers that are supported
  69182. */
  69183. export enum PoseEnabledControllerType {
  69184. /**
  69185. * HTC Vive
  69186. */
  69187. VIVE = 0,
  69188. /**
  69189. * Oculus Rift
  69190. */
  69191. OCULUS = 1,
  69192. /**
  69193. * Windows mixed reality
  69194. */
  69195. WINDOWS = 2,
  69196. /**
  69197. * Samsung gear VR
  69198. */
  69199. GEAR_VR = 3,
  69200. /**
  69201. * Google Daydream
  69202. */
  69203. DAYDREAM = 4,
  69204. /**
  69205. * Generic
  69206. */
  69207. GENERIC = 5
  69208. }
  69209. /**
  69210. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69211. */
  69212. export interface MutableGamepadButton {
  69213. /**
  69214. * Value of the button/trigger
  69215. */
  69216. value: number;
  69217. /**
  69218. * If the button/trigger is currently touched
  69219. */
  69220. touched: boolean;
  69221. /**
  69222. * If the button/trigger is currently pressed
  69223. */
  69224. pressed: boolean;
  69225. }
  69226. /**
  69227. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69228. * @hidden
  69229. */
  69230. export interface ExtendedGamepadButton extends GamepadButton {
  69231. /**
  69232. * If the button/trigger is currently pressed
  69233. */
  69234. readonly pressed: boolean;
  69235. /**
  69236. * If the button/trigger is currently touched
  69237. */
  69238. readonly touched: boolean;
  69239. /**
  69240. * Value of the button/trigger
  69241. */
  69242. readonly value: number;
  69243. }
  69244. /** @hidden */
  69245. export interface _GamePadFactory {
  69246. /**
  69247. * Returns wether or not the current gamepad can be created for this type of controller.
  69248. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69249. * @returns true if it can be created, otherwise false
  69250. */
  69251. canCreate(gamepadInfo: any): boolean;
  69252. /**
  69253. * Creates a new instance of the Gamepad.
  69254. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69255. * @returns the new gamepad instance
  69256. */
  69257. create(gamepadInfo: any): Gamepad;
  69258. }
  69259. /**
  69260. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69261. */
  69262. export class PoseEnabledControllerHelper {
  69263. /** @hidden */
  69264. static _ControllerFactories: _GamePadFactory[];
  69265. /** @hidden */
  69266. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69267. /**
  69268. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69269. * @param vrGamepad the gamepad to initialized
  69270. * @returns a vr controller of the type the gamepad identified as
  69271. */
  69272. static InitiateController(vrGamepad: any): Gamepad;
  69273. }
  69274. /**
  69275. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69276. */
  69277. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69278. private _deviceRoomPosition;
  69279. private _deviceRoomRotationQuaternion;
  69280. /**
  69281. * The device position in babylon space
  69282. */
  69283. devicePosition: Vector3;
  69284. /**
  69285. * The device rotation in babylon space
  69286. */
  69287. deviceRotationQuaternion: Quaternion;
  69288. /**
  69289. * The scale factor of the device in babylon space
  69290. */
  69291. deviceScaleFactor: number;
  69292. /**
  69293. * (Likely devicePosition should be used instead) The device position in its room space
  69294. */
  69295. position: Vector3;
  69296. /**
  69297. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69298. */
  69299. rotationQuaternion: Quaternion;
  69300. /**
  69301. * The type of controller (Eg. Windows mixed reality)
  69302. */
  69303. controllerType: PoseEnabledControllerType;
  69304. protected _calculatedPosition: Vector3;
  69305. private _calculatedRotation;
  69306. /**
  69307. * The raw pose from the device
  69308. */
  69309. rawPose: DevicePose;
  69310. private _trackPosition;
  69311. private _maxRotationDistFromHeadset;
  69312. private _draggedRoomRotation;
  69313. /**
  69314. * @hidden
  69315. */
  69316. _disableTrackPosition(fixedPosition: Vector3): void;
  69317. /**
  69318. * Internal, the mesh attached to the controller
  69319. * @hidden
  69320. */
  69321. _mesh: Nullable<AbstractMesh>;
  69322. private _poseControlledCamera;
  69323. private _leftHandSystemQuaternion;
  69324. /**
  69325. * Internal, matrix used to convert room space to babylon space
  69326. * @hidden
  69327. */
  69328. _deviceToWorld: Matrix;
  69329. /**
  69330. * Node to be used when casting a ray from the controller
  69331. * @hidden
  69332. */
  69333. _pointingPoseNode: Nullable<TransformNode>;
  69334. /**
  69335. * Name of the child mesh that can be used to cast a ray from the controller
  69336. */
  69337. static readonly POINTING_POSE: string;
  69338. /**
  69339. * Creates a new PoseEnabledController from a gamepad
  69340. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69341. */
  69342. constructor(browserGamepad: any);
  69343. private _workingMatrix;
  69344. /**
  69345. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69346. */
  69347. update(): void;
  69348. /**
  69349. * Updates only the pose device and mesh without doing any button event checking
  69350. */
  69351. protected _updatePoseAndMesh(): void;
  69352. /**
  69353. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69354. * @param poseData raw pose fromthe device
  69355. */
  69356. updateFromDevice(poseData: DevicePose): void;
  69357. /**
  69358. * @hidden
  69359. */
  69360. _meshAttachedObservable: Observable<AbstractMesh>;
  69361. /**
  69362. * Attaches a mesh to the controller
  69363. * @param mesh the mesh to be attached
  69364. */
  69365. attachToMesh(mesh: AbstractMesh): void;
  69366. /**
  69367. * Attaches the controllers mesh to a camera
  69368. * @param camera the camera the mesh should be attached to
  69369. */
  69370. attachToPoseControlledCamera(camera: TargetCamera): void;
  69371. /**
  69372. * Disposes of the controller
  69373. */
  69374. dispose(): void;
  69375. /**
  69376. * The mesh that is attached to the controller
  69377. */
  69378. readonly mesh: Nullable<AbstractMesh>;
  69379. /**
  69380. * Gets the ray of the controller in the direction the controller is pointing
  69381. * @param length the length the resulting ray should be
  69382. * @returns a ray in the direction the controller is pointing
  69383. */
  69384. getForwardRay(length?: number): Ray;
  69385. }
  69386. }
  69387. declare module BABYLON {
  69388. /**
  69389. * Defines the WebVRController object that represents controllers tracked in 3D space
  69390. */
  69391. export abstract class WebVRController extends PoseEnabledController {
  69392. /**
  69393. * Internal, the default controller model for the controller
  69394. */
  69395. protected _defaultModel: AbstractMesh;
  69396. /**
  69397. * Fired when the trigger state has changed
  69398. */
  69399. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69400. /**
  69401. * Fired when the main button state has changed
  69402. */
  69403. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69404. /**
  69405. * Fired when the secondary button state has changed
  69406. */
  69407. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69408. /**
  69409. * Fired when the pad state has changed
  69410. */
  69411. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69412. /**
  69413. * Fired when controllers stick values have changed
  69414. */
  69415. onPadValuesChangedObservable: Observable<StickValues>;
  69416. /**
  69417. * Array of button availible on the controller
  69418. */
  69419. protected _buttons: Array<MutableGamepadButton>;
  69420. private _onButtonStateChange;
  69421. /**
  69422. * Fired when a controller button's state has changed
  69423. * @param callback the callback containing the button that was modified
  69424. */
  69425. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69426. /**
  69427. * X and Y axis corrisponding to the controllers joystick
  69428. */
  69429. pad: StickValues;
  69430. /**
  69431. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69432. */
  69433. hand: string;
  69434. /**
  69435. * The default controller model for the controller
  69436. */
  69437. readonly defaultModel: AbstractMesh;
  69438. /**
  69439. * Creates a new WebVRController from a gamepad
  69440. * @param vrGamepad the gamepad that the WebVRController should be created from
  69441. */
  69442. constructor(vrGamepad: any);
  69443. /**
  69444. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69445. */
  69446. update(): void;
  69447. /**
  69448. * Function to be called when a button is modified
  69449. */
  69450. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69451. /**
  69452. * Loads a mesh and attaches it to the controller
  69453. * @param scene the scene the mesh should be added to
  69454. * @param meshLoaded callback for when the mesh has been loaded
  69455. */
  69456. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69457. private _setButtonValue;
  69458. private _changes;
  69459. private _checkChanges;
  69460. /**
  69461. * Disposes of th webVRCOntroller
  69462. */
  69463. dispose(): void;
  69464. }
  69465. }
  69466. declare module BABYLON {
  69467. /**
  69468. * The HemisphericLight simulates the ambient environment light,
  69469. * so the passed direction is the light reflection direction, not the incoming direction.
  69470. */
  69471. export class HemisphericLight extends Light {
  69472. /**
  69473. * The groundColor is the light in the opposite direction to the one specified during creation.
  69474. * 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.
  69475. */
  69476. groundColor: Color3;
  69477. /**
  69478. * The light reflection direction, not the incoming direction.
  69479. */
  69480. direction: Vector3;
  69481. /**
  69482. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69483. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69484. * The HemisphericLight can't cast shadows.
  69485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69486. * @param name The friendly name of the light
  69487. * @param direction The direction of the light reflection
  69488. * @param scene The scene the light belongs to
  69489. */
  69490. constructor(name: string, direction: Vector3, scene: Scene);
  69491. protected _buildUniformLayout(): void;
  69492. /**
  69493. * Returns the string "HemisphericLight".
  69494. * @return The class name
  69495. */
  69496. getClassName(): string;
  69497. /**
  69498. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69499. * Returns the updated direction.
  69500. * @param target The target the direction should point to
  69501. * @return The computed direction
  69502. */
  69503. setDirectionToTarget(target: Vector3): Vector3;
  69504. /**
  69505. * Returns the shadow generator associated to the light.
  69506. * @returns Always null for hemispheric lights because it does not support shadows.
  69507. */
  69508. getShadowGenerator(): Nullable<IShadowGenerator>;
  69509. /**
  69510. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69511. * @param effect The effect to update
  69512. * @param lightIndex The index of the light in the effect to update
  69513. * @returns The hemispheric light
  69514. */
  69515. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69516. /**
  69517. * Computes the world matrix of the node
  69518. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69519. * @param useWasUpdatedFlag defines a reserved property
  69520. * @returns the world matrix
  69521. */
  69522. computeWorldMatrix(): Matrix;
  69523. /**
  69524. * Returns the integer 3.
  69525. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69526. */
  69527. getTypeID(): number;
  69528. /**
  69529. * Prepares the list of defines specific to the light type.
  69530. * @param defines the list of defines
  69531. * @param lightIndex defines the index of the light for the effect
  69532. */
  69533. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69534. }
  69535. }
  69536. declare module BABYLON {
  69537. /**
  69538. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69539. * IMPORTANT!! The data is right-hand data.
  69540. * @export
  69541. * @interface DevicePose
  69542. */
  69543. export interface DevicePose {
  69544. /**
  69545. * The position of the device, values in array are [x,y,z].
  69546. */
  69547. readonly position: Nullable<Float32Array>;
  69548. /**
  69549. * The linearVelocity of the device, values in array are [x,y,z].
  69550. */
  69551. readonly linearVelocity: Nullable<Float32Array>;
  69552. /**
  69553. * The linearAcceleration of the device, values in array are [x,y,z].
  69554. */
  69555. readonly linearAcceleration: Nullable<Float32Array>;
  69556. /**
  69557. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69558. */
  69559. readonly orientation: Nullable<Float32Array>;
  69560. /**
  69561. * The angularVelocity of the device, values in array are [x,y,z].
  69562. */
  69563. readonly angularVelocity: Nullable<Float32Array>;
  69564. /**
  69565. * The angularAcceleration of the device, values in array are [x,y,z].
  69566. */
  69567. readonly angularAcceleration: Nullable<Float32Array>;
  69568. }
  69569. /**
  69570. * Interface representing a pose controlled object in Babylon.
  69571. * A pose controlled object has both regular pose values as well as pose values
  69572. * from an external device such as a VR head mounted display
  69573. */
  69574. export interface PoseControlled {
  69575. /**
  69576. * The position of the object in babylon space.
  69577. */
  69578. position: Vector3;
  69579. /**
  69580. * The rotation quaternion of the object in babylon space.
  69581. */
  69582. rotationQuaternion: Quaternion;
  69583. /**
  69584. * The position of the device in babylon space.
  69585. */
  69586. devicePosition?: Vector3;
  69587. /**
  69588. * The rotation quaternion of the device in babylon space.
  69589. */
  69590. deviceRotationQuaternion: Quaternion;
  69591. /**
  69592. * The raw pose coming from the device.
  69593. */
  69594. rawPose: Nullable<DevicePose>;
  69595. /**
  69596. * The scale of the device to be used when translating from device space to babylon space.
  69597. */
  69598. deviceScaleFactor: number;
  69599. /**
  69600. * Updates the poseControlled values based on the input device pose.
  69601. * @param poseData the pose data to update the object with
  69602. */
  69603. updateFromDevice(poseData: DevicePose): void;
  69604. }
  69605. /**
  69606. * Set of options to customize the webVRCamera
  69607. */
  69608. export interface WebVROptions {
  69609. /**
  69610. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69611. */
  69612. trackPosition?: boolean;
  69613. /**
  69614. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69615. */
  69616. positionScale?: number;
  69617. /**
  69618. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69619. */
  69620. displayName?: string;
  69621. /**
  69622. * Should the native controller meshes be initialized. (default: true)
  69623. */
  69624. controllerMeshes?: boolean;
  69625. /**
  69626. * Creating a default HemiLight only on controllers. (default: true)
  69627. */
  69628. defaultLightingOnControllers?: boolean;
  69629. /**
  69630. * If you don't want to use the default VR button of the helper. (default: false)
  69631. */
  69632. useCustomVRButton?: boolean;
  69633. /**
  69634. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69635. */
  69636. customVRButton?: HTMLButtonElement;
  69637. /**
  69638. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69639. */
  69640. rayLength?: number;
  69641. /**
  69642. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69643. */
  69644. defaultHeight?: number;
  69645. }
  69646. /**
  69647. * This represents a WebVR camera.
  69648. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69649. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69650. */
  69651. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69652. private webVROptions;
  69653. /**
  69654. * @hidden
  69655. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69656. */
  69657. _vrDevice: any;
  69658. /**
  69659. * The rawPose of the vrDevice.
  69660. */
  69661. rawPose: Nullable<DevicePose>;
  69662. private _onVREnabled;
  69663. private _specsVersion;
  69664. private _attached;
  69665. private _frameData;
  69666. protected _descendants: Array<Node>;
  69667. private _deviceRoomPosition;
  69668. /** @hidden */
  69669. _deviceRoomRotationQuaternion: Quaternion;
  69670. private _standingMatrix;
  69671. /**
  69672. * Represents device position in babylon space.
  69673. */
  69674. devicePosition: Vector3;
  69675. /**
  69676. * Represents device rotation in babylon space.
  69677. */
  69678. deviceRotationQuaternion: Quaternion;
  69679. /**
  69680. * The scale of the device to be used when translating from device space to babylon space.
  69681. */
  69682. deviceScaleFactor: number;
  69683. private _deviceToWorld;
  69684. private _worldToDevice;
  69685. /**
  69686. * References to the webVR controllers for the vrDevice.
  69687. */
  69688. controllers: Array<WebVRController>;
  69689. /**
  69690. * Emits an event when a controller is attached.
  69691. */
  69692. onControllersAttachedObservable: Observable<WebVRController[]>;
  69693. /**
  69694. * Emits an event when a controller's mesh has been loaded;
  69695. */
  69696. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69697. /**
  69698. * Emits an event when the HMD's pose has been updated.
  69699. */
  69700. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69701. private _poseSet;
  69702. /**
  69703. * If the rig cameras be used as parent instead of this camera.
  69704. */
  69705. rigParenting: boolean;
  69706. private _lightOnControllers;
  69707. private _defaultHeight?;
  69708. /**
  69709. * Instantiates a WebVRFreeCamera.
  69710. * @param name The name of the WebVRFreeCamera
  69711. * @param position The starting anchor position for the camera
  69712. * @param scene The scene the camera belongs to
  69713. * @param webVROptions a set of customizable options for the webVRCamera
  69714. */
  69715. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69716. /**
  69717. * Gets the device distance from the ground in meters.
  69718. * @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.
  69719. */
  69720. deviceDistanceToRoomGround(): number;
  69721. /**
  69722. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69723. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69724. */
  69725. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69726. /**
  69727. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69728. * @returns A promise with a boolean set to if the standing matrix is supported.
  69729. */
  69730. useStandingMatrixAsync(): Promise<boolean>;
  69731. /**
  69732. * Disposes the camera
  69733. */
  69734. dispose(): void;
  69735. /**
  69736. * Gets a vrController by name.
  69737. * @param name The name of the controller to retreive
  69738. * @returns the controller matching the name specified or null if not found
  69739. */
  69740. getControllerByName(name: string): Nullable<WebVRController>;
  69741. private _leftController;
  69742. /**
  69743. * The controller corrisponding to the users left hand.
  69744. */
  69745. readonly leftController: Nullable<WebVRController>;
  69746. private _rightController;
  69747. /**
  69748. * The controller corrisponding to the users right hand.
  69749. */
  69750. readonly rightController: Nullable<WebVRController>;
  69751. /**
  69752. * Casts a ray forward from the vrCamera's gaze.
  69753. * @param length Length of the ray (default: 100)
  69754. * @returns the ray corrisponding to the gaze
  69755. */
  69756. getForwardRay(length?: number): Ray;
  69757. /**
  69758. * @hidden
  69759. * Updates the camera based on device's frame data
  69760. */
  69761. _checkInputs(): void;
  69762. /**
  69763. * Updates the poseControlled values based on the input device pose.
  69764. * @param poseData Pose coming from the device
  69765. */
  69766. updateFromDevice(poseData: DevicePose): void;
  69767. private _htmlElementAttached;
  69768. private _detachIfAttached;
  69769. /**
  69770. * WebVR's attach control will start broadcasting frames to the device.
  69771. * Note that in certain browsers (chrome for example) this function must be called
  69772. * within a user-interaction callback. Example:
  69773. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69774. *
  69775. * @param element html element to attach the vrDevice to
  69776. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69777. */
  69778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69779. /**
  69780. * Detaches the camera from the html element and disables VR
  69781. *
  69782. * @param element html element to detach from
  69783. */
  69784. detachControl(element: HTMLElement): void;
  69785. /**
  69786. * @returns the name of this class
  69787. */
  69788. getClassName(): string;
  69789. /**
  69790. * Calls resetPose on the vrDisplay
  69791. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69792. */
  69793. resetToCurrentRotation(): void;
  69794. /**
  69795. * @hidden
  69796. * Updates the rig cameras (left and right eye)
  69797. */
  69798. _updateRigCameras(): void;
  69799. private _workingVector;
  69800. private _oneVector;
  69801. private _workingMatrix;
  69802. private updateCacheCalled;
  69803. private _correctPositionIfNotTrackPosition;
  69804. /**
  69805. * @hidden
  69806. * Updates the cached values of the camera
  69807. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69808. */
  69809. _updateCache(ignoreParentClass?: boolean): void;
  69810. /**
  69811. * @hidden
  69812. * Get current device position in babylon world
  69813. */
  69814. _computeDevicePosition(): void;
  69815. /**
  69816. * Updates the current device position and rotation in the babylon world
  69817. */
  69818. update(): void;
  69819. /**
  69820. * @hidden
  69821. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69822. * @returns an identity matrix
  69823. */
  69824. _getViewMatrix(): Matrix;
  69825. private _tmpMatrix;
  69826. /**
  69827. * This function is called by the two RIG cameras.
  69828. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69829. * @hidden
  69830. */
  69831. _getWebVRViewMatrix(): Matrix;
  69832. /** @hidden */
  69833. _getWebVRProjectionMatrix(): Matrix;
  69834. private _onGamepadConnectedObserver;
  69835. private _onGamepadDisconnectedObserver;
  69836. private _updateCacheWhenTrackingDisabledObserver;
  69837. /**
  69838. * Initializes the controllers and their meshes
  69839. */
  69840. initControllers(): void;
  69841. }
  69842. }
  69843. declare module BABYLON {
  69844. /**
  69845. * Size options for a post process
  69846. */
  69847. export type PostProcessOptions = {
  69848. width: number;
  69849. height: number;
  69850. };
  69851. /**
  69852. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69853. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69854. */
  69855. export class PostProcess {
  69856. /** Name of the PostProcess. */
  69857. name: string;
  69858. /**
  69859. * Gets or sets the unique id of the post process
  69860. */
  69861. uniqueId: number;
  69862. /**
  69863. * Width of the texture to apply the post process on
  69864. */
  69865. width: number;
  69866. /**
  69867. * Height of the texture to apply the post process on
  69868. */
  69869. height: number;
  69870. /**
  69871. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69872. * @hidden
  69873. */
  69874. _outputTexture: Nullable<InternalTexture>;
  69875. /**
  69876. * Sampling mode used by the shader
  69877. * See https://doc.babylonjs.com/classes/3.1/texture
  69878. */
  69879. renderTargetSamplingMode: number;
  69880. /**
  69881. * Clear color to use when screen clearing
  69882. */
  69883. clearColor: Color4;
  69884. /**
  69885. * If the buffer needs to be cleared before applying the post process. (default: true)
  69886. * Should be set to false if shader will overwrite all previous pixels.
  69887. */
  69888. autoClear: boolean;
  69889. /**
  69890. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69891. */
  69892. alphaMode: number;
  69893. /**
  69894. * Sets the setAlphaBlendConstants of the babylon engine
  69895. */
  69896. alphaConstants: Color4;
  69897. /**
  69898. * Animations to be used for the post processing
  69899. */
  69900. animations: Animation[];
  69901. /**
  69902. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69903. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69904. */
  69905. enablePixelPerfectMode: boolean;
  69906. /**
  69907. * Force the postprocess to be applied without taking in account viewport
  69908. */
  69909. forceFullscreenViewport: boolean;
  69910. /**
  69911. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  69912. *
  69913. * | Value | Type | Description |
  69914. * | ----- | ----------------------------------- | ----------- |
  69915. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  69916. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  69917. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  69918. *
  69919. */
  69920. scaleMode: number;
  69921. /**
  69922. * Force textures to be a power of two (default: false)
  69923. */
  69924. alwaysForcePOT: boolean;
  69925. private _samples;
  69926. /**
  69927. * Number of sample textures (default: 1)
  69928. */
  69929. samples: number;
  69930. /**
  69931. * Modify the scale of the post process to be the same as the viewport (default: false)
  69932. */
  69933. adaptScaleToCurrentViewport: boolean;
  69934. private _camera;
  69935. private _scene;
  69936. private _engine;
  69937. private _options;
  69938. private _reusable;
  69939. private _textureType;
  69940. /**
  69941. * Smart array of input and output textures for the post process.
  69942. * @hidden
  69943. */
  69944. _textures: SmartArray<InternalTexture>;
  69945. /**
  69946. * The index in _textures that corresponds to the output texture.
  69947. * @hidden
  69948. */
  69949. _currentRenderTextureInd: number;
  69950. private _effect;
  69951. private _samplers;
  69952. private _fragmentUrl;
  69953. private _vertexUrl;
  69954. private _parameters;
  69955. private _scaleRatio;
  69956. protected _indexParameters: any;
  69957. private _shareOutputWithPostProcess;
  69958. private _texelSize;
  69959. private _forcedOutputTexture;
  69960. /**
  69961. * Returns the fragment url or shader name used in the post process.
  69962. * @returns the fragment url or name in the shader store.
  69963. */
  69964. getEffectName(): string;
  69965. /**
  69966. * An event triggered when the postprocess is activated.
  69967. */
  69968. onActivateObservable: Observable<Camera>;
  69969. private _onActivateObserver;
  69970. /**
  69971. * A function that is added to the onActivateObservable
  69972. */
  69973. onActivate: Nullable<(camera: Camera) => void>;
  69974. /**
  69975. * An event triggered when the postprocess changes its size.
  69976. */
  69977. onSizeChangedObservable: Observable<PostProcess>;
  69978. private _onSizeChangedObserver;
  69979. /**
  69980. * A function that is added to the onSizeChangedObservable
  69981. */
  69982. onSizeChanged: (postProcess: PostProcess) => void;
  69983. /**
  69984. * An event triggered when the postprocess applies its effect.
  69985. */
  69986. onApplyObservable: Observable<Effect>;
  69987. private _onApplyObserver;
  69988. /**
  69989. * A function that is added to the onApplyObservable
  69990. */
  69991. onApply: (effect: Effect) => void;
  69992. /**
  69993. * An event triggered before rendering the postprocess
  69994. */
  69995. onBeforeRenderObservable: Observable<Effect>;
  69996. private _onBeforeRenderObserver;
  69997. /**
  69998. * A function that is added to the onBeforeRenderObservable
  69999. */
  70000. onBeforeRender: (effect: Effect) => void;
  70001. /**
  70002. * An event triggered after rendering the postprocess
  70003. */
  70004. onAfterRenderObservable: Observable<Effect>;
  70005. private _onAfterRenderObserver;
  70006. /**
  70007. * A function that is added to the onAfterRenderObservable
  70008. */
  70009. onAfterRender: (efect: Effect) => void;
  70010. /**
  70011. * 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
  70012. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70013. */
  70014. inputTexture: InternalTexture;
  70015. /**
  70016. * Gets the camera which post process is applied to.
  70017. * @returns The camera the post process is applied to.
  70018. */
  70019. getCamera(): Camera;
  70020. /**
  70021. * Gets the texel size of the postprocess.
  70022. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70023. */
  70024. readonly texelSize: Vector2;
  70025. /**
  70026. * Creates a new instance PostProcess
  70027. * @param name The name of the PostProcess.
  70028. * @param fragmentUrl The url of the fragment shader to be used.
  70029. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70030. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70031. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70032. * @param camera The camera to apply the render pass to.
  70033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70034. * @param engine The engine which the post process will be applied. (default: current engine)
  70035. * @param reusable If the post process can be reused on the same frame. (default: false)
  70036. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70037. * @param textureType Type of textures used when performing the post process. (default: 0)
  70038. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70039. * @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
  70040. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70041. */
  70042. constructor(
  70043. /** Name of the PostProcess. */
  70044. 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);
  70045. /**
  70046. * Gets a string idenfifying the name of the class
  70047. * @returns "PostProcess" string
  70048. */
  70049. getClassName(): string;
  70050. /**
  70051. * Gets the engine which this post process belongs to.
  70052. * @returns The engine the post process was enabled with.
  70053. */
  70054. getEngine(): Engine;
  70055. /**
  70056. * The effect that is created when initializing the post process.
  70057. * @returns The created effect corrisponding the the postprocess.
  70058. */
  70059. getEffect(): Effect;
  70060. /**
  70061. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70062. * @param postProcess The post process to share the output with.
  70063. * @returns This post process.
  70064. */
  70065. shareOutputWith(postProcess: PostProcess): PostProcess;
  70066. /**
  70067. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70068. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70069. */
  70070. useOwnOutput(): void;
  70071. /**
  70072. * Updates the effect with the current post process compile time values and recompiles the shader.
  70073. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70074. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70075. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70076. * @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
  70077. * @param onCompiled Called when the shader has been compiled.
  70078. * @param onError Called if there is an error when compiling a shader.
  70079. */
  70080. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70081. /**
  70082. * The post process is reusable if it can be used multiple times within one frame.
  70083. * @returns If the post process is reusable
  70084. */
  70085. isReusable(): boolean;
  70086. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70087. markTextureDirty(): void;
  70088. /**
  70089. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70090. * 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.
  70091. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70092. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70093. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70094. * @returns The target texture that was bound to be written to.
  70095. */
  70096. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70097. /**
  70098. * If the post process is supported.
  70099. */
  70100. readonly isSupported: boolean;
  70101. /**
  70102. * The aspect ratio of the output texture.
  70103. */
  70104. readonly aspectRatio: number;
  70105. /**
  70106. * Get a value indicating if the post-process is ready to be used
  70107. * @returns true if the post-process is ready (shader is compiled)
  70108. */
  70109. isReady(): boolean;
  70110. /**
  70111. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70112. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70113. */
  70114. apply(): Nullable<Effect>;
  70115. private _disposeTextures;
  70116. /**
  70117. * Disposes the post process.
  70118. * @param camera The camera to dispose the post process on.
  70119. */
  70120. dispose(camera?: Camera): void;
  70121. }
  70122. }
  70123. declare module BABYLON {
  70124. /**
  70125. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70126. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70127. */
  70128. export class PostProcessManager {
  70129. private _scene;
  70130. private _indexBuffer;
  70131. private _vertexBuffers;
  70132. /**
  70133. * Creates a new instance PostProcess
  70134. * @param scene The scene that the post process is associated with.
  70135. */
  70136. constructor(scene: Scene);
  70137. private _prepareBuffers;
  70138. private _buildIndexBuffer;
  70139. /**
  70140. * Rebuilds the vertex buffers of the manager.
  70141. * @hidden
  70142. */
  70143. _rebuild(): void;
  70144. /**
  70145. * Prepares a frame to be run through a post process.
  70146. * @param sourceTexture The input texture to the post procesess. (default: null)
  70147. * @param postProcesses An array of post processes to be run. (default: null)
  70148. * @returns True if the post processes were able to be run.
  70149. * @hidden
  70150. */
  70151. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70152. /**
  70153. * Manually render a set of post processes to a texture.
  70154. * @param postProcesses An array of post processes to be run.
  70155. * @param targetTexture The target texture to render to.
  70156. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70157. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70158. * @param lodLevel defines which lod of the texture to render to
  70159. */
  70160. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70161. /**
  70162. * Finalize the result of the output of the postprocesses.
  70163. * @param doNotPresent If true the result will not be displayed to the screen.
  70164. * @param targetTexture The target texture to render to.
  70165. * @param faceIndex The index of the face to bind the target texture to.
  70166. * @param postProcesses The array of post processes to render.
  70167. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70168. * @hidden
  70169. */
  70170. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70171. /**
  70172. * Disposes of the post process manager.
  70173. */
  70174. dispose(): void;
  70175. }
  70176. }
  70177. declare module BABYLON {
  70178. /**
  70179. * Raw texture can help creating a texture directly from an array of data.
  70180. * This can be super useful if you either get the data from an uncompressed source or
  70181. * if you wish to create your texture pixel by pixel.
  70182. */
  70183. export class RawTexture extends Texture {
  70184. /**
  70185. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70186. */
  70187. format: number;
  70188. private _engine;
  70189. /**
  70190. * Instantiates a new RawTexture.
  70191. * Raw texture can help creating a texture directly from an array of data.
  70192. * This can be super useful if you either get the data from an uncompressed source or
  70193. * if you wish to create your texture pixel by pixel.
  70194. * @param data define the array of data to use to create the texture
  70195. * @param width define the width of the texture
  70196. * @param height define the height of the texture
  70197. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70198. * @param scene define the scene the texture belongs to
  70199. * @param generateMipMaps define whether mip maps should be generated or not
  70200. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70201. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70202. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70203. */
  70204. constructor(data: ArrayBufferView, width: number, height: number,
  70205. /**
  70206. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  70207. */
  70208. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  70209. /**
  70210. * Updates the texture underlying data.
  70211. * @param data Define the new data of the texture
  70212. */
  70213. update(data: ArrayBufferView): void;
  70214. /**
  70215. * Creates a luminance texture from some data.
  70216. * @param data Define the texture data
  70217. * @param width Define the width of the texture
  70218. * @param height Define the height of the texture
  70219. * @param scene Define the scene the texture belongs to
  70220. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70221. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70222. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70223. * @returns the luminance texture
  70224. */
  70225. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70226. /**
  70227. * Creates a luminance alpha texture from some data.
  70228. * @param data Define the texture data
  70229. * @param width Define the width of the texture
  70230. * @param height Define the height of the texture
  70231. * @param scene Define the scene the texture belongs to
  70232. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70233. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70234. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70235. * @returns the luminance alpha texture
  70236. */
  70237. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70238. /**
  70239. * Creates an alpha texture from some data.
  70240. * @param data Define the texture data
  70241. * @param width Define the width of the texture
  70242. * @param height Define the height of the texture
  70243. * @param scene Define the scene the texture belongs to
  70244. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70245. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70246. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70247. * @returns the alpha texture
  70248. */
  70249. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  70250. /**
  70251. * Creates a RGB texture from some data.
  70252. * @param data Define the texture data
  70253. * @param width Define the width of the texture
  70254. * @param height Define the height of the texture
  70255. * @param scene Define the scene the texture belongs to
  70256. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70257. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70258. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70259. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70260. * @returns the RGB alpha texture
  70261. */
  70262. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70263. /**
  70264. * Creates a RGBA texture from some data.
  70265. * @param data Define the texture data
  70266. * @param width Define the width of the texture
  70267. * @param height Define the height of the texture
  70268. * @param scene Define the scene the texture belongs to
  70269. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70270. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70271. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70272. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70273. * @returns the RGBA texture
  70274. */
  70275. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70276. /**
  70277. * Creates a R texture from some data.
  70278. * @param data Define the texture data
  70279. * @param width Define the width of the texture
  70280. * @param height Define the height of the texture
  70281. * @param scene Define the scene the texture belongs to
  70282. * @param generateMipMaps Define whether or not to create mip maps for the texture
  70283. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  70284. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  70285. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  70286. * @returns the R texture
  70287. */
  70288. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  70289. }
  70290. }
  70291. declare module BABYLON {
  70292. interface AbstractScene {
  70293. /**
  70294. * The list of layers (background and foreground) of the scene
  70295. */
  70296. layers: Array<Layer>;
  70297. }
  70298. /**
  70299. * Defines the layer scene component responsible to manage any layers
  70300. * in a given scene.
  70301. */
  70302. export class LayerSceneComponent implements ISceneComponent {
  70303. /**
  70304. * The component name helpfull to identify the component in the list of scene components.
  70305. */
  70306. readonly name: string;
  70307. /**
  70308. * The scene the component belongs to.
  70309. */
  70310. scene: Scene;
  70311. private _engine;
  70312. /**
  70313. * Creates a new instance of the component for the given scene
  70314. * @param scene Defines the scene to register the component in
  70315. */
  70316. constructor(scene: Scene);
  70317. /**
  70318. * Registers the component in a given scene
  70319. */
  70320. register(): void;
  70321. /**
  70322. * Rebuilds the elements related to this component in case of
  70323. * context lost for instance.
  70324. */
  70325. rebuild(): void;
  70326. /**
  70327. * Disposes the component and the associated ressources.
  70328. */
  70329. dispose(): void;
  70330. private _draw;
  70331. private _drawCameraPredicate;
  70332. private _drawCameraBackground;
  70333. private _drawCameraForeground;
  70334. private _drawRenderTargetPredicate;
  70335. private _drawRenderTargetBackground;
  70336. private _drawRenderTargetForeground;
  70337. }
  70338. }
  70339. declare module BABYLON {
  70340. /** @hidden */
  70341. export var layerPixelShader: {
  70342. name: string;
  70343. shader: string;
  70344. };
  70345. }
  70346. declare module BABYLON {
  70347. /** @hidden */
  70348. export var layerVertexShader: {
  70349. name: string;
  70350. shader: string;
  70351. };
  70352. }
  70353. declare module BABYLON {
  70354. /**
  70355. * This represents a full screen 2d layer.
  70356. * This can be useful to display a picture in the background of your scene for instance.
  70357. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70358. */
  70359. export class Layer {
  70360. /**
  70361. * Define the name of the layer.
  70362. */
  70363. name: string;
  70364. /**
  70365. * Define the texture the layer should display.
  70366. */
  70367. texture: Nullable<Texture>;
  70368. /**
  70369. * Is the layer in background or foreground.
  70370. */
  70371. isBackground: boolean;
  70372. /**
  70373. * Define the color of the layer (instead of texture).
  70374. */
  70375. color: Color4;
  70376. /**
  70377. * Define the scale of the layer in order to zoom in out of the texture.
  70378. */
  70379. scale: Vector2;
  70380. /**
  70381. * Define an offset for the layer in order to shift the texture.
  70382. */
  70383. offset: Vector2;
  70384. /**
  70385. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70386. */
  70387. alphaBlendingMode: number;
  70388. /**
  70389. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70390. * Alpha test will not mix with the background color in case of transparency.
  70391. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70392. */
  70393. alphaTest: boolean;
  70394. /**
  70395. * Define a mask to restrict the layer to only some of the scene cameras.
  70396. */
  70397. layerMask: number;
  70398. /**
  70399. * Define the list of render target the layer is visible into.
  70400. */
  70401. renderTargetTextures: RenderTargetTexture[];
  70402. /**
  70403. * Define if the layer is only used in renderTarget or if it also
  70404. * renders in the main frame buffer of the canvas.
  70405. */
  70406. renderOnlyInRenderTargetTextures: boolean;
  70407. private _scene;
  70408. private _vertexBuffers;
  70409. private _indexBuffer;
  70410. private _effect;
  70411. private _alphaTestEffect;
  70412. /**
  70413. * An event triggered when the layer is disposed.
  70414. */
  70415. onDisposeObservable: Observable<Layer>;
  70416. private _onDisposeObserver;
  70417. /**
  70418. * Back compatibility with callback before the onDisposeObservable existed.
  70419. * The set callback will be triggered when the layer has been disposed.
  70420. */
  70421. onDispose: () => void;
  70422. /**
  70423. * An event triggered before rendering the scene
  70424. */
  70425. onBeforeRenderObservable: Observable<Layer>;
  70426. private _onBeforeRenderObserver;
  70427. /**
  70428. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70429. * The set callback will be triggered just before rendering the layer.
  70430. */
  70431. onBeforeRender: () => void;
  70432. /**
  70433. * An event triggered after rendering the scene
  70434. */
  70435. onAfterRenderObservable: Observable<Layer>;
  70436. private _onAfterRenderObserver;
  70437. /**
  70438. * Back compatibility with callback before the onAfterRenderObservable existed.
  70439. * The set callback will be triggered just after rendering the layer.
  70440. */
  70441. onAfterRender: () => void;
  70442. /**
  70443. * Instantiates a new layer.
  70444. * This represents a full screen 2d layer.
  70445. * This can be useful to display a picture in the background of your scene for instance.
  70446. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70447. * @param name Define the name of the layer in the scene
  70448. * @param imgUrl Define the url of the texture to display in the layer
  70449. * @param scene Define the scene the layer belongs to
  70450. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70451. * @param color Defines a color for the layer
  70452. */
  70453. constructor(
  70454. /**
  70455. * Define the name of the layer.
  70456. */
  70457. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70458. private _createIndexBuffer;
  70459. /** @hidden */
  70460. _rebuild(): void;
  70461. /**
  70462. * Renders the layer in the scene.
  70463. */
  70464. render(): void;
  70465. /**
  70466. * Disposes and releases the associated ressources.
  70467. */
  70468. dispose(): void;
  70469. }
  70470. }
  70471. declare module BABYLON {
  70472. interface AbstractScene {
  70473. /**
  70474. * The list of procedural textures added to the scene
  70475. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70476. */
  70477. proceduralTextures: Array<ProceduralTexture>;
  70478. }
  70479. /**
  70480. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70481. * in a given scene.
  70482. */
  70483. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70484. /**
  70485. * The component name helpfull to identify the component in the list of scene components.
  70486. */
  70487. readonly name: string;
  70488. /**
  70489. * The scene the component belongs to.
  70490. */
  70491. scene: Scene;
  70492. /**
  70493. * Creates a new instance of the component for the given scene
  70494. * @param scene Defines the scene to register the component in
  70495. */
  70496. constructor(scene: Scene);
  70497. /**
  70498. * Registers the component in a given scene
  70499. */
  70500. register(): void;
  70501. /**
  70502. * Rebuilds the elements related to this component in case of
  70503. * context lost for instance.
  70504. */
  70505. rebuild(): void;
  70506. /**
  70507. * Disposes the component and the associated ressources.
  70508. */
  70509. dispose(): void;
  70510. private _beforeClear;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /** @hidden */
  70515. export var proceduralVertexShader: {
  70516. name: string;
  70517. shader: string;
  70518. };
  70519. }
  70520. declare module BABYLON {
  70521. /**
  70522. * 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.
  70523. * This is the base class of any Procedural texture and contains most of the shareable code.
  70524. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70525. */
  70526. export class ProceduralTexture extends Texture {
  70527. isCube: boolean;
  70528. /**
  70529. * Define if the texture is enabled or not (disabled texture will not render)
  70530. */
  70531. isEnabled: boolean;
  70532. /**
  70533. * Define if the texture must be cleared before rendering (default is true)
  70534. */
  70535. autoClear: boolean;
  70536. /**
  70537. * Callback called when the texture is generated
  70538. */
  70539. onGenerated: () => void;
  70540. /**
  70541. * Event raised when the texture is generated
  70542. */
  70543. onGeneratedObservable: Observable<ProceduralTexture>;
  70544. /** @hidden */
  70545. _generateMipMaps: boolean;
  70546. /** @hidden **/
  70547. _effect: Effect;
  70548. /** @hidden */
  70549. _textures: {
  70550. [key: string]: Texture;
  70551. };
  70552. private _size;
  70553. private _currentRefreshId;
  70554. private _refreshRate;
  70555. private _vertexBuffers;
  70556. private _indexBuffer;
  70557. private _uniforms;
  70558. private _samplers;
  70559. private _fragment;
  70560. private _floats;
  70561. private _ints;
  70562. private _floatsArrays;
  70563. private _colors3;
  70564. private _colors4;
  70565. private _vectors2;
  70566. private _vectors3;
  70567. private _matrices;
  70568. private _fallbackTexture;
  70569. private _fallbackTextureUsed;
  70570. private _engine;
  70571. private _cachedDefines;
  70572. private _contentUpdateId;
  70573. private _contentData;
  70574. /**
  70575. * Instantiates a new procedural texture.
  70576. * 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.
  70577. * This is the base class of any Procedural texture and contains most of the shareable code.
  70578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70579. * @param name Define the name of the texture
  70580. * @param size Define the size of the texture to create
  70581. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70582. * @param scene Define the scene the texture belongs to
  70583. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70584. * @param generateMipMaps Define if the texture should creates mip maps or not
  70585. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70586. */
  70587. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70588. /**
  70589. * The effect that is created when initializing the post process.
  70590. * @returns The created effect corrisponding the the postprocess.
  70591. */
  70592. getEffect(): Effect;
  70593. /**
  70594. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70595. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70596. */
  70597. getContent(): Nullable<ArrayBufferView>;
  70598. private _createIndexBuffer;
  70599. /** @hidden */
  70600. _rebuild(): void;
  70601. /**
  70602. * Resets the texture in order to recreate its associated resources.
  70603. * This can be called in case of context loss
  70604. */
  70605. reset(): void;
  70606. protected _getDefines(): string;
  70607. /**
  70608. * Is the texture ready to be used ? (rendered at least once)
  70609. * @returns true if ready, otherwise, false.
  70610. */
  70611. isReady(): boolean;
  70612. /**
  70613. * Resets the refresh counter of the texture and start bak from scratch.
  70614. * Could be useful to regenerate the texture if it is setup to render only once.
  70615. */
  70616. resetRefreshCounter(): void;
  70617. /**
  70618. * Set the fragment shader to use in order to render the texture.
  70619. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70620. */
  70621. setFragment(fragment: any): void;
  70622. /**
  70623. * Define the refresh rate of the texture or the rendering frequency.
  70624. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70625. */
  70626. refreshRate: number;
  70627. /** @hidden */
  70628. _shouldRender(): boolean;
  70629. /**
  70630. * Get the size the texture is rendering at.
  70631. * @returns the size (texture is always squared)
  70632. */
  70633. getRenderSize(): number;
  70634. /**
  70635. * Resize the texture to new value.
  70636. * @param size Define the new size the texture should have
  70637. * @param generateMipMaps Define whether the new texture should create mip maps
  70638. */
  70639. resize(size: number, generateMipMaps: boolean): void;
  70640. private _checkUniform;
  70641. /**
  70642. * Set a texture in the shader program used to render.
  70643. * @param name Define the name of the uniform samplers as defined in the shader
  70644. * @param texture Define the texture to bind to this sampler
  70645. * @return the texture itself allowing "fluent" like uniform updates
  70646. */
  70647. setTexture(name: string, texture: Texture): ProceduralTexture;
  70648. /**
  70649. * Set a float in the shader.
  70650. * @param name Define the name of the uniform as defined in the shader
  70651. * @param value Define the value to give to the uniform
  70652. * @return the texture itself allowing "fluent" like uniform updates
  70653. */
  70654. setFloat(name: string, value: number): ProceduralTexture;
  70655. /**
  70656. * Set a int in the shader.
  70657. * @param name Define the name of the uniform as defined in the shader
  70658. * @param value Define the value to give to the uniform
  70659. * @return the texture itself allowing "fluent" like uniform updates
  70660. */
  70661. setInt(name: string, value: number): ProceduralTexture;
  70662. /**
  70663. * Set an array of floats in the shader.
  70664. * @param name Define the name of the uniform as defined in the shader
  70665. * @param value Define the value to give to the uniform
  70666. * @return the texture itself allowing "fluent" like uniform updates
  70667. */
  70668. setFloats(name: string, value: number[]): ProceduralTexture;
  70669. /**
  70670. * Set a vec3 in the shader from a Color3.
  70671. * @param name Define the name of the uniform as defined in the shader
  70672. * @param value Define the value to give to the uniform
  70673. * @return the texture itself allowing "fluent" like uniform updates
  70674. */
  70675. setColor3(name: string, value: Color3): ProceduralTexture;
  70676. /**
  70677. * Set a vec4 in the shader from a Color4.
  70678. * @param name Define the name of the uniform as defined in the shader
  70679. * @param value Define the value to give to the uniform
  70680. * @return the texture itself allowing "fluent" like uniform updates
  70681. */
  70682. setColor4(name: string, value: Color4): ProceduralTexture;
  70683. /**
  70684. * Set a vec2 in the shader from a Vector2.
  70685. * @param name Define the name of the uniform as defined in the shader
  70686. * @param value Define the value to give to the uniform
  70687. * @return the texture itself allowing "fluent" like uniform updates
  70688. */
  70689. setVector2(name: string, value: Vector2): ProceduralTexture;
  70690. /**
  70691. * Set a vec3 in the shader from a Vector3.
  70692. * @param name Define the name of the uniform as defined in the shader
  70693. * @param value Define the value to give to the uniform
  70694. * @return the texture itself allowing "fluent" like uniform updates
  70695. */
  70696. setVector3(name: string, value: Vector3): ProceduralTexture;
  70697. /**
  70698. * Set a mat4 in the shader from a MAtrix.
  70699. * @param name Define the name of the uniform as defined in the shader
  70700. * @param value Define the value to give to the uniform
  70701. * @return the texture itself allowing "fluent" like uniform updates
  70702. */
  70703. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70704. /**
  70705. * Render the texture to its associated render target.
  70706. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70707. */
  70708. render(useCameraPostProcess?: boolean): void;
  70709. /**
  70710. * Clone the texture.
  70711. * @returns the cloned texture
  70712. */
  70713. clone(): ProceduralTexture;
  70714. /**
  70715. * Dispose the texture and release its asoociated resources.
  70716. */
  70717. dispose(): void;
  70718. }
  70719. }
  70720. declare module BABYLON {
  70721. /**
  70722. * This represents the base class for particle system in Babylon.
  70723. * 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.
  70724. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70725. * @example https://doc.babylonjs.com/babylon101/particles
  70726. */
  70727. export class BaseParticleSystem {
  70728. /**
  70729. * Source color is added to the destination color without alpha affecting the result
  70730. */
  70731. static BLENDMODE_ONEONE: number;
  70732. /**
  70733. * Blend current color and particle color using particle’s alpha
  70734. */
  70735. static BLENDMODE_STANDARD: number;
  70736. /**
  70737. * Add current color and particle color multiplied by particle’s alpha
  70738. */
  70739. static BLENDMODE_ADD: number;
  70740. /**
  70741. * Multiply current color with particle color
  70742. */
  70743. static BLENDMODE_MULTIPLY: number;
  70744. /**
  70745. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70746. */
  70747. static BLENDMODE_MULTIPLYADD: number;
  70748. /**
  70749. * List of animations used by the particle system.
  70750. */
  70751. animations: Animation[];
  70752. /**
  70753. * The id of the Particle system.
  70754. */
  70755. id: string;
  70756. /**
  70757. * The friendly name of the Particle system.
  70758. */
  70759. name: string;
  70760. /**
  70761. * The rendering group used by the Particle system to chose when to render.
  70762. */
  70763. renderingGroupId: number;
  70764. /**
  70765. * The emitter represents the Mesh or position we are attaching the particle system to.
  70766. */
  70767. emitter: Nullable<AbstractMesh | Vector3>;
  70768. /**
  70769. * The maximum number of particles to emit per frame
  70770. */
  70771. emitRate: number;
  70772. /**
  70773. * If you want to launch only a few particles at once, that can be done, as well.
  70774. */
  70775. manualEmitCount: number;
  70776. /**
  70777. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70778. */
  70779. updateSpeed: number;
  70780. /**
  70781. * The amount of time the particle system is running (depends of the overall update speed).
  70782. */
  70783. targetStopDuration: number;
  70784. /**
  70785. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70786. */
  70787. disposeOnStop: boolean;
  70788. /**
  70789. * Minimum power of emitting particles.
  70790. */
  70791. minEmitPower: number;
  70792. /**
  70793. * Maximum power of emitting particles.
  70794. */
  70795. maxEmitPower: number;
  70796. /**
  70797. * Minimum life time of emitting particles.
  70798. */
  70799. minLifeTime: number;
  70800. /**
  70801. * Maximum life time of emitting particles.
  70802. */
  70803. maxLifeTime: number;
  70804. /**
  70805. * Minimum Size of emitting particles.
  70806. */
  70807. minSize: number;
  70808. /**
  70809. * Maximum Size of emitting particles.
  70810. */
  70811. maxSize: number;
  70812. /**
  70813. * Minimum scale of emitting particles on X axis.
  70814. */
  70815. minScaleX: number;
  70816. /**
  70817. * Maximum scale of emitting particles on X axis.
  70818. */
  70819. maxScaleX: number;
  70820. /**
  70821. * Minimum scale of emitting particles on Y axis.
  70822. */
  70823. minScaleY: number;
  70824. /**
  70825. * Maximum scale of emitting particles on Y axis.
  70826. */
  70827. maxScaleY: number;
  70828. /**
  70829. * Gets or sets the minimal initial rotation in radians.
  70830. */
  70831. minInitialRotation: number;
  70832. /**
  70833. * Gets or sets the maximal initial rotation in radians.
  70834. */
  70835. maxInitialRotation: number;
  70836. /**
  70837. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70838. */
  70839. minAngularSpeed: number;
  70840. /**
  70841. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70842. */
  70843. maxAngularSpeed: number;
  70844. /**
  70845. * The texture used to render each particle. (this can be a spritesheet)
  70846. */
  70847. particleTexture: Nullable<Texture>;
  70848. /**
  70849. * The layer mask we are rendering the particles through.
  70850. */
  70851. layerMask: number;
  70852. /**
  70853. * This can help using your own shader to render the particle system.
  70854. * The according effect will be created
  70855. */
  70856. customShader: any;
  70857. /**
  70858. * By default particle system starts as soon as they are created. This prevents the
  70859. * automatic start to happen and let you decide when to start emitting particles.
  70860. */
  70861. preventAutoStart: boolean;
  70862. private _noiseTexture;
  70863. /**
  70864. * Gets or sets a texture used to add random noise to particle positions
  70865. */
  70866. noiseTexture: Nullable<ProceduralTexture>;
  70867. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70868. noiseStrength: Vector3;
  70869. /**
  70870. * Callback triggered when the particle animation is ending.
  70871. */
  70872. onAnimationEnd: Nullable<() => void>;
  70873. /**
  70874. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70875. */
  70876. blendMode: number;
  70877. /**
  70878. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70879. * to override the particles.
  70880. */
  70881. forceDepthWrite: boolean;
  70882. /** 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 */
  70883. preWarmCycles: number;
  70884. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70885. preWarmStepOffset: number;
  70886. /**
  70887. * 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)
  70888. */
  70889. spriteCellChangeSpeed: number;
  70890. /**
  70891. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70892. */
  70893. startSpriteCellID: number;
  70894. /**
  70895. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70896. */
  70897. endSpriteCellID: number;
  70898. /**
  70899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70900. */
  70901. spriteCellWidth: number;
  70902. /**
  70903. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70904. */
  70905. spriteCellHeight: number;
  70906. /**
  70907. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70908. */
  70909. spriteRandomStartCell: boolean;
  70910. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70911. translationPivot: Vector2;
  70912. /** @hidden */
  70913. protected _isAnimationSheetEnabled: boolean;
  70914. /**
  70915. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70916. */
  70917. beginAnimationOnStart: boolean;
  70918. /**
  70919. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70920. */
  70921. beginAnimationFrom: number;
  70922. /**
  70923. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70924. */
  70925. beginAnimationTo: number;
  70926. /**
  70927. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70928. */
  70929. beginAnimationLoop: boolean;
  70930. /**
  70931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70932. */
  70933. isAnimationSheetEnabled: boolean;
  70934. /**
  70935. * Get hosting scene
  70936. * @returns the scene
  70937. */
  70938. getScene(): Scene;
  70939. /**
  70940. * You can use gravity if you want to give an orientation to your particles.
  70941. */
  70942. gravity: Vector3;
  70943. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70944. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70945. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70946. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70947. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70948. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70949. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70950. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70951. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70952. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70953. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70954. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70955. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70956. /**
  70957. * Defines the delay in milliseconds before starting the system (0 by default)
  70958. */
  70959. startDelay: number;
  70960. /**
  70961. * Gets the current list of drag gradients.
  70962. * You must use addDragGradient and removeDragGradient to udpate this list
  70963. * @returns the list of drag gradients
  70964. */
  70965. getDragGradients(): Nullable<Array<FactorGradient>>;
  70966. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70967. limitVelocityDamping: number;
  70968. /**
  70969. * Gets the current list of limit velocity gradients.
  70970. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70971. * @returns the list of limit velocity gradients
  70972. */
  70973. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70974. /**
  70975. * Gets the current list of color gradients.
  70976. * You must use addColorGradient and removeColorGradient to udpate this list
  70977. * @returns the list of color gradients
  70978. */
  70979. getColorGradients(): Nullable<Array<ColorGradient>>;
  70980. /**
  70981. * Gets the current list of size gradients.
  70982. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70983. * @returns the list of size gradients
  70984. */
  70985. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70986. /**
  70987. * Gets the current list of color remap gradients.
  70988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70989. * @returns the list of color remap gradients
  70990. */
  70991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70992. /**
  70993. * Gets the current list of alpha remap gradients.
  70994. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70995. * @returns the list of alpha remap gradients
  70996. */
  70997. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70998. /**
  70999. * Gets the current list of life time gradients.
  71000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71001. * @returns the list of life time gradients
  71002. */
  71003. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71004. /**
  71005. * Gets the current list of angular speed gradients.
  71006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71007. * @returns the list of angular speed gradients
  71008. */
  71009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71010. /**
  71011. * Gets the current list of velocity gradients.
  71012. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71013. * @returns the list of velocity gradients
  71014. */
  71015. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71016. /**
  71017. * Gets the current list of start size gradients.
  71018. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71019. * @returns the list of start size gradients
  71020. */
  71021. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71022. /**
  71023. * Gets the current list of emit rate gradients.
  71024. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71025. * @returns the list of emit rate gradients
  71026. */
  71027. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71028. /**
  71029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71031. */
  71032. direction1: Vector3;
  71033. /**
  71034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71036. */
  71037. direction2: Vector3;
  71038. /**
  71039. * 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.
  71040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71041. */
  71042. minEmitBox: Vector3;
  71043. /**
  71044. * 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.
  71045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71046. */
  71047. maxEmitBox: Vector3;
  71048. /**
  71049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71050. */
  71051. color1: Color4;
  71052. /**
  71053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71054. */
  71055. color2: Color4;
  71056. /**
  71057. * Color the particle will have at the end of its lifetime
  71058. */
  71059. colorDead: Color4;
  71060. /**
  71061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71062. */
  71063. textureMask: Color4;
  71064. /**
  71065. * The particle emitter type defines the emitter used by the particle system.
  71066. * It can be for example box, sphere, or cone...
  71067. */
  71068. particleEmitterType: IParticleEmitterType;
  71069. /** @hidden */
  71070. _isSubEmitter: boolean;
  71071. /**
  71072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71074. */
  71075. billboardMode: number;
  71076. protected _isBillboardBased: boolean;
  71077. /**
  71078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71079. */
  71080. isBillboardBased: boolean;
  71081. /**
  71082. * The scene the particle system belongs to.
  71083. */
  71084. protected _scene: Scene;
  71085. /**
  71086. * Local cache of defines for image processing.
  71087. */
  71088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71089. /**
  71090. * Default configuration related to image processing available in the standard Material.
  71091. */
  71092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71093. /**
  71094. * Gets the image processing configuration used either in this material.
  71095. */
  71096. /**
  71097. * Sets the Default image processing configuration used either in the this material.
  71098. *
  71099. * If sets to null, the scene one is in use.
  71100. */
  71101. imageProcessingConfiguration: ImageProcessingConfiguration;
  71102. /**
  71103. * Attaches a new image processing configuration to the Standard Material.
  71104. * @param configuration
  71105. */
  71106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71107. /** @hidden */
  71108. protected _reset(): void;
  71109. /** @hidden */
  71110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71111. /**
  71112. * Instantiates a particle system.
  71113. * 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.
  71114. * @param name The name of the particle system
  71115. */
  71116. constructor(name: string);
  71117. /**
  71118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71121. * @returns the emitter
  71122. */
  71123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71124. /**
  71125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71126. * @param radius The radius of the hemisphere to emit from
  71127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71128. * @returns the emitter
  71129. */
  71130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71131. /**
  71132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71133. * @param radius The radius of the sphere to emit from
  71134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71135. * @returns the emitter
  71136. */
  71137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71138. /**
  71139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71140. * @param radius The radius of the sphere to emit from
  71141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71143. * @returns the emitter
  71144. */
  71145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71146. /**
  71147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71148. * @param radius The radius of the emission cylinder
  71149. * @param height The height of the emission cylinder
  71150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71152. * @returns the emitter
  71153. */
  71154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71155. /**
  71156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71157. * @param radius The radius of the cylinder to emit from
  71158. * @param height The height of the emission cylinder
  71159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71162. * @returns the emitter
  71163. */
  71164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71165. /**
  71166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71167. * @param radius The radius of the cone to emit from
  71168. * @param angle The base angle of the cone
  71169. * @returns the emitter
  71170. */
  71171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71172. /**
  71173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71178. * @returns the emitter
  71179. */
  71180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71181. }
  71182. }
  71183. declare module BABYLON {
  71184. /**
  71185. * Type of sub emitter
  71186. */
  71187. export enum SubEmitterType {
  71188. /**
  71189. * Attached to the particle over it's lifetime
  71190. */
  71191. ATTACHED = 0,
  71192. /**
  71193. * Created when the particle dies
  71194. */
  71195. END = 1
  71196. }
  71197. /**
  71198. * Sub emitter class used to emit particles from an existing particle
  71199. */
  71200. export class SubEmitter {
  71201. /**
  71202. * the particle system to be used by the sub emitter
  71203. */
  71204. particleSystem: ParticleSystem;
  71205. /**
  71206. * Type of the submitter (Default: END)
  71207. */
  71208. type: SubEmitterType;
  71209. /**
  71210. * 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)
  71211. * Note: This only is supported when using an emitter of type Mesh
  71212. */
  71213. inheritDirection: boolean;
  71214. /**
  71215. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71216. */
  71217. inheritedVelocityAmount: number;
  71218. /**
  71219. * Creates a sub emitter
  71220. * @param particleSystem the particle system to be used by the sub emitter
  71221. */
  71222. constructor(
  71223. /**
  71224. * the particle system to be used by the sub emitter
  71225. */
  71226. particleSystem: ParticleSystem);
  71227. /**
  71228. * Clones the sub emitter
  71229. * @returns the cloned sub emitter
  71230. */
  71231. clone(): SubEmitter;
  71232. /**
  71233. * Serialize current object to a JSON object
  71234. * @returns the serialized object
  71235. */
  71236. serialize(): any;
  71237. /** @hidden */
  71238. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71239. /**
  71240. * Creates a new SubEmitter from a serialized JSON version
  71241. * @param serializationObject defines the JSON object to read from
  71242. * @param scene defines the hosting scene
  71243. * @param rootUrl defines the rootUrl for data loading
  71244. * @returns a new SubEmitter
  71245. */
  71246. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71247. /** Release associated resources */
  71248. dispose(): void;
  71249. }
  71250. }
  71251. declare module BABYLON {
  71252. /** @hidden */
  71253. export var clipPlaneFragmentDeclaration: {
  71254. name: string;
  71255. shader: string;
  71256. };
  71257. }
  71258. declare module BABYLON {
  71259. /** @hidden */
  71260. export var imageProcessingDeclaration: {
  71261. name: string;
  71262. shader: string;
  71263. };
  71264. }
  71265. declare module BABYLON {
  71266. /** @hidden */
  71267. export var imageProcessingFunctions: {
  71268. name: string;
  71269. shader: string;
  71270. };
  71271. }
  71272. declare module BABYLON {
  71273. /** @hidden */
  71274. export var clipPlaneFragment: {
  71275. name: string;
  71276. shader: string;
  71277. };
  71278. }
  71279. declare module BABYLON {
  71280. /** @hidden */
  71281. export var particlesPixelShader: {
  71282. name: string;
  71283. shader: string;
  71284. };
  71285. }
  71286. declare module BABYLON {
  71287. /** @hidden */
  71288. export var clipPlaneVertexDeclaration: {
  71289. name: string;
  71290. shader: string;
  71291. };
  71292. }
  71293. declare module BABYLON {
  71294. /** @hidden */
  71295. export var clipPlaneVertex: {
  71296. name: string;
  71297. shader: string;
  71298. };
  71299. }
  71300. declare module BABYLON {
  71301. /** @hidden */
  71302. export var particlesVertexShader: {
  71303. name: string;
  71304. shader: string;
  71305. };
  71306. }
  71307. declare module BABYLON {
  71308. /**
  71309. * This represents a particle system in Babylon.
  71310. * 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.
  71311. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71312. * @example https://doc.babylonjs.com/babylon101/particles
  71313. */
  71314. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71315. /**
  71316. * Billboard mode will only apply to Y axis
  71317. */
  71318. static readonly BILLBOARDMODE_Y: number;
  71319. /**
  71320. * Billboard mode will apply to all axes
  71321. */
  71322. static readonly BILLBOARDMODE_ALL: number;
  71323. /**
  71324. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71325. */
  71326. static readonly BILLBOARDMODE_STRETCHED: number;
  71327. /**
  71328. * This function can be defined to provide custom update for active particles.
  71329. * This function will be called instead of regular update (age, position, color, etc.).
  71330. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71331. */
  71332. updateFunction: (particles: Particle[]) => void;
  71333. private _emitterWorldMatrix;
  71334. /**
  71335. * This function can be defined to specify initial direction for every new particle.
  71336. * It by default use the emitterType defined function
  71337. */
  71338. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71339. /**
  71340. * This function can be defined to specify initial position for every new particle.
  71341. * It by default use the emitterType defined function
  71342. */
  71343. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71344. /**
  71345. * @hidden
  71346. */
  71347. _inheritedVelocityOffset: Vector3;
  71348. /**
  71349. * An event triggered when the system is disposed
  71350. */
  71351. onDisposeObservable: Observable<ParticleSystem>;
  71352. private _onDisposeObserver;
  71353. /**
  71354. * Sets a callback that will be triggered when the system is disposed
  71355. */
  71356. onDispose: () => void;
  71357. private _particles;
  71358. private _epsilon;
  71359. private _capacity;
  71360. private _stockParticles;
  71361. private _newPartsExcess;
  71362. private _vertexData;
  71363. private _vertexBuffer;
  71364. private _vertexBuffers;
  71365. private _spriteBuffer;
  71366. private _indexBuffer;
  71367. private _effect;
  71368. private _customEffect;
  71369. private _cachedDefines;
  71370. private _scaledColorStep;
  71371. private _colorDiff;
  71372. private _scaledDirection;
  71373. private _scaledGravity;
  71374. private _currentRenderId;
  71375. private _alive;
  71376. private _useInstancing;
  71377. private _started;
  71378. private _stopped;
  71379. private _actualFrame;
  71380. private _scaledUpdateSpeed;
  71381. private _vertexBufferSize;
  71382. /** @hidden */
  71383. _currentEmitRateGradient: Nullable<FactorGradient>;
  71384. /** @hidden */
  71385. _currentEmitRate1: number;
  71386. /** @hidden */
  71387. _currentEmitRate2: number;
  71388. /** @hidden */
  71389. _currentStartSizeGradient: Nullable<FactorGradient>;
  71390. /** @hidden */
  71391. _currentStartSize1: number;
  71392. /** @hidden */
  71393. _currentStartSize2: number;
  71394. private readonly _rawTextureWidth;
  71395. private _rampGradientsTexture;
  71396. private _useRampGradients;
  71397. /** Gets or sets a boolean indicating that ramp gradients must be used
  71398. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71399. */
  71400. useRampGradients: boolean;
  71401. /**
  71402. * 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.
  71403. * 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: [])
  71404. */
  71405. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71406. private _subEmitters;
  71407. /**
  71408. * @hidden
  71409. * If the particle systems emitter should be disposed when the particle system is disposed
  71410. */
  71411. _disposeEmitterOnDispose: boolean;
  71412. /**
  71413. * The current active Sub-systems, this property is used by the root particle system only.
  71414. */
  71415. activeSubSystems: Array<ParticleSystem>;
  71416. private _rootParticleSystem;
  71417. /**
  71418. * Gets the current list of active particles
  71419. */
  71420. readonly particles: Particle[];
  71421. /**
  71422. * Returns the string "ParticleSystem"
  71423. * @returns a string containing the class name
  71424. */
  71425. getClassName(): string;
  71426. /**
  71427. * Instantiates a particle system.
  71428. * 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.
  71429. * @param name The name of the particle system
  71430. * @param capacity The max number of particles alive at the same time
  71431. * @param scene The scene the particle system belongs to
  71432. * @param customEffect a custom effect used to change the way particles are rendered by default
  71433. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71434. * @param epsilon Offset used to render the particles
  71435. */
  71436. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71437. private _addFactorGradient;
  71438. private _removeFactorGradient;
  71439. /**
  71440. * Adds a new life time gradient
  71441. * @param gradient defines the gradient to use (between 0 and 1)
  71442. * @param factor defines the life time factor to affect to the specified gradient
  71443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71444. * @returns the current particle system
  71445. */
  71446. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71447. /**
  71448. * Remove a specific life time gradient
  71449. * @param gradient defines the gradient to remove
  71450. * @returns the current particle system
  71451. */
  71452. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71453. /**
  71454. * Adds a new size gradient
  71455. * @param gradient defines the gradient to use (between 0 and 1)
  71456. * @param factor defines the size factor to affect to the specified gradient
  71457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71458. * @returns the current particle system
  71459. */
  71460. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71461. /**
  71462. * Remove a specific size gradient
  71463. * @param gradient defines the gradient to remove
  71464. * @returns the current particle system
  71465. */
  71466. removeSizeGradient(gradient: number): IParticleSystem;
  71467. /**
  71468. * Adds a new color remap gradient
  71469. * @param gradient defines the gradient to use (between 0 and 1)
  71470. * @param min defines the color remap minimal range
  71471. * @param max defines the color remap maximal range
  71472. * @returns the current particle system
  71473. */
  71474. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71475. /**
  71476. * Remove a specific color remap gradient
  71477. * @param gradient defines the gradient to remove
  71478. * @returns the current particle system
  71479. */
  71480. removeColorRemapGradient(gradient: number): IParticleSystem;
  71481. /**
  71482. * Adds a new alpha remap gradient
  71483. * @param gradient defines the gradient to use (between 0 and 1)
  71484. * @param min defines the alpha remap minimal range
  71485. * @param max defines the alpha remap maximal range
  71486. * @returns the current particle system
  71487. */
  71488. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71489. /**
  71490. * Remove a specific alpha remap gradient
  71491. * @param gradient defines the gradient to remove
  71492. * @returns the current particle system
  71493. */
  71494. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71495. /**
  71496. * Adds a new angular speed gradient
  71497. * @param gradient defines the gradient to use (between 0 and 1)
  71498. * @param factor defines the angular speed to affect to the specified gradient
  71499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71500. * @returns the current particle system
  71501. */
  71502. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71503. /**
  71504. * Remove a specific angular speed gradient
  71505. * @param gradient defines the gradient to remove
  71506. * @returns the current particle system
  71507. */
  71508. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71509. /**
  71510. * Adds a new velocity gradient
  71511. * @param gradient defines the gradient to use (between 0 and 1)
  71512. * @param factor defines the velocity to affect to the specified gradient
  71513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71514. * @returns the current particle system
  71515. */
  71516. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71517. /**
  71518. * Remove a specific velocity gradient
  71519. * @param gradient defines the gradient to remove
  71520. * @returns the current particle system
  71521. */
  71522. removeVelocityGradient(gradient: number): IParticleSystem;
  71523. /**
  71524. * Adds a new limit velocity gradient
  71525. * @param gradient defines the gradient to use (between 0 and 1)
  71526. * @param factor defines the limit velocity value to affect to the specified gradient
  71527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71528. * @returns the current particle system
  71529. */
  71530. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71531. /**
  71532. * Remove a specific limit velocity gradient
  71533. * @param gradient defines the gradient to remove
  71534. * @returns the current particle system
  71535. */
  71536. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71537. /**
  71538. * Adds a new drag gradient
  71539. * @param gradient defines the gradient to use (between 0 and 1)
  71540. * @param factor defines the drag value to affect to the specified gradient
  71541. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71542. * @returns the current particle system
  71543. */
  71544. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71545. /**
  71546. * Remove a specific drag gradient
  71547. * @param gradient defines the gradient to remove
  71548. * @returns the current particle system
  71549. */
  71550. removeDragGradient(gradient: number): IParticleSystem;
  71551. /**
  71552. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71553. * @param gradient defines the gradient to use (between 0 and 1)
  71554. * @param factor defines the emit rate value to affect to the specified gradient
  71555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71556. * @returns the current particle system
  71557. */
  71558. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71559. /**
  71560. * Remove a specific emit rate gradient
  71561. * @param gradient defines the gradient to remove
  71562. * @returns the current particle system
  71563. */
  71564. removeEmitRateGradient(gradient: number): IParticleSystem;
  71565. /**
  71566. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71567. * @param gradient defines the gradient to use (between 0 and 1)
  71568. * @param factor defines the start size value to affect to the specified gradient
  71569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71570. * @returns the current particle system
  71571. */
  71572. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71573. /**
  71574. * Remove a specific start size gradient
  71575. * @param gradient defines the gradient to remove
  71576. * @returns the current particle system
  71577. */
  71578. removeStartSizeGradient(gradient: number): IParticleSystem;
  71579. private _createRampGradientTexture;
  71580. /**
  71581. * Gets the current list of ramp gradients.
  71582. * You must use addRampGradient and removeRampGradient to udpate this list
  71583. * @returns the list of ramp gradients
  71584. */
  71585. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71586. /**
  71587. * Adds a new ramp gradient used to remap particle colors
  71588. * @param gradient defines the gradient to use (between 0 and 1)
  71589. * @param color defines the color to affect to the specified gradient
  71590. * @returns the current particle system
  71591. */
  71592. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71593. /**
  71594. * Remove a specific ramp gradient
  71595. * @param gradient defines the gradient to remove
  71596. * @returns the current particle system
  71597. */
  71598. removeRampGradient(gradient: number): ParticleSystem;
  71599. /**
  71600. * Adds a new color gradient
  71601. * @param gradient defines the gradient to use (between 0 and 1)
  71602. * @param color1 defines the color to affect to the specified gradient
  71603. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71604. * @returns this particle system
  71605. */
  71606. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71607. /**
  71608. * Remove a specific color gradient
  71609. * @param gradient defines the gradient to remove
  71610. * @returns this particle system
  71611. */
  71612. removeColorGradient(gradient: number): IParticleSystem;
  71613. private _fetchR;
  71614. protected _reset(): void;
  71615. private _resetEffect;
  71616. private _createVertexBuffers;
  71617. private _createIndexBuffer;
  71618. /**
  71619. * Gets the maximum number of particles active at the same time.
  71620. * @returns The max number of active particles.
  71621. */
  71622. getCapacity(): number;
  71623. /**
  71624. * Gets whether there are still active particles in the system.
  71625. * @returns True if it is alive, otherwise false.
  71626. */
  71627. isAlive(): boolean;
  71628. /**
  71629. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71630. * @returns True if it has been started, otherwise false.
  71631. */
  71632. isStarted(): boolean;
  71633. private _prepareSubEmitterInternalArray;
  71634. /**
  71635. * Starts the particle system and begins to emit
  71636. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71637. */
  71638. start(delay?: number): void;
  71639. /**
  71640. * Stops the particle system.
  71641. * @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.
  71642. */
  71643. stop(stopSubEmitters?: boolean): void;
  71644. /**
  71645. * Remove all active particles
  71646. */
  71647. reset(): void;
  71648. /**
  71649. * @hidden (for internal use only)
  71650. */
  71651. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71652. /**
  71653. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71654. * Its lifetime will start back at 0.
  71655. */
  71656. recycleParticle: (particle: Particle) => void;
  71657. private _stopSubEmitters;
  71658. private _createParticle;
  71659. private _removeFromRoot;
  71660. private _emitFromParticle;
  71661. private _update;
  71662. /** @hidden */
  71663. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71664. /** @hidden */
  71665. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71666. /** @hidden */
  71667. private _getEffect;
  71668. /**
  71669. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71670. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71671. */
  71672. animate(preWarmOnly?: boolean): void;
  71673. private _appendParticleVertices;
  71674. /**
  71675. * Rebuilds the particle system.
  71676. */
  71677. rebuild(): void;
  71678. /**
  71679. * Is this system ready to be used/rendered
  71680. * @return true if the system is ready
  71681. */
  71682. isReady(): boolean;
  71683. private _render;
  71684. /**
  71685. * Renders the particle system in its current state.
  71686. * @returns the current number of particles
  71687. */
  71688. render(): number;
  71689. /**
  71690. * Disposes the particle system and free the associated resources
  71691. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71692. */
  71693. dispose(disposeTexture?: boolean): void;
  71694. /**
  71695. * Clones the particle system.
  71696. * @param name The name of the cloned object
  71697. * @param newEmitter The new emitter to use
  71698. * @returns the cloned particle system
  71699. */
  71700. clone(name: string, newEmitter: any): ParticleSystem;
  71701. /**
  71702. * Serializes the particle system to a JSON object.
  71703. * @returns the JSON object
  71704. */
  71705. serialize(): any;
  71706. /** @hidden */
  71707. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71708. /** @hidden */
  71709. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71710. /**
  71711. * Parses a JSON object to create a particle system.
  71712. * @param parsedParticleSystem The JSON object to parse
  71713. * @param scene The scene to create the particle system in
  71714. * @param rootUrl The root url to use to load external dependencies like texture
  71715. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71716. * @returns the Parsed particle system
  71717. */
  71718. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71719. }
  71720. }
  71721. declare module BABYLON {
  71722. /**
  71723. * A particle represents one of the element emitted by a particle system.
  71724. * This is mainly define by its coordinates, direction, velocity and age.
  71725. */
  71726. export class Particle {
  71727. /**
  71728. * The particle system the particle belongs to.
  71729. */
  71730. particleSystem: ParticleSystem;
  71731. private static _Count;
  71732. /**
  71733. * Unique ID of the particle
  71734. */
  71735. id: number;
  71736. /**
  71737. * The world position of the particle in the scene.
  71738. */
  71739. position: Vector3;
  71740. /**
  71741. * The world direction of the particle in the scene.
  71742. */
  71743. direction: Vector3;
  71744. /**
  71745. * The color of the particle.
  71746. */
  71747. color: Color4;
  71748. /**
  71749. * The color change of the particle per step.
  71750. */
  71751. colorStep: Color4;
  71752. /**
  71753. * Defines how long will the life of the particle be.
  71754. */
  71755. lifeTime: number;
  71756. /**
  71757. * The current age of the particle.
  71758. */
  71759. age: number;
  71760. /**
  71761. * The current size of the particle.
  71762. */
  71763. size: number;
  71764. /**
  71765. * The current scale of the particle.
  71766. */
  71767. scale: Vector2;
  71768. /**
  71769. * The current angle of the particle.
  71770. */
  71771. angle: number;
  71772. /**
  71773. * Defines how fast is the angle changing.
  71774. */
  71775. angularSpeed: number;
  71776. /**
  71777. * Defines the cell index used by the particle to be rendered from a sprite.
  71778. */
  71779. cellIndex: number;
  71780. /**
  71781. * The information required to support color remapping
  71782. */
  71783. remapData: Vector4;
  71784. /** @hidden */
  71785. _randomCellOffset?: number;
  71786. /** @hidden */
  71787. _initialDirection: Nullable<Vector3>;
  71788. /** @hidden */
  71789. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71790. /** @hidden */
  71791. _initialStartSpriteCellID: number;
  71792. /** @hidden */
  71793. _initialEndSpriteCellID: number;
  71794. /** @hidden */
  71795. _currentColorGradient: Nullable<ColorGradient>;
  71796. /** @hidden */
  71797. _currentColor1: Color4;
  71798. /** @hidden */
  71799. _currentColor2: Color4;
  71800. /** @hidden */
  71801. _currentSizeGradient: Nullable<FactorGradient>;
  71802. /** @hidden */
  71803. _currentSize1: number;
  71804. /** @hidden */
  71805. _currentSize2: number;
  71806. /** @hidden */
  71807. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71808. /** @hidden */
  71809. _currentAngularSpeed1: number;
  71810. /** @hidden */
  71811. _currentAngularSpeed2: number;
  71812. /** @hidden */
  71813. _currentVelocityGradient: Nullable<FactorGradient>;
  71814. /** @hidden */
  71815. _currentVelocity1: number;
  71816. /** @hidden */
  71817. _currentVelocity2: number;
  71818. /** @hidden */
  71819. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71820. /** @hidden */
  71821. _currentLimitVelocity1: number;
  71822. /** @hidden */
  71823. _currentLimitVelocity2: number;
  71824. /** @hidden */
  71825. _currentDragGradient: Nullable<FactorGradient>;
  71826. /** @hidden */
  71827. _currentDrag1: number;
  71828. /** @hidden */
  71829. _currentDrag2: number;
  71830. /** @hidden */
  71831. _randomNoiseCoordinates1: Vector3;
  71832. /** @hidden */
  71833. _randomNoiseCoordinates2: Vector3;
  71834. /**
  71835. * Creates a new instance Particle
  71836. * @param particleSystem the particle system the particle belongs to
  71837. */
  71838. constructor(
  71839. /**
  71840. * The particle system the particle belongs to.
  71841. */
  71842. particleSystem: ParticleSystem);
  71843. private updateCellInfoFromSystem;
  71844. /**
  71845. * Defines how the sprite cell index is updated for the particle
  71846. */
  71847. updateCellIndex(): void;
  71848. /** @hidden */
  71849. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71850. /** @hidden */
  71851. _inheritParticleInfoToSubEmitters(): void;
  71852. /** @hidden */
  71853. _reset(): void;
  71854. /**
  71855. * Copy the properties of particle to another one.
  71856. * @param other the particle to copy the information to.
  71857. */
  71858. copyTo(other: Particle): void;
  71859. }
  71860. }
  71861. declare module BABYLON {
  71862. /**
  71863. * Particle emitter represents a volume emitting particles.
  71864. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71865. */
  71866. export interface IParticleEmitterType {
  71867. /**
  71868. * Called by the particle System when the direction is computed for the created particle.
  71869. * @param worldMatrix is the world matrix of the particle system
  71870. * @param directionToUpdate is the direction vector to update with the result
  71871. * @param particle is the particle we are computed the direction for
  71872. */
  71873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71874. /**
  71875. * Called by the particle System when the position is computed for the created particle.
  71876. * @param worldMatrix is the world matrix of the particle system
  71877. * @param positionToUpdate is the position vector to update with the result
  71878. * @param particle is the particle we are computed the position for
  71879. */
  71880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71881. /**
  71882. * Clones the current emitter and returns a copy of it
  71883. * @returns the new emitter
  71884. */
  71885. clone(): IParticleEmitterType;
  71886. /**
  71887. * Called by the GPUParticleSystem to setup the update shader
  71888. * @param effect defines the update shader
  71889. */
  71890. applyToShader(effect: Effect): void;
  71891. /**
  71892. * Returns a string to use to update the GPU particles update shader
  71893. * @returns the effect defines string
  71894. */
  71895. getEffectDefines(): string;
  71896. /**
  71897. * Returns a string representing the class name
  71898. * @returns a string containing the class name
  71899. */
  71900. getClassName(): string;
  71901. /**
  71902. * Serializes the particle system to a JSON object.
  71903. * @returns the JSON object
  71904. */
  71905. serialize(): any;
  71906. /**
  71907. * Parse properties from a JSON object
  71908. * @param serializationObject defines the JSON object
  71909. */
  71910. parse(serializationObject: any): void;
  71911. }
  71912. }
  71913. declare module BABYLON {
  71914. /**
  71915. * Particle emitter emitting particles from the inside of a box.
  71916. * It emits the particles randomly between 2 given directions.
  71917. */
  71918. export class BoxParticleEmitter implements IParticleEmitterType {
  71919. /**
  71920. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71921. */
  71922. direction1: Vector3;
  71923. /**
  71924. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71925. */
  71926. direction2: Vector3;
  71927. /**
  71928. * 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.
  71929. */
  71930. minEmitBox: Vector3;
  71931. /**
  71932. * 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.
  71933. */
  71934. maxEmitBox: Vector3;
  71935. /**
  71936. * Creates a new instance BoxParticleEmitter
  71937. */
  71938. constructor();
  71939. /**
  71940. * Called by the particle System when the direction is computed for the created particle.
  71941. * @param worldMatrix is the world matrix of the particle system
  71942. * @param directionToUpdate is the direction vector to update with the result
  71943. * @param particle is the particle we are computed the direction for
  71944. */
  71945. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71946. /**
  71947. * Called by the particle System when the position is computed for the created particle.
  71948. * @param worldMatrix is the world matrix of the particle system
  71949. * @param positionToUpdate is the position vector to update with the result
  71950. * @param particle is the particle we are computed the position for
  71951. */
  71952. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71953. /**
  71954. * Clones the current emitter and returns a copy of it
  71955. * @returns the new emitter
  71956. */
  71957. clone(): BoxParticleEmitter;
  71958. /**
  71959. * Called by the GPUParticleSystem to setup the update shader
  71960. * @param effect defines the update shader
  71961. */
  71962. applyToShader(effect: Effect): void;
  71963. /**
  71964. * Returns a string to use to update the GPU particles update shader
  71965. * @returns a string containng the defines string
  71966. */
  71967. getEffectDefines(): string;
  71968. /**
  71969. * Returns the string "BoxParticleEmitter"
  71970. * @returns a string containing the class name
  71971. */
  71972. getClassName(): string;
  71973. /**
  71974. * Serializes the particle system to a JSON object.
  71975. * @returns the JSON object
  71976. */
  71977. serialize(): any;
  71978. /**
  71979. * Parse properties from a JSON object
  71980. * @param serializationObject defines the JSON object
  71981. */
  71982. parse(serializationObject: any): void;
  71983. }
  71984. }
  71985. declare module BABYLON {
  71986. /**
  71987. * Particle emitter emitting particles from the inside of a cone.
  71988. * It emits the particles alongside the cone volume from the base to the particle.
  71989. * The emission direction might be randomized.
  71990. */
  71991. export class ConeParticleEmitter implements IParticleEmitterType {
  71992. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71993. directionRandomizer: number;
  71994. private _radius;
  71995. private _angle;
  71996. private _height;
  71997. /**
  71998. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71999. */
  72000. radiusRange: number;
  72001. /**
  72002. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72003. */
  72004. heightRange: number;
  72005. /**
  72006. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72007. */
  72008. emitFromSpawnPointOnly: boolean;
  72009. /**
  72010. * Gets or sets the radius of the emission cone
  72011. */
  72012. radius: number;
  72013. /**
  72014. * Gets or sets the angle of the emission cone
  72015. */
  72016. angle: number;
  72017. private _buildHeight;
  72018. /**
  72019. * Creates a new instance ConeParticleEmitter
  72020. * @param radius the radius of the emission cone (1 by default)
  72021. * @param angle the cone base angle (PI by default)
  72022. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72023. */
  72024. constructor(radius?: number, angle?: number,
  72025. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72026. directionRandomizer?: number);
  72027. /**
  72028. * Called by the particle System when the direction is computed for the created particle.
  72029. * @param worldMatrix is the world matrix of the particle system
  72030. * @param directionToUpdate is the direction vector to update with the result
  72031. * @param particle is the particle we are computed the direction for
  72032. */
  72033. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72034. /**
  72035. * Called by the particle System when the position is computed for the created particle.
  72036. * @param worldMatrix is the world matrix of the particle system
  72037. * @param positionToUpdate is the position vector to update with the result
  72038. * @param particle is the particle we are computed the position for
  72039. */
  72040. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72041. /**
  72042. * Clones the current emitter and returns a copy of it
  72043. * @returns the new emitter
  72044. */
  72045. clone(): ConeParticleEmitter;
  72046. /**
  72047. * Called by the GPUParticleSystem to setup the update shader
  72048. * @param effect defines the update shader
  72049. */
  72050. applyToShader(effect: Effect): void;
  72051. /**
  72052. * Returns a string to use to update the GPU particles update shader
  72053. * @returns a string containng the defines string
  72054. */
  72055. getEffectDefines(): string;
  72056. /**
  72057. * Returns the string "ConeParticleEmitter"
  72058. * @returns a string containing the class name
  72059. */
  72060. getClassName(): string;
  72061. /**
  72062. * Serializes the particle system to a JSON object.
  72063. * @returns the JSON object
  72064. */
  72065. serialize(): any;
  72066. /**
  72067. * Parse properties from a JSON object
  72068. * @param serializationObject defines the JSON object
  72069. */
  72070. parse(serializationObject: any): void;
  72071. }
  72072. }
  72073. declare module BABYLON {
  72074. /**
  72075. * Particle emitter emitting particles from the inside of a cylinder.
  72076. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72077. */
  72078. export class CylinderParticleEmitter implements IParticleEmitterType {
  72079. /**
  72080. * The radius of the emission cylinder.
  72081. */
  72082. radius: number;
  72083. /**
  72084. * The height of the emission cylinder.
  72085. */
  72086. height: number;
  72087. /**
  72088. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72089. */
  72090. radiusRange: number;
  72091. /**
  72092. * How much to randomize the particle direction [0-1].
  72093. */
  72094. directionRandomizer: number;
  72095. /**
  72096. * Creates a new instance CylinderParticleEmitter
  72097. * @param radius the radius of the emission cylinder (1 by default)
  72098. * @param height the height of the emission cylinder (1 by default)
  72099. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72100. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72101. */
  72102. constructor(
  72103. /**
  72104. * The radius of the emission cylinder.
  72105. */
  72106. radius?: number,
  72107. /**
  72108. * The height of the emission cylinder.
  72109. */
  72110. height?: number,
  72111. /**
  72112. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72113. */
  72114. radiusRange?: number,
  72115. /**
  72116. * How much to randomize the particle direction [0-1].
  72117. */
  72118. directionRandomizer?: number);
  72119. /**
  72120. * Called by the particle System when the direction is computed for the created particle.
  72121. * @param worldMatrix is the world matrix of the particle system
  72122. * @param directionToUpdate is the direction vector to update with the result
  72123. * @param particle is the particle we are computed the direction for
  72124. */
  72125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72126. /**
  72127. * Called by the particle System when the position is computed for the created particle.
  72128. * @param worldMatrix is the world matrix of the particle system
  72129. * @param positionToUpdate is the position vector to update with the result
  72130. * @param particle is the particle we are computed the position for
  72131. */
  72132. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72133. /**
  72134. * Clones the current emitter and returns a copy of it
  72135. * @returns the new emitter
  72136. */
  72137. clone(): CylinderParticleEmitter;
  72138. /**
  72139. * Called by the GPUParticleSystem to setup the update shader
  72140. * @param effect defines the update shader
  72141. */
  72142. applyToShader(effect: Effect): void;
  72143. /**
  72144. * Returns a string to use to update the GPU particles update shader
  72145. * @returns a string containng the defines string
  72146. */
  72147. getEffectDefines(): string;
  72148. /**
  72149. * Returns the string "CylinderParticleEmitter"
  72150. * @returns a string containing the class name
  72151. */
  72152. getClassName(): string;
  72153. /**
  72154. * Serializes the particle system to a JSON object.
  72155. * @returns the JSON object
  72156. */
  72157. serialize(): any;
  72158. /**
  72159. * Parse properties from a JSON object
  72160. * @param serializationObject defines the JSON object
  72161. */
  72162. parse(serializationObject: any): void;
  72163. }
  72164. /**
  72165. * Particle emitter emitting particles from the inside of a cylinder.
  72166. * It emits the particles randomly between two vectors.
  72167. */
  72168. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72169. /**
  72170. * The min limit of the emission direction.
  72171. */
  72172. direction1: Vector3;
  72173. /**
  72174. * The max limit of the emission direction.
  72175. */
  72176. direction2: Vector3;
  72177. /**
  72178. * Creates a new instance CylinderDirectedParticleEmitter
  72179. * @param radius the radius of the emission cylinder (1 by default)
  72180. * @param height the height of the emission cylinder (1 by default)
  72181. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72182. * @param direction1 the min limit of the emission direction (up vector by default)
  72183. * @param direction2 the max limit of the emission direction (up vector by default)
  72184. */
  72185. constructor(radius?: number, height?: number, radiusRange?: number,
  72186. /**
  72187. * The min limit of the emission direction.
  72188. */
  72189. direction1?: Vector3,
  72190. /**
  72191. * The max limit of the emission direction.
  72192. */
  72193. direction2?: Vector3);
  72194. /**
  72195. * Called by the particle System when the direction is computed for the created particle.
  72196. * @param worldMatrix is the world matrix of the particle system
  72197. * @param directionToUpdate is the direction vector to update with the result
  72198. * @param particle is the particle we are computed the direction for
  72199. */
  72200. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72201. /**
  72202. * Clones the current emitter and returns a copy of it
  72203. * @returns the new emitter
  72204. */
  72205. clone(): CylinderDirectedParticleEmitter;
  72206. /**
  72207. * Called by the GPUParticleSystem to setup the update shader
  72208. * @param effect defines the update shader
  72209. */
  72210. applyToShader(effect: Effect): void;
  72211. /**
  72212. * Returns a string to use to update the GPU particles update shader
  72213. * @returns a string containng the defines string
  72214. */
  72215. getEffectDefines(): string;
  72216. /**
  72217. * Returns the string "CylinderDirectedParticleEmitter"
  72218. * @returns a string containing the class name
  72219. */
  72220. getClassName(): string;
  72221. /**
  72222. * Serializes the particle system to a JSON object.
  72223. * @returns the JSON object
  72224. */
  72225. serialize(): any;
  72226. /**
  72227. * Parse properties from a JSON object
  72228. * @param serializationObject defines the JSON object
  72229. */
  72230. parse(serializationObject: any): void;
  72231. }
  72232. }
  72233. declare module BABYLON {
  72234. /**
  72235. * Particle emitter emitting particles from the inside of a hemisphere.
  72236. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72237. */
  72238. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72239. /**
  72240. * The radius of the emission hemisphere.
  72241. */
  72242. radius: number;
  72243. /**
  72244. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72245. */
  72246. radiusRange: number;
  72247. /**
  72248. * How much to randomize the particle direction [0-1].
  72249. */
  72250. directionRandomizer: number;
  72251. /**
  72252. * Creates a new instance HemisphericParticleEmitter
  72253. * @param radius the radius of the emission hemisphere (1 by default)
  72254. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72255. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72256. */
  72257. constructor(
  72258. /**
  72259. * The radius of the emission hemisphere.
  72260. */
  72261. radius?: number,
  72262. /**
  72263. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72264. */
  72265. radiusRange?: number,
  72266. /**
  72267. * How much to randomize the particle direction [0-1].
  72268. */
  72269. directionRandomizer?: number);
  72270. /**
  72271. * Called by the particle System when the direction is computed for the created particle.
  72272. * @param worldMatrix is the world matrix of the particle system
  72273. * @param directionToUpdate is the direction vector to update with the result
  72274. * @param particle is the particle we are computed the direction for
  72275. */
  72276. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72277. /**
  72278. * Called by the particle System when the position is computed for the created particle.
  72279. * @param worldMatrix is the world matrix of the particle system
  72280. * @param positionToUpdate is the position vector to update with the result
  72281. * @param particle is the particle we are computed the position for
  72282. */
  72283. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72284. /**
  72285. * Clones the current emitter and returns a copy of it
  72286. * @returns the new emitter
  72287. */
  72288. clone(): HemisphericParticleEmitter;
  72289. /**
  72290. * Called by the GPUParticleSystem to setup the update shader
  72291. * @param effect defines the update shader
  72292. */
  72293. applyToShader(effect: Effect): void;
  72294. /**
  72295. * Returns a string to use to update the GPU particles update shader
  72296. * @returns a string containng the defines string
  72297. */
  72298. getEffectDefines(): string;
  72299. /**
  72300. * Returns the string "HemisphericParticleEmitter"
  72301. * @returns a string containing the class name
  72302. */
  72303. getClassName(): string;
  72304. /**
  72305. * Serializes the particle system to a JSON object.
  72306. * @returns the JSON object
  72307. */
  72308. serialize(): any;
  72309. /**
  72310. * Parse properties from a JSON object
  72311. * @param serializationObject defines the JSON object
  72312. */
  72313. parse(serializationObject: any): void;
  72314. }
  72315. }
  72316. declare module BABYLON {
  72317. /**
  72318. * Particle emitter emitting particles from a point.
  72319. * It emits the particles randomly between 2 given directions.
  72320. */
  72321. export class PointParticleEmitter implements IParticleEmitterType {
  72322. /**
  72323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72324. */
  72325. direction1: Vector3;
  72326. /**
  72327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72328. */
  72329. direction2: Vector3;
  72330. /**
  72331. * Creates a new instance PointParticleEmitter
  72332. */
  72333. constructor();
  72334. /**
  72335. * Called by the particle System when the direction is computed for the created particle.
  72336. * @param worldMatrix is the world matrix of the particle system
  72337. * @param directionToUpdate is the direction vector to update with the result
  72338. * @param particle is the particle we are computed the direction for
  72339. */
  72340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72341. /**
  72342. * Called by the particle System when the position is computed for the created particle.
  72343. * @param worldMatrix is the world matrix of the particle system
  72344. * @param positionToUpdate is the position vector to update with the result
  72345. * @param particle is the particle we are computed the position for
  72346. */
  72347. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72348. /**
  72349. * Clones the current emitter and returns a copy of it
  72350. * @returns the new emitter
  72351. */
  72352. clone(): PointParticleEmitter;
  72353. /**
  72354. * Called by the GPUParticleSystem to setup the update shader
  72355. * @param effect defines the update shader
  72356. */
  72357. applyToShader(effect: Effect): void;
  72358. /**
  72359. * Returns a string to use to update the GPU particles update shader
  72360. * @returns a string containng the defines string
  72361. */
  72362. getEffectDefines(): string;
  72363. /**
  72364. * Returns the string "PointParticleEmitter"
  72365. * @returns a string containing the class name
  72366. */
  72367. getClassName(): string;
  72368. /**
  72369. * Serializes the particle system to a JSON object.
  72370. * @returns the JSON object
  72371. */
  72372. serialize(): any;
  72373. /**
  72374. * Parse properties from a JSON object
  72375. * @param serializationObject defines the JSON object
  72376. */
  72377. parse(serializationObject: any): void;
  72378. }
  72379. }
  72380. declare module BABYLON {
  72381. /**
  72382. * Particle emitter emitting particles from the inside of a sphere.
  72383. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72384. */
  72385. export class SphereParticleEmitter implements IParticleEmitterType {
  72386. /**
  72387. * The radius of the emission sphere.
  72388. */
  72389. radius: number;
  72390. /**
  72391. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72392. */
  72393. radiusRange: number;
  72394. /**
  72395. * How much to randomize the particle direction [0-1].
  72396. */
  72397. directionRandomizer: number;
  72398. /**
  72399. * Creates a new instance SphereParticleEmitter
  72400. * @param radius the radius of the emission sphere (1 by default)
  72401. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72402. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72403. */
  72404. constructor(
  72405. /**
  72406. * The radius of the emission sphere.
  72407. */
  72408. radius?: number,
  72409. /**
  72410. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72411. */
  72412. radiusRange?: number,
  72413. /**
  72414. * How much to randomize the particle direction [0-1].
  72415. */
  72416. directionRandomizer?: number);
  72417. /**
  72418. * Called by the particle System when the direction is computed for the created particle.
  72419. * @param worldMatrix is the world matrix of the particle system
  72420. * @param directionToUpdate is the direction vector to update with the result
  72421. * @param particle is the particle we are computed the direction for
  72422. */
  72423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72424. /**
  72425. * Called by the particle System when the position is computed for the created particle.
  72426. * @param worldMatrix is the world matrix of the particle system
  72427. * @param positionToUpdate is the position vector to update with the result
  72428. * @param particle is the particle we are computed the position for
  72429. */
  72430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72431. /**
  72432. * Clones the current emitter and returns a copy of it
  72433. * @returns the new emitter
  72434. */
  72435. clone(): SphereParticleEmitter;
  72436. /**
  72437. * Called by the GPUParticleSystem to setup the update shader
  72438. * @param effect defines the update shader
  72439. */
  72440. applyToShader(effect: Effect): void;
  72441. /**
  72442. * Returns a string to use to update the GPU particles update shader
  72443. * @returns a string containng the defines string
  72444. */
  72445. getEffectDefines(): string;
  72446. /**
  72447. * Returns the string "SphereParticleEmitter"
  72448. * @returns a string containing the class name
  72449. */
  72450. getClassName(): string;
  72451. /**
  72452. * Serializes the particle system to a JSON object.
  72453. * @returns the JSON object
  72454. */
  72455. serialize(): any;
  72456. /**
  72457. * Parse properties from a JSON object
  72458. * @param serializationObject defines the JSON object
  72459. */
  72460. parse(serializationObject: any): void;
  72461. }
  72462. /**
  72463. * Particle emitter emitting particles from the inside of a sphere.
  72464. * It emits the particles randomly between two vectors.
  72465. */
  72466. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72467. /**
  72468. * The min limit of the emission direction.
  72469. */
  72470. direction1: Vector3;
  72471. /**
  72472. * The max limit of the emission direction.
  72473. */
  72474. direction2: Vector3;
  72475. /**
  72476. * Creates a new instance SphereDirectedParticleEmitter
  72477. * @param radius the radius of the emission sphere (1 by default)
  72478. * @param direction1 the min limit of the emission direction (up vector by default)
  72479. * @param direction2 the max limit of the emission direction (up vector by default)
  72480. */
  72481. constructor(radius?: number,
  72482. /**
  72483. * The min limit of the emission direction.
  72484. */
  72485. direction1?: Vector3,
  72486. /**
  72487. * The max limit of the emission direction.
  72488. */
  72489. direction2?: Vector3);
  72490. /**
  72491. * Called by the particle System when the direction is computed for the created particle.
  72492. * @param worldMatrix is the world matrix of the particle system
  72493. * @param directionToUpdate is the direction vector to update with the result
  72494. * @param particle is the particle we are computed the direction for
  72495. */
  72496. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72497. /**
  72498. * Clones the current emitter and returns a copy of it
  72499. * @returns the new emitter
  72500. */
  72501. clone(): SphereDirectedParticleEmitter;
  72502. /**
  72503. * Called by the GPUParticleSystem to setup the update shader
  72504. * @param effect defines the update shader
  72505. */
  72506. applyToShader(effect: Effect): void;
  72507. /**
  72508. * Returns a string to use to update the GPU particles update shader
  72509. * @returns a string containng the defines string
  72510. */
  72511. getEffectDefines(): string;
  72512. /**
  72513. * Returns the string "SphereDirectedParticleEmitter"
  72514. * @returns a string containing the class name
  72515. */
  72516. getClassName(): string;
  72517. /**
  72518. * Serializes the particle system to a JSON object.
  72519. * @returns the JSON object
  72520. */
  72521. serialize(): any;
  72522. /**
  72523. * Parse properties from a JSON object
  72524. * @param serializationObject defines the JSON object
  72525. */
  72526. parse(serializationObject: any): void;
  72527. }
  72528. }
  72529. declare module BABYLON {
  72530. /**
  72531. * Interface representing a particle system in Babylon.js.
  72532. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72533. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72534. */
  72535. export interface IParticleSystem {
  72536. /**
  72537. * List of animations used by the particle system.
  72538. */
  72539. animations: Animation[];
  72540. /**
  72541. * The id of the Particle system.
  72542. */
  72543. id: string;
  72544. /**
  72545. * The name of the Particle system.
  72546. */
  72547. name: string;
  72548. /**
  72549. * The emitter represents the Mesh or position we are attaching the particle system to.
  72550. */
  72551. emitter: Nullable<AbstractMesh | Vector3>;
  72552. /**
  72553. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72554. */
  72555. isBillboardBased: boolean;
  72556. /**
  72557. * The rendering group used by the Particle system to chose when to render.
  72558. */
  72559. renderingGroupId: number;
  72560. /**
  72561. * The layer mask we are rendering the particles through.
  72562. */
  72563. layerMask: number;
  72564. /**
  72565. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72566. */
  72567. updateSpeed: number;
  72568. /**
  72569. * The amount of time the particle system is running (depends of the overall update speed).
  72570. */
  72571. targetStopDuration: number;
  72572. /**
  72573. * The texture used to render each particle. (this can be a spritesheet)
  72574. */
  72575. particleTexture: Nullable<Texture>;
  72576. /**
  72577. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72578. */
  72579. blendMode: number;
  72580. /**
  72581. * Minimum life time of emitting particles.
  72582. */
  72583. minLifeTime: number;
  72584. /**
  72585. * Maximum life time of emitting particles.
  72586. */
  72587. maxLifeTime: number;
  72588. /**
  72589. * Minimum Size of emitting particles.
  72590. */
  72591. minSize: number;
  72592. /**
  72593. * Maximum Size of emitting particles.
  72594. */
  72595. maxSize: number;
  72596. /**
  72597. * Minimum scale of emitting particles on X axis.
  72598. */
  72599. minScaleX: number;
  72600. /**
  72601. * Maximum scale of emitting particles on X axis.
  72602. */
  72603. maxScaleX: number;
  72604. /**
  72605. * Minimum scale of emitting particles on Y axis.
  72606. */
  72607. minScaleY: number;
  72608. /**
  72609. * Maximum scale of emitting particles on Y axis.
  72610. */
  72611. maxScaleY: number;
  72612. /**
  72613. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72614. */
  72615. color1: Color4;
  72616. /**
  72617. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72618. */
  72619. color2: Color4;
  72620. /**
  72621. * Color the particle will have at the end of its lifetime.
  72622. */
  72623. colorDead: Color4;
  72624. /**
  72625. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72626. */
  72627. emitRate: number;
  72628. /**
  72629. * You can use gravity if you want to give an orientation to your particles.
  72630. */
  72631. gravity: Vector3;
  72632. /**
  72633. * Minimum power of emitting particles.
  72634. */
  72635. minEmitPower: number;
  72636. /**
  72637. * Maximum power of emitting particles.
  72638. */
  72639. maxEmitPower: number;
  72640. /**
  72641. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72642. */
  72643. minAngularSpeed: number;
  72644. /**
  72645. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72646. */
  72647. maxAngularSpeed: number;
  72648. /**
  72649. * Gets or sets the minimal initial rotation in radians.
  72650. */
  72651. minInitialRotation: number;
  72652. /**
  72653. * Gets or sets the maximal initial rotation in radians.
  72654. */
  72655. maxInitialRotation: number;
  72656. /**
  72657. * The particle emitter type defines the emitter used by the particle system.
  72658. * It can be for example box, sphere, or cone...
  72659. */
  72660. particleEmitterType: Nullable<IParticleEmitterType>;
  72661. /**
  72662. * Defines the delay in milliseconds before starting the system (0 by default)
  72663. */
  72664. startDelay: number;
  72665. /**
  72666. * 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
  72667. */
  72668. preWarmCycles: number;
  72669. /**
  72670. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72671. */
  72672. preWarmStepOffset: number;
  72673. /**
  72674. * 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)
  72675. */
  72676. spriteCellChangeSpeed: number;
  72677. /**
  72678. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72679. */
  72680. startSpriteCellID: number;
  72681. /**
  72682. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72683. */
  72684. endSpriteCellID: number;
  72685. /**
  72686. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72687. */
  72688. spriteCellWidth: number;
  72689. /**
  72690. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72691. */
  72692. spriteCellHeight: number;
  72693. /**
  72694. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72695. */
  72696. spriteRandomStartCell: boolean;
  72697. /**
  72698. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72699. */
  72700. isAnimationSheetEnabled: boolean;
  72701. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72702. translationPivot: Vector2;
  72703. /**
  72704. * Gets or sets a texture used to add random noise to particle positions
  72705. */
  72706. noiseTexture: Nullable<BaseTexture>;
  72707. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72708. noiseStrength: Vector3;
  72709. /**
  72710. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72711. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72712. */
  72713. billboardMode: number;
  72714. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72715. limitVelocityDamping: number;
  72716. /**
  72717. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72718. */
  72719. beginAnimationOnStart: boolean;
  72720. /**
  72721. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72722. */
  72723. beginAnimationFrom: number;
  72724. /**
  72725. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72726. */
  72727. beginAnimationTo: number;
  72728. /**
  72729. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72730. */
  72731. beginAnimationLoop: boolean;
  72732. /**
  72733. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72734. */
  72735. disposeOnStop: boolean;
  72736. /**
  72737. * Gets the maximum number of particles active at the same time.
  72738. * @returns The max number of active particles.
  72739. */
  72740. getCapacity(): number;
  72741. /**
  72742. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72743. * @returns True if it has been started, otherwise false.
  72744. */
  72745. isStarted(): boolean;
  72746. /**
  72747. * Animates the particle system for this frame.
  72748. */
  72749. animate(): void;
  72750. /**
  72751. * Renders the particle system in its current state.
  72752. * @returns the current number of particles
  72753. */
  72754. render(): number;
  72755. /**
  72756. * Dispose the particle system and frees its associated resources.
  72757. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72758. */
  72759. dispose(disposeTexture?: boolean): void;
  72760. /**
  72761. * Clones the particle system.
  72762. * @param name The name of the cloned object
  72763. * @param newEmitter The new emitter to use
  72764. * @returns the cloned particle system
  72765. */
  72766. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72767. /**
  72768. * Serializes the particle system to a JSON object.
  72769. * @returns the JSON object
  72770. */
  72771. serialize(): any;
  72772. /**
  72773. * Rebuild the particle system
  72774. */
  72775. rebuild(): void;
  72776. /**
  72777. * Starts the particle system and begins to emit
  72778. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72779. */
  72780. start(delay?: number): void;
  72781. /**
  72782. * Stops the particle system.
  72783. */
  72784. stop(): void;
  72785. /**
  72786. * Remove all active particles
  72787. */
  72788. reset(): void;
  72789. /**
  72790. * Is this system ready to be used/rendered
  72791. * @return true if the system is ready
  72792. */
  72793. isReady(): boolean;
  72794. /**
  72795. * Adds a new color gradient
  72796. * @param gradient defines the gradient to use (between 0 and 1)
  72797. * @param color1 defines the color to affect to the specified gradient
  72798. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72799. * @returns the current particle system
  72800. */
  72801. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72802. /**
  72803. * Remove a specific color gradient
  72804. * @param gradient defines the gradient to remove
  72805. * @returns the current particle system
  72806. */
  72807. removeColorGradient(gradient: number): IParticleSystem;
  72808. /**
  72809. * Adds a new size gradient
  72810. * @param gradient defines the gradient to use (between 0 and 1)
  72811. * @param factor defines the size factor to affect to the specified gradient
  72812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72813. * @returns the current particle system
  72814. */
  72815. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72816. /**
  72817. * Remove a specific size gradient
  72818. * @param gradient defines the gradient to remove
  72819. * @returns the current particle system
  72820. */
  72821. removeSizeGradient(gradient: number): IParticleSystem;
  72822. /**
  72823. * Gets the current list of color gradients.
  72824. * You must use addColorGradient and removeColorGradient to udpate this list
  72825. * @returns the list of color gradients
  72826. */
  72827. getColorGradients(): Nullable<Array<ColorGradient>>;
  72828. /**
  72829. * Gets the current list of size gradients.
  72830. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72831. * @returns the list of size gradients
  72832. */
  72833. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72834. /**
  72835. * Gets the current list of angular speed gradients.
  72836. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72837. * @returns the list of angular speed gradients
  72838. */
  72839. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72840. /**
  72841. * Adds a new angular speed gradient
  72842. * @param gradient defines the gradient to use (between 0 and 1)
  72843. * @param factor defines the angular speed to affect to the specified gradient
  72844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72845. * @returns the current particle system
  72846. */
  72847. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72848. /**
  72849. * Remove a specific angular speed gradient
  72850. * @param gradient defines the gradient to remove
  72851. * @returns the current particle system
  72852. */
  72853. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72854. /**
  72855. * Gets the current list of velocity gradients.
  72856. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72857. * @returns the list of velocity gradients
  72858. */
  72859. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72860. /**
  72861. * Adds a new velocity gradient
  72862. * @param gradient defines the gradient to use (between 0 and 1)
  72863. * @param factor defines the velocity to affect to the specified gradient
  72864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72865. * @returns the current particle system
  72866. */
  72867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72868. /**
  72869. * Remove a specific velocity gradient
  72870. * @param gradient defines the gradient to remove
  72871. * @returns the current particle system
  72872. */
  72873. removeVelocityGradient(gradient: number): IParticleSystem;
  72874. /**
  72875. * Gets the current list of limit velocity gradients.
  72876. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72877. * @returns the list of limit velocity gradients
  72878. */
  72879. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72880. /**
  72881. * Adds a new limit velocity gradient
  72882. * @param gradient defines the gradient to use (between 0 and 1)
  72883. * @param factor defines the limit velocity to affect to the specified gradient
  72884. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72885. * @returns the current particle system
  72886. */
  72887. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72888. /**
  72889. * Remove a specific limit velocity gradient
  72890. * @param gradient defines the gradient to remove
  72891. * @returns the current particle system
  72892. */
  72893. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72894. /**
  72895. * Adds a new drag gradient
  72896. * @param gradient defines the gradient to use (between 0 and 1)
  72897. * @param factor defines the drag to affect to the specified gradient
  72898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72899. * @returns the current particle system
  72900. */
  72901. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72902. /**
  72903. * Remove a specific drag gradient
  72904. * @param gradient defines the gradient to remove
  72905. * @returns the current particle system
  72906. */
  72907. removeDragGradient(gradient: number): IParticleSystem;
  72908. /**
  72909. * Gets the current list of drag gradients.
  72910. * You must use addDragGradient and removeDragGradient to udpate this list
  72911. * @returns the list of drag gradients
  72912. */
  72913. getDragGradients(): Nullable<Array<FactorGradient>>;
  72914. /**
  72915. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72916. * @param gradient defines the gradient to use (between 0 and 1)
  72917. * @param factor defines the emit rate to affect to the specified gradient
  72918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72919. * @returns the current particle system
  72920. */
  72921. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72922. /**
  72923. * Remove a specific emit rate gradient
  72924. * @param gradient defines the gradient to remove
  72925. * @returns the current particle system
  72926. */
  72927. removeEmitRateGradient(gradient: number): IParticleSystem;
  72928. /**
  72929. * Gets the current list of emit rate gradients.
  72930. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72931. * @returns the list of emit rate gradients
  72932. */
  72933. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72934. /**
  72935. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72936. * @param gradient defines the gradient to use (between 0 and 1)
  72937. * @param factor defines the start size to affect to the specified gradient
  72938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72939. * @returns the current particle system
  72940. */
  72941. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72942. /**
  72943. * Remove a specific start size gradient
  72944. * @param gradient defines the gradient to remove
  72945. * @returns the current particle system
  72946. */
  72947. removeStartSizeGradient(gradient: number): IParticleSystem;
  72948. /**
  72949. * Gets the current list of start size gradients.
  72950. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72951. * @returns the list of start size gradients
  72952. */
  72953. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72954. /**
  72955. * Adds a new life time gradient
  72956. * @param gradient defines the gradient to use (between 0 and 1)
  72957. * @param factor defines the life time factor to affect to the specified gradient
  72958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72959. * @returns the current particle system
  72960. */
  72961. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72962. /**
  72963. * Remove a specific life time gradient
  72964. * @param gradient defines the gradient to remove
  72965. * @returns the current particle system
  72966. */
  72967. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72968. /**
  72969. * Gets the current list of life time gradients.
  72970. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72971. * @returns the list of life time gradients
  72972. */
  72973. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72974. /**
  72975. * Gets the current list of color gradients.
  72976. * You must use addColorGradient and removeColorGradient to udpate this list
  72977. * @returns the list of color gradients
  72978. */
  72979. getColorGradients(): Nullable<Array<ColorGradient>>;
  72980. /**
  72981. * Adds a new ramp gradient used to remap particle colors
  72982. * @param gradient defines the gradient to use (between 0 and 1)
  72983. * @param color defines the color to affect to the specified gradient
  72984. * @returns the current particle system
  72985. */
  72986. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72987. /**
  72988. * Gets the current list of ramp gradients.
  72989. * You must use addRampGradient and removeRampGradient to udpate this list
  72990. * @returns the list of ramp gradients
  72991. */
  72992. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72993. /** Gets or sets a boolean indicating that ramp gradients must be used
  72994. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72995. */
  72996. useRampGradients: boolean;
  72997. /**
  72998. * Adds a new color remap gradient
  72999. * @param gradient defines the gradient to use (between 0 and 1)
  73000. * @param min defines the color remap minimal range
  73001. * @param max defines the color remap maximal range
  73002. * @returns the current particle system
  73003. */
  73004. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73005. /**
  73006. * Gets the current list of color remap gradients.
  73007. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73008. * @returns the list of color remap gradients
  73009. */
  73010. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73011. /**
  73012. * Adds a new alpha remap gradient
  73013. * @param gradient defines the gradient to use (between 0 and 1)
  73014. * @param min defines the alpha remap minimal range
  73015. * @param max defines the alpha remap maximal range
  73016. * @returns the current particle system
  73017. */
  73018. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73019. /**
  73020. * Gets the current list of alpha remap gradients.
  73021. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73022. * @returns the list of alpha remap gradients
  73023. */
  73024. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73025. /**
  73026. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73027. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73028. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73029. * @returns the emitter
  73030. */
  73031. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73032. /**
  73033. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73034. * @param radius The radius of the hemisphere to emit from
  73035. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73036. * @returns the emitter
  73037. */
  73038. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73039. /**
  73040. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73041. * @param radius The radius of the sphere to emit from
  73042. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73043. * @returns the emitter
  73044. */
  73045. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73046. /**
  73047. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73048. * @param radius The radius of the sphere to emit from
  73049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73051. * @returns the emitter
  73052. */
  73053. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73054. /**
  73055. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73056. * @param radius The radius of the emission cylinder
  73057. * @param height The height of the emission cylinder
  73058. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73059. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73060. * @returns the emitter
  73061. */
  73062. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73063. /**
  73064. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73065. * @param radius The radius of the cylinder to emit from
  73066. * @param height The height of the emission cylinder
  73067. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73068. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73069. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73070. * @returns the emitter
  73071. */
  73072. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73073. /**
  73074. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73075. * @param radius The radius of the cone to emit from
  73076. * @param angle The base angle of the cone
  73077. * @returns the emitter
  73078. */
  73079. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73080. /**
  73081. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73084. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73085. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73086. * @returns the emitter
  73087. */
  73088. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73089. /**
  73090. * Get hosting scene
  73091. * @returns the scene
  73092. */
  73093. getScene(): Scene;
  73094. }
  73095. }
  73096. declare module BABYLON {
  73097. /** @hidden */
  73098. export var linePixelShader: {
  73099. name: string;
  73100. shader: string;
  73101. };
  73102. }
  73103. declare module BABYLON {
  73104. /** @hidden */
  73105. export var lineVertexShader: {
  73106. name: string;
  73107. shader: string;
  73108. };
  73109. }
  73110. declare module BABYLON {
  73111. interface AbstractMesh {
  73112. /**
  73113. * Disables the mesh edge rendering mode
  73114. * @returns the currentAbstractMesh
  73115. */
  73116. disableEdgesRendering(): AbstractMesh;
  73117. /**
  73118. * Enables the edge rendering mode on the mesh.
  73119. * This mode makes the mesh edges visible
  73120. * @param epsilon defines the maximal distance between two angles to detect a face
  73121. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73122. * @returns the currentAbstractMesh
  73123. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73124. */
  73125. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73126. /**
  73127. * Gets the edgesRenderer associated with the mesh
  73128. */
  73129. edgesRenderer: Nullable<EdgesRenderer>;
  73130. }
  73131. interface LinesMesh {
  73132. /**
  73133. * Enables the edge rendering mode on the mesh.
  73134. * This mode makes the mesh edges visible
  73135. * @param epsilon defines the maximal distance between two angles to detect a face
  73136. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73137. * @returns the currentAbstractMesh
  73138. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73139. */
  73140. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73141. }
  73142. interface InstancedLinesMesh {
  73143. /**
  73144. * Enables the edge rendering mode on the mesh.
  73145. * This mode makes the mesh edges visible
  73146. * @param epsilon defines the maximal distance between two angles to detect a face
  73147. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73148. * @returns the current InstancedLinesMesh
  73149. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73150. */
  73151. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  73152. }
  73153. /**
  73154. * Defines the minimum contract an Edges renderer should follow.
  73155. */
  73156. export interface IEdgesRenderer extends IDisposable {
  73157. /**
  73158. * Gets or sets a boolean indicating if the edgesRenderer is active
  73159. */
  73160. isEnabled: boolean;
  73161. /**
  73162. * Renders the edges of the attached mesh,
  73163. */
  73164. render(): void;
  73165. /**
  73166. * Checks wether or not the edges renderer is ready to render.
  73167. * @return true if ready, otherwise false.
  73168. */
  73169. isReady(): boolean;
  73170. }
  73171. /**
  73172. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73173. */
  73174. export class EdgesRenderer implements IEdgesRenderer {
  73175. /**
  73176. * Define the size of the edges with an orthographic camera
  73177. */
  73178. edgesWidthScalerForOrthographic: number;
  73179. /**
  73180. * Define the size of the edges with a perspective camera
  73181. */
  73182. edgesWidthScalerForPerspective: number;
  73183. protected _source: AbstractMesh;
  73184. protected _linesPositions: number[];
  73185. protected _linesNormals: number[];
  73186. protected _linesIndices: number[];
  73187. protected _epsilon: number;
  73188. protected _indicesCount: number;
  73189. protected _lineShader: ShaderMaterial;
  73190. protected _ib: WebGLBuffer;
  73191. protected _buffers: {
  73192. [key: string]: Nullable<VertexBuffer>;
  73193. };
  73194. protected _checkVerticesInsteadOfIndices: boolean;
  73195. private _meshRebuildObserver;
  73196. private _meshDisposeObserver;
  73197. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73198. isEnabled: boolean;
  73199. /**
  73200. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73201. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73202. * @param source Mesh used to create edges
  73203. * @param epsilon sum of angles in adjacency to check for edge
  73204. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73205. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73206. */
  73207. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73208. protected _prepareRessources(): void;
  73209. /** @hidden */
  73210. _rebuild(): void;
  73211. /**
  73212. * Releases the required resources for the edges renderer
  73213. */
  73214. dispose(): void;
  73215. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73216. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73217. /**
  73218. * Checks if the pair of p0 and p1 is en edge
  73219. * @param faceIndex
  73220. * @param edge
  73221. * @param faceNormals
  73222. * @param p0
  73223. * @param p1
  73224. * @private
  73225. */
  73226. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73227. /**
  73228. * push line into the position, normal and index buffer
  73229. * @protected
  73230. */
  73231. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73232. /**
  73233. * Generates lines edges from adjacencjes
  73234. * @private
  73235. */
  73236. _generateEdgesLines(): void;
  73237. /**
  73238. * Checks wether or not the edges renderer is ready to render.
  73239. * @return true if ready, otherwise false.
  73240. */
  73241. isReady(): boolean;
  73242. /**
  73243. * Renders the edges of the attached mesh,
  73244. */
  73245. render(): void;
  73246. }
  73247. /**
  73248. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73249. */
  73250. export class LineEdgesRenderer extends EdgesRenderer {
  73251. /**
  73252. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73253. * @param source LineMesh used to generate edges
  73254. * @param epsilon not important (specified angle for edge detection)
  73255. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73256. */
  73257. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73258. /**
  73259. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73260. */
  73261. _generateEdgesLines(): void;
  73262. }
  73263. }
  73264. declare module BABYLON {
  73265. /**
  73266. * This represents the object necessary to create a rendering group.
  73267. * This is exclusively used and created by the rendering manager.
  73268. * To modify the behavior, you use the available helpers in your scene or meshes.
  73269. * @hidden
  73270. */
  73271. export class RenderingGroup {
  73272. index: number;
  73273. private _scene;
  73274. private _opaqueSubMeshes;
  73275. private _transparentSubMeshes;
  73276. private _alphaTestSubMeshes;
  73277. private _depthOnlySubMeshes;
  73278. private _particleSystems;
  73279. private _spriteManagers;
  73280. private _opaqueSortCompareFn;
  73281. private _alphaTestSortCompareFn;
  73282. private _transparentSortCompareFn;
  73283. private _renderOpaque;
  73284. private _renderAlphaTest;
  73285. private _renderTransparent;
  73286. private _edgesRenderers;
  73287. onBeforeTransparentRendering: () => void;
  73288. /**
  73289. * Set the opaque sort comparison function.
  73290. * If null the sub meshes will be render in the order they were created
  73291. */
  73292. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73293. /**
  73294. * Set the alpha test sort comparison function.
  73295. * If null the sub meshes will be render in the order they were created
  73296. */
  73297. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73298. /**
  73299. * Set the transparent sort comparison function.
  73300. * If null the sub meshes will be render in the order they were created
  73301. */
  73302. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73303. /**
  73304. * Creates a new rendering group.
  73305. * @param index The rendering group index
  73306. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73307. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73308. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73309. */
  73310. 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>);
  73311. /**
  73312. * Render all the sub meshes contained in the group.
  73313. * @param customRenderFunction Used to override the default render behaviour of the group.
  73314. * @returns true if rendered some submeshes.
  73315. */
  73316. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73317. /**
  73318. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73319. * @param subMeshes The submeshes to render
  73320. */
  73321. private renderOpaqueSorted;
  73322. /**
  73323. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73324. * @param subMeshes The submeshes to render
  73325. */
  73326. private renderAlphaTestSorted;
  73327. /**
  73328. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73329. * @param subMeshes The submeshes to render
  73330. */
  73331. private renderTransparentSorted;
  73332. /**
  73333. * Renders the submeshes in a specified order.
  73334. * @param subMeshes The submeshes to sort before render
  73335. * @param sortCompareFn The comparison function use to sort
  73336. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73337. * @param transparent Specifies to activate blending if true
  73338. */
  73339. private static renderSorted;
  73340. /**
  73341. * Renders the submeshes in the order they were dispatched (no sort applied).
  73342. * @param subMeshes The submeshes to render
  73343. */
  73344. private static renderUnsorted;
  73345. /**
  73346. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73347. * are rendered back to front if in the same alpha index.
  73348. *
  73349. * @param a The first submesh
  73350. * @param b The second submesh
  73351. * @returns The result of the comparison
  73352. */
  73353. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73354. /**
  73355. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73356. * are rendered back to front.
  73357. *
  73358. * @param a The first submesh
  73359. * @param b The second submesh
  73360. * @returns The result of the comparison
  73361. */
  73362. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73363. /**
  73364. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73365. * are rendered front to back (prevent overdraw).
  73366. *
  73367. * @param a The first submesh
  73368. * @param b The second submesh
  73369. * @returns The result of the comparison
  73370. */
  73371. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73372. /**
  73373. * Resets the different lists of submeshes to prepare a new frame.
  73374. */
  73375. prepare(): void;
  73376. dispose(): void;
  73377. /**
  73378. * Inserts the submesh in its correct queue depending on its material.
  73379. * @param subMesh The submesh to dispatch
  73380. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73381. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73382. */
  73383. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73384. dispatchSprites(spriteManager: ISpriteManager): void;
  73385. dispatchParticles(particleSystem: IParticleSystem): void;
  73386. private _renderParticles;
  73387. private _renderSprites;
  73388. }
  73389. }
  73390. declare module BABYLON {
  73391. /**
  73392. * Interface describing the different options available in the rendering manager
  73393. * regarding Auto Clear between groups.
  73394. */
  73395. export interface IRenderingManagerAutoClearSetup {
  73396. /**
  73397. * Defines whether or not autoclear is enable.
  73398. */
  73399. autoClear: boolean;
  73400. /**
  73401. * Defines whether or not to autoclear the depth buffer.
  73402. */
  73403. depth: boolean;
  73404. /**
  73405. * Defines whether or not to autoclear the stencil buffer.
  73406. */
  73407. stencil: boolean;
  73408. }
  73409. /**
  73410. * This class is used by the onRenderingGroupObservable
  73411. */
  73412. export class RenderingGroupInfo {
  73413. /**
  73414. * The Scene that being rendered
  73415. */
  73416. scene: Scene;
  73417. /**
  73418. * The camera currently used for the rendering pass
  73419. */
  73420. camera: Nullable<Camera>;
  73421. /**
  73422. * The ID of the renderingGroup being processed
  73423. */
  73424. renderingGroupId: number;
  73425. }
  73426. /**
  73427. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73428. * It is enable to manage the different groups as well as the different necessary sort functions.
  73429. * This should not be used directly aside of the few static configurations
  73430. */
  73431. export class RenderingManager {
  73432. /**
  73433. * The max id used for rendering groups (not included)
  73434. */
  73435. static MAX_RENDERINGGROUPS: number;
  73436. /**
  73437. * The min id used for rendering groups (included)
  73438. */
  73439. static MIN_RENDERINGGROUPS: number;
  73440. /**
  73441. * Used to globally prevent autoclearing scenes.
  73442. */
  73443. static AUTOCLEAR: boolean;
  73444. /**
  73445. * @hidden
  73446. */
  73447. _useSceneAutoClearSetup: boolean;
  73448. private _scene;
  73449. private _renderingGroups;
  73450. private _depthStencilBufferAlreadyCleaned;
  73451. private _autoClearDepthStencil;
  73452. private _customOpaqueSortCompareFn;
  73453. private _customAlphaTestSortCompareFn;
  73454. private _customTransparentSortCompareFn;
  73455. private _renderingGroupInfo;
  73456. /**
  73457. * Instantiates a new rendering group for a particular scene
  73458. * @param scene Defines the scene the groups belongs to
  73459. */
  73460. constructor(scene: Scene);
  73461. private _clearDepthStencilBuffer;
  73462. /**
  73463. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73464. * @hidden
  73465. */
  73466. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73467. /**
  73468. * Resets the different information of the group to prepare a new frame
  73469. * @hidden
  73470. */
  73471. reset(): void;
  73472. /**
  73473. * Dispose and release the group and its associated resources.
  73474. * @hidden
  73475. */
  73476. dispose(): void;
  73477. /**
  73478. * Clear the info related to rendering groups preventing retention points during dispose.
  73479. */
  73480. freeRenderingGroups(): void;
  73481. private _prepareRenderingGroup;
  73482. /**
  73483. * Add a sprite manager to the rendering manager in order to render it this frame.
  73484. * @param spriteManager Define the sprite manager to render
  73485. */
  73486. dispatchSprites(spriteManager: ISpriteManager): void;
  73487. /**
  73488. * Add a particle system to the rendering manager in order to render it this frame.
  73489. * @param particleSystem Define the particle system to render
  73490. */
  73491. dispatchParticles(particleSystem: IParticleSystem): void;
  73492. /**
  73493. * Add a submesh to the manager in order to render it this frame
  73494. * @param subMesh The submesh to dispatch
  73495. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73496. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73497. */
  73498. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73499. /**
  73500. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73501. * This allowed control for front to back rendering or reversly depending of the special needs.
  73502. *
  73503. * @param renderingGroupId The rendering group id corresponding to its index
  73504. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73505. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73506. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73507. */
  73508. 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;
  73509. /**
  73510. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73511. *
  73512. * @param renderingGroupId The rendering group id corresponding to its index
  73513. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73514. * @param depth Automatically clears depth between groups if true and autoClear is true.
  73515. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  73516. */
  73517. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  73518. /**
  73519. * Gets the current auto clear configuration for one rendering group of the rendering
  73520. * manager.
  73521. * @param index the rendering group index to get the information for
  73522. * @returns The auto clear setup for the requested rendering group
  73523. */
  73524. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  73525. }
  73526. }
  73527. declare module BABYLON {
  73528. /**
  73529. * This Helps creating a texture that will be created from a camera in your scene.
  73530. * It is basically a dynamic texture that could be used to create special effects for instance.
  73531. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  73532. */
  73533. export class RenderTargetTexture extends Texture {
  73534. isCube: boolean;
  73535. /**
  73536. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  73537. */
  73538. static readonly REFRESHRATE_RENDER_ONCE: number;
  73539. /**
  73540. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  73541. */
  73542. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  73543. /**
  73544. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  73545. * the central point of your effect and can save a lot of performances.
  73546. */
  73547. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  73548. /**
  73549. * Use this predicate to dynamically define the list of mesh you want to render.
  73550. * If set, the renderList property will be overwritten.
  73551. */
  73552. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  73553. private _renderList;
  73554. /**
  73555. * Use this list to define the list of mesh you want to render.
  73556. */
  73557. renderList: Nullable<Array<AbstractMesh>>;
  73558. private _hookArray;
  73559. /**
  73560. * Define if particles should be rendered in your texture.
  73561. */
  73562. renderParticles: boolean;
  73563. /**
  73564. * Define if sprites should be rendered in your texture.
  73565. */
  73566. renderSprites: boolean;
  73567. /**
  73568. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  73569. */
  73570. coordinatesMode: number;
  73571. /**
  73572. * Define the camera used to render the texture.
  73573. */
  73574. activeCamera: Nullable<Camera>;
  73575. /**
  73576. * Override the render function of the texture with your own one.
  73577. */
  73578. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  73579. /**
  73580. * Define if camera post processes should be use while rendering the texture.
  73581. */
  73582. useCameraPostProcesses: boolean;
  73583. /**
  73584. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  73585. */
  73586. ignoreCameraViewport: boolean;
  73587. private _postProcessManager;
  73588. private _postProcesses;
  73589. private _resizeObserver;
  73590. /**
  73591. * An event triggered when the texture is unbind.
  73592. */
  73593. onBeforeBindObservable: Observable<RenderTargetTexture>;
  73594. /**
  73595. * An event triggered when the texture is unbind.
  73596. */
  73597. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  73598. private _onAfterUnbindObserver;
  73599. /**
  73600. * Set a after unbind callback in the texture.
  73601. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  73602. */
  73603. onAfterUnbind: () => void;
  73604. /**
  73605. * An event triggered before rendering the texture
  73606. */
  73607. onBeforeRenderObservable: Observable<number>;
  73608. private _onBeforeRenderObserver;
  73609. /**
  73610. * Set a before render callback in the texture.
  73611. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  73612. */
  73613. onBeforeRender: (faceIndex: number) => void;
  73614. /**
  73615. * An event triggered after rendering the texture
  73616. */
  73617. onAfterRenderObservable: Observable<number>;
  73618. private _onAfterRenderObserver;
  73619. /**
  73620. * Set a after render callback in the texture.
  73621. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  73622. */
  73623. onAfterRender: (faceIndex: number) => void;
  73624. /**
  73625. * An event triggered after the texture clear
  73626. */
  73627. onClearObservable: Observable<Engine>;
  73628. private _onClearObserver;
  73629. /**
  73630. * Set a clear callback in the texture.
  73631. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  73632. */
  73633. onClear: (Engine: Engine) => void;
  73634. /**
  73635. * Define the clear color of the Render Target if it should be different from the scene.
  73636. */
  73637. clearColor: Color4;
  73638. protected _size: number | {
  73639. width: number;
  73640. height: number;
  73641. };
  73642. protected _initialSizeParameter: number | {
  73643. width: number;
  73644. height: number;
  73645. } | {
  73646. ratio: number;
  73647. };
  73648. protected _sizeRatio: Nullable<number>;
  73649. /** @hidden */
  73650. _generateMipMaps: boolean;
  73651. protected _renderingManager: RenderingManager;
  73652. /** @hidden */
  73653. _waitingRenderList: string[];
  73654. protected _doNotChangeAspectRatio: boolean;
  73655. protected _currentRefreshId: number;
  73656. protected _refreshRate: number;
  73657. protected _textureMatrix: Matrix;
  73658. protected _samples: number;
  73659. protected _renderTargetOptions: RenderTargetCreationOptions;
  73660. /**
  73661. * Gets render target creation options that were used.
  73662. */
  73663. readonly renderTargetOptions: RenderTargetCreationOptions;
  73664. protected _engine: Engine;
  73665. protected _onRatioRescale(): void;
  73666. /**
  73667. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  73668. * It must define where the camera used to render the texture is set
  73669. */
  73670. boundingBoxPosition: Vector3;
  73671. private _boundingBoxSize;
  73672. /**
  73673. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  73674. * When defined, the cubemap will switch to local mode
  73675. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73676. * @example https://www.babylonjs-playground.com/#RNASML
  73677. */
  73678. boundingBoxSize: Vector3;
  73679. /**
  73680. * In case the RTT has been created with a depth texture, get the associated
  73681. * depth texture.
  73682. * Otherwise, return null.
  73683. */
  73684. depthStencilTexture: Nullable<InternalTexture>;
  73685. /**
  73686. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  73687. * or used a shadow, depth texture...
  73688. * @param name The friendly name of the texture
  73689. * @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)
  73690. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  73691. * @param generateMipMaps True if mip maps need to be generated after render.
  73692. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  73693. * @param type The type of the buffer in the RTT (int, half float, float...)
  73694. * @param isCube True if a cube texture needs to be created
  73695. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  73696. * @param generateDepthBuffer True to generate a depth buffer
  73697. * @param generateStencilBuffer True to generate a stencil buffer
  73698. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  73699. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  73700. * @param delayAllocation if the texture allocation should be delayed (default: false)
  73701. */
  73702. constructor(name: string, size: number | {
  73703. width: number;
  73704. height: number;
  73705. } | {
  73706. ratio: number;
  73707. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  73708. /**
  73709. * Creates a depth stencil texture.
  73710. * This is only available in WebGL 2 or with the depth texture extension available.
  73711. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  73712. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  73713. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  73714. */
  73715. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  73716. private _processSizeParameter;
  73717. /**
  73718. * Define the number of samples to use in case of MSAA.
  73719. * It defaults to one meaning no MSAA has been enabled.
  73720. */
  73721. samples: number;
  73722. /**
  73723. * Resets the refresh counter of the texture and start bak from scratch.
  73724. * Could be useful to regenerate the texture if it is setup to render only once.
  73725. */
  73726. resetRefreshCounter(): void;
  73727. /**
  73728. * Define the refresh rate of the texture or the rendering frequency.
  73729. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73730. */
  73731. refreshRate: number;
  73732. /**
  73733. * Adds a post process to the render target rendering passes.
  73734. * @param postProcess define the post process to add
  73735. */
  73736. addPostProcess(postProcess: PostProcess): void;
  73737. /**
  73738. * Clear all the post processes attached to the render target
  73739. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  73740. */
  73741. clearPostProcesses(dispose?: boolean): void;
  73742. /**
  73743. * Remove one of the post process from the list of attached post processes to the texture
  73744. * @param postProcess define the post process to remove from the list
  73745. */
  73746. removePostProcess(postProcess: PostProcess): void;
  73747. /** @hidden */
  73748. _shouldRender(): boolean;
  73749. /**
  73750. * Gets the actual render size of the texture.
  73751. * @returns the width of the render size
  73752. */
  73753. getRenderSize(): number;
  73754. /**
  73755. * Gets the actual render width of the texture.
  73756. * @returns the width of the render size
  73757. */
  73758. getRenderWidth(): number;
  73759. /**
  73760. * Gets the actual render height of the texture.
  73761. * @returns the height of the render size
  73762. */
  73763. getRenderHeight(): number;
  73764. /**
  73765. * Get if the texture can be rescaled or not.
  73766. */
  73767. readonly canRescale: boolean;
  73768. /**
  73769. * Resize the texture using a ratio.
  73770. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  73771. */
  73772. scale(ratio: number): void;
  73773. /**
  73774. * Get the texture reflection matrix used to rotate/transform the reflection.
  73775. * @returns the reflection matrix
  73776. */
  73777. getReflectionTextureMatrix(): Matrix;
  73778. /**
  73779. * Resize the texture to a new desired size.
  73780. * Be carrefull as it will recreate all the data in the new texture.
  73781. * @param size Define the new size. It can be:
  73782. * - a number for squared texture,
  73783. * - an object containing { width: number, height: number }
  73784. * - or an object containing a ratio { ratio: number }
  73785. */
  73786. resize(size: number | {
  73787. width: number;
  73788. height: number;
  73789. } | {
  73790. ratio: number;
  73791. }): void;
  73792. /**
  73793. * Renders all the objects from the render list into the texture.
  73794. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  73795. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  73796. */
  73797. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  73798. private _bestReflectionRenderTargetDimension;
  73799. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  73800. private renderToTarget;
  73801. /**
  73802. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73803. * This allowed control for front to back rendering or reversly depending of the special needs.
  73804. *
  73805. * @param renderingGroupId The rendering group id corresponding to its index
  73806. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73807. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73808. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73809. */
  73810. 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;
  73811. /**
  73812. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73813. *
  73814. * @param renderingGroupId The rendering group id corresponding to its index
  73815. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73816. */
  73817. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  73818. /**
  73819. * Clones the texture.
  73820. * @returns the cloned texture
  73821. */
  73822. clone(): RenderTargetTexture;
  73823. /**
  73824. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73825. * @returns The JSON representation of the texture
  73826. */
  73827. serialize(): any;
  73828. /**
  73829. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  73830. */
  73831. disposeFramebufferObjects(): void;
  73832. /**
  73833. * Dispose the texture and release its associated resources.
  73834. */
  73835. dispose(): void;
  73836. /** @hidden */
  73837. _rebuild(): void;
  73838. /**
  73839. * Clear the info related to rendering groups preventing retention point in material dispose.
  73840. */
  73841. freeRenderingGroups(): void;
  73842. }
  73843. }
  73844. declare module BABYLON {
  73845. /**
  73846. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73847. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73848. * You can then easily use it as a reflectionTexture on a flat surface.
  73849. * In case the surface is not a plane, please consider relying on reflection probes.
  73850. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73851. */
  73852. export class MirrorTexture extends RenderTargetTexture {
  73853. private scene;
  73854. /**
  73855. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  73856. * 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.
  73857. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73858. */
  73859. mirrorPlane: Plane;
  73860. /**
  73861. * Define the blur ratio used to blur the reflection if needed.
  73862. */
  73863. blurRatio: number;
  73864. /**
  73865. * Define the adaptive blur kernel used to blur the reflection if needed.
  73866. * This will autocompute the closest best match for the `blurKernel`
  73867. */
  73868. adaptiveBlurKernel: number;
  73869. /**
  73870. * Define the blur kernel used to blur the reflection if needed.
  73871. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73872. */
  73873. blurKernel: number;
  73874. /**
  73875. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  73876. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73877. */
  73878. blurKernelX: number;
  73879. /**
  73880. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  73881. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  73882. */
  73883. blurKernelY: number;
  73884. private _autoComputeBlurKernel;
  73885. protected _onRatioRescale(): void;
  73886. private _updateGammaSpace;
  73887. private _imageProcessingConfigChangeObserver;
  73888. private _transformMatrix;
  73889. private _mirrorMatrix;
  73890. private _savedViewMatrix;
  73891. private _blurX;
  73892. private _blurY;
  73893. private _adaptiveBlurKernel;
  73894. private _blurKernelX;
  73895. private _blurKernelY;
  73896. private _blurRatio;
  73897. /**
  73898. * Instantiates a Mirror Texture.
  73899. * Mirror texture can be used to simulate the view from a mirror in a scene.
  73900. * It will dynamically be rendered every frame to adapt to the camera point of view.
  73901. * You can then easily use it as a reflectionTexture on a flat surface.
  73902. * In case the surface is not a plane, please consider relying on reflection probes.
  73903. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  73904. * @param name
  73905. * @param size
  73906. * @param scene
  73907. * @param generateMipMaps
  73908. * @param type
  73909. * @param samplingMode
  73910. * @param generateDepthBuffer
  73911. */
  73912. constructor(name: string, size: number | {
  73913. width: number;
  73914. height: number;
  73915. } | {
  73916. ratio: number;
  73917. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  73918. private _preparePostProcesses;
  73919. /**
  73920. * Clone the mirror texture.
  73921. * @returns the cloned texture
  73922. */
  73923. clone(): MirrorTexture;
  73924. /**
  73925. * Serialize the texture to a JSON representation you could use in Parse later on
  73926. * @returns the serialized JSON representation
  73927. */
  73928. serialize(): any;
  73929. /**
  73930. * Dispose the texture and release its associated resources.
  73931. */
  73932. dispose(): void;
  73933. }
  73934. }
  73935. declare module BABYLON {
  73936. /**
  73937. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  73938. * @see http://doc.babylonjs.com/babylon101/materials#texture
  73939. */
  73940. export class Texture extends BaseTexture {
  73941. /** @hidden */
  73942. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  73943. /** @hidden */
  73944. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  73945. /** @hidden */
  73946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  73947. /** nearest is mag = nearest and min = nearest and mip = linear */
  73948. static readonly NEAREST_SAMPLINGMODE: number;
  73949. /** nearest is mag = nearest and min = nearest and mip = linear */
  73950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  73951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73952. static readonly BILINEAR_SAMPLINGMODE: number;
  73953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  73955. /** Trilinear is mag = linear and min = linear and mip = linear */
  73956. static readonly TRILINEAR_SAMPLINGMODE: number;
  73957. /** Trilinear is mag = linear and min = linear and mip = linear */
  73958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  73959. /** mag = nearest and min = nearest and mip = nearest */
  73960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  73961. /** mag = nearest and min = linear and mip = nearest */
  73962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  73963. /** mag = nearest and min = linear and mip = linear */
  73964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  73965. /** mag = nearest and min = linear and mip = none */
  73966. static readonly NEAREST_LINEAR: number;
  73967. /** mag = nearest and min = nearest and mip = none */
  73968. static readonly NEAREST_NEAREST: number;
  73969. /** mag = linear and min = nearest and mip = nearest */
  73970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  73971. /** mag = linear and min = nearest and mip = linear */
  73972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  73973. /** mag = linear and min = linear and mip = none */
  73974. static readonly LINEAR_LINEAR: number;
  73975. /** mag = linear and min = nearest and mip = none */
  73976. static readonly LINEAR_NEAREST: number;
  73977. /** Explicit coordinates mode */
  73978. static readonly EXPLICIT_MODE: number;
  73979. /** Spherical coordinates mode */
  73980. static readonly SPHERICAL_MODE: number;
  73981. /** Planar coordinates mode */
  73982. static readonly PLANAR_MODE: number;
  73983. /** Cubic coordinates mode */
  73984. static readonly CUBIC_MODE: number;
  73985. /** Projection coordinates mode */
  73986. static readonly PROJECTION_MODE: number;
  73987. /** Inverse Cubic coordinates mode */
  73988. static readonly SKYBOX_MODE: number;
  73989. /** Inverse Cubic coordinates mode */
  73990. static readonly INVCUBIC_MODE: number;
  73991. /** Equirectangular coordinates mode */
  73992. static readonly EQUIRECTANGULAR_MODE: number;
  73993. /** Equirectangular Fixed coordinates mode */
  73994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  73995. /** Equirectangular Fixed Mirrored coordinates mode */
  73996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73997. /** Texture is not repeating outside of 0..1 UVs */
  73998. static readonly CLAMP_ADDRESSMODE: number;
  73999. /** Texture is repeating outside of 0..1 UVs */
  74000. static readonly WRAP_ADDRESSMODE: number;
  74001. /** Texture is repeating and mirrored */
  74002. static readonly MIRROR_ADDRESSMODE: number;
  74003. /**
  74004. * 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
  74005. */
  74006. static UseSerializedUrlIfAny: boolean;
  74007. /**
  74008. * Define the url of the texture.
  74009. */
  74010. url: Nullable<string>;
  74011. /**
  74012. * Define an offset on the texture to offset the u coordinates of the UVs
  74013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74014. */
  74015. uOffset: number;
  74016. /**
  74017. * Define an offset on the texture to offset the v coordinates of the UVs
  74018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74019. */
  74020. vOffset: number;
  74021. /**
  74022. * Define an offset on the texture to scale the u coordinates of the UVs
  74023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74024. */
  74025. uScale: number;
  74026. /**
  74027. * Define an offset on the texture to scale the v coordinates of the UVs
  74028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74029. */
  74030. vScale: number;
  74031. /**
  74032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  74033. * @see http://doc.babylonjs.com/how_to/more_materials
  74034. */
  74035. uAng: number;
  74036. /**
  74037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  74038. * @see http://doc.babylonjs.com/how_to/more_materials
  74039. */
  74040. vAng: number;
  74041. /**
  74042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  74043. * @see http://doc.babylonjs.com/how_to/more_materials
  74044. */
  74045. wAng: number;
  74046. /**
  74047. * Defines the center of rotation (U)
  74048. */
  74049. uRotationCenter: number;
  74050. /**
  74051. * Defines the center of rotation (V)
  74052. */
  74053. vRotationCenter: number;
  74054. /**
  74055. * Defines the center of rotation (W)
  74056. */
  74057. wRotationCenter: number;
  74058. /**
  74059. * Are mip maps generated for this texture or not.
  74060. */
  74061. readonly noMipmap: boolean;
  74062. private _noMipmap;
  74063. /** @hidden */
  74064. _invertY: boolean;
  74065. private _rowGenerationMatrix;
  74066. private _cachedTextureMatrix;
  74067. private _projectionModeMatrix;
  74068. private _t0;
  74069. private _t1;
  74070. private _t2;
  74071. private _cachedUOffset;
  74072. private _cachedVOffset;
  74073. private _cachedUScale;
  74074. private _cachedVScale;
  74075. private _cachedUAng;
  74076. private _cachedVAng;
  74077. private _cachedWAng;
  74078. private _cachedProjectionMatrixId;
  74079. private _cachedCoordinatesMode;
  74080. /** @hidden */
  74081. protected _initialSamplingMode: number;
  74082. /** @hidden */
  74083. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  74084. private _deleteBuffer;
  74085. protected _format: Nullable<number>;
  74086. private _delayedOnLoad;
  74087. private _delayedOnError;
  74088. /**
  74089. * Observable triggered once the texture has been loaded.
  74090. */
  74091. onLoadObservable: Observable<Texture>;
  74092. protected _isBlocking: boolean;
  74093. /**
  74094. * Is the texture preventing material to render while loading.
  74095. * If false, a default texture will be used instead of the loading one during the preparation step.
  74096. */
  74097. isBlocking: boolean;
  74098. /**
  74099. * Get the current sampling mode associated with the texture.
  74100. */
  74101. readonly samplingMode: number;
  74102. /**
  74103. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  74104. */
  74105. readonly invertY: boolean;
  74106. /**
  74107. * Instantiates a new texture.
  74108. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74109. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74110. * @param url define the url of the picture to load as a texture
  74111. * @param scene define the scene the texture will belong to
  74112. * @param noMipmap define if the texture will require mip maps or not
  74113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74115. * @param onLoad define a callback triggered when the texture has been loaded
  74116. * @param onError define a callback triggered when an error occurred during the loading session
  74117. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74118. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74119. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74120. */
  74121. 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);
  74122. /**
  74123. * Update the url (and optional buffer) of this texture if url was null during construction.
  74124. * @param url the url of the texture
  74125. * @param buffer the buffer of the texture (defaults to null)
  74126. * @param onLoad callback called when the texture is loaded (defaults to null)
  74127. */
  74128. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  74129. /**
  74130. * Finish the loading sequence of a texture flagged as delayed load.
  74131. * @hidden
  74132. */
  74133. delayLoad(): void;
  74134. private _prepareRowForTextureGeneration;
  74135. /**
  74136. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  74137. * @returns the transform matrix of the texture.
  74138. */
  74139. getTextureMatrix(): Matrix;
  74140. /**
  74141. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  74142. * @returns The reflection texture transform
  74143. */
  74144. getReflectionTextureMatrix(): Matrix;
  74145. /**
  74146. * Clones the texture.
  74147. * @returns the cloned texture
  74148. */
  74149. clone(): Texture;
  74150. /**
  74151. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74152. * @returns The JSON representation of the texture
  74153. */
  74154. serialize(): any;
  74155. /**
  74156. * Get the current class name of the texture useful for serialization or dynamic coding.
  74157. * @returns "Texture"
  74158. */
  74159. getClassName(): string;
  74160. /**
  74161. * Dispose the texture and release its associated resources.
  74162. */
  74163. dispose(): void;
  74164. /**
  74165. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  74166. * @param parsedTexture Define the JSON representation of the texture
  74167. * @param scene Define the scene the parsed texture should be instantiated in
  74168. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74169. * @returns The parsed texture if successful
  74170. */
  74171. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74172. /**
  74173. * Creates a texture from its base 64 representation.
  74174. * @param data Define the base64 payload without the data: prefix
  74175. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74176. * @param scene Define the scene the texture should belong to
  74177. * @param noMipmap Forces the texture to not create mip map information if true
  74178. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74179. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74180. * @param onLoad define a callback triggered when the texture has been loaded
  74181. * @param onError define a callback triggered when an error occurred during the loading session
  74182. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74183. * @returns the created texture
  74184. */
  74185. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74186. /**
  74187. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74188. * @param data Define the base64 payload without the data: prefix
  74189. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74190. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74191. * @param scene Define the scene the texture should belong to
  74192. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74193. * @param noMipmap Forces the texture to not create mip map information if true
  74194. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74195. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74196. * @param onLoad define a callback triggered when the texture has been loaded
  74197. * @param onError define a callback triggered when an error occurred during the loading session
  74198. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74199. * @returns the created texture
  74200. */
  74201. 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;
  74202. }
  74203. }
  74204. declare module BABYLON {
  74205. /**
  74206. * Defines the options associated with the creation of a shader material.
  74207. */
  74208. export interface IShaderMaterialOptions {
  74209. /**
  74210. * Does the material work in alpha blend mode
  74211. */
  74212. needAlphaBlending: boolean;
  74213. /**
  74214. * Does the material work in alpha test mode
  74215. */
  74216. needAlphaTesting: boolean;
  74217. /**
  74218. * The list of attribute names used in the shader
  74219. */
  74220. attributes: string[];
  74221. /**
  74222. * The list of unifrom names used in the shader
  74223. */
  74224. uniforms: string[];
  74225. /**
  74226. * The list of UBO names used in the shader
  74227. */
  74228. uniformBuffers: string[];
  74229. /**
  74230. * The list of sampler names used in the shader
  74231. */
  74232. samplers: string[];
  74233. /**
  74234. * The list of defines used in the shader
  74235. */
  74236. defines: string[];
  74237. }
  74238. /**
  74239. * 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.
  74240. *
  74241. * This returned material effects how the mesh will look based on the code in the shaders.
  74242. *
  74243. * @see http://doc.babylonjs.com/how_to/shader_material
  74244. */
  74245. export class ShaderMaterial extends Material {
  74246. private _shaderPath;
  74247. private _options;
  74248. private _textures;
  74249. private _textureArrays;
  74250. private _floats;
  74251. private _ints;
  74252. private _floatsArrays;
  74253. private _colors3;
  74254. private _colors3Arrays;
  74255. private _colors4;
  74256. private _vectors2;
  74257. private _vectors3;
  74258. private _vectors4;
  74259. private _matrices;
  74260. private _matrices3x3;
  74261. private _matrices2x2;
  74262. private _vectors2Arrays;
  74263. private _vectors3Arrays;
  74264. private _cachedWorldViewMatrix;
  74265. private _renderId;
  74266. /**
  74267. * Instantiate a new shader material.
  74268. * 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.
  74269. * This returned material effects how the mesh will look based on the code in the shaders.
  74270. * @see http://doc.babylonjs.com/how_to/shader_material
  74271. * @param name Define the name of the material in the scene
  74272. * @param scene Define the scene the material belongs to
  74273. * @param shaderPath Defines the route to the shader code in one of three ways:
  74274. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74275. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74276. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74277. * @param options Define the options used to create the shader
  74278. */
  74279. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74280. /**
  74281. * Gets the current class name of the material e.g. "ShaderMaterial"
  74282. * Mainly use in serialization.
  74283. * @returns the class name
  74284. */
  74285. getClassName(): string;
  74286. /**
  74287. * Specifies if the material will require alpha blending
  74288. * @returns a boolean specifying if alpha blending is needed
  74289. */
  74290. needAlphaBlending(): boolean;
  74291. /**
  74292. * Specifies if this material should be rendered in alpha test mode
  74293. * @returns a boolean specifying if an alpha test is needed.
  74294. */
  74295. needAlphaTesting(): boolean;
  74296. private _checkUniform;
  74297. /**
  74298. * Set a texture in the shader.
  74299. * @param name Define the name of the uniform samplers as defined in the shader
  74300. * @param texture Define the texture to bind to this sampler
  74301. * @return the material itself allowing "fluent" like uniform updates
  74302. */
  74303. setTexture(name: string, texture: Texture): ShaderMaterial;
  74304. /**
  74305. * Set a texture array in the shader.
  74306. * @param name Define the name of the uniform sampler array as defined in the shader
  74307. * @param textures Define the list of textures to bind to this sampler
  74308. * @return the material itself allowing "fluent" like uniform updates
  74309. */
  74310. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74311. /**
  74312. * Set a float in the shader.
  74313. * @param name Define the name of the uniform as defined in the shader
  74314. * @param value Define the value to give to the uniform
  74315. * @return the material itself allowing "fluent" like uniform updates
  74316. */
  74317. setFloat(name: string, value: number): ShaderMaterial;
  74318. /**
  74319. * Set a int in the shader.
  74320. * @param name Define the name of the uniform as defined in the shader
  74321. * @param value Define the value to give to the uniform
  74322. * @return the material itself allowing "fluent" like uniform updates
  74323. */
  74324. setInt(name: string, value: number): ShaderMaterial;
  74325. /**
  74326. * Set an array of floats in the shader.
  74327. * @param name Define the name of the uniform as defined in the shader
  74328. * @param value Define the value to give to the uniform
  74329. * @return the material itself allowing "fluent" like uniform updates
  74330. */
  74331. setFloats(name: string, value: number[]): ShaderMaterial;
  74332. /**
  74333. * Set a vec3 in the shader from a Color3.
  74334. * @param name Define the name of the uniform as defined in the shader
  74335. * @param value Define the value to give to the uniform
  74336. * @return the material itself allowing "fluent" like uniform updates
  74337. */
  74338. setColor3(name: string, value: Color3): ShaderMaterial;
  74339. /**
  74340. * Set a vec3 array in the shader from a Color3 array.
  74341. * @param name Define the name of the uniform as defined in the shader
  74342. * @param value Define the value to give to the uniform
  74343. * @return the material itself allowing "fluent" like uniform updates
  74344. */
  74345. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74346. /**
  74347. * Set a vec4 in the shader from a Color4.
  74348. * @param name Define the name of the uniform as defined in the shader
  74349. * @param value Define the value to give to the uniform
  74350. * @return the material itself allowing "fluent" like uniform updates
  74351. */
  74352. setColor4(name: string, value: Color4): ShaderMaterial;
  74353. /**
  74354. * Set a vec2 in the shader from a Vector2.
  74355. * @param name Define the name of the uniform as defined in the shader
  74356. * @param value Define the value to give to the uniform
  74357. * @return the material itself allowing "fluent" like uniform updates
  74358. */
  74359. setVector2(name: string, value: Vector2): ShaderMaterial;
  74360. /**
  74361. * Set a vec3 in the shader from a Vector3.
  74362. * @param name Define the name of the uniform as defined in the shader
  74363. * @param value Define the value to give to the uniform
  74364. * @return the material itself allowing "fluent" like uniform updates
  74365. */
  74366. setVector3(name: string, value: Vector3): ShaderMaterial;
  74367. /**
  74368. * Set a vec4 in the shader from a Vector4.
  74369. * @param name Define the name of the uniform as defined in the shader
  74370. * @param value Define the value to give to the uniform
  74371. * @return the material itself allowing "fluent" like uniform updates
  74372. */
  74373. setVector4(name: string, value: Vector4): ShaderMaterial;
  74374. /**
  74375. * Set a mat4 in the shader from a Matrix.
  74376. * @param name Define the name of the uniform as defined in the shader
  74377. * @param value Define the value to give to the uniform
  74378. * @return the material itself allowing "fluent" like uniform updates
  74379. */
  74380. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74381. /**
  74382. * Set a mat3 in the shader from a Float32Array.
  74383. * @param name Define the name of the uniform as defined in the shader
  74384. * @param value Define the value to give to the uniform
  74385. * @return the material itself allowing "fluent" like uniform updates
  74386. */
  74387. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74388. /**
  74389. * Set a mat2 in the shader from a Float32Array.
  74390. * @param name Define the name of the uniform as defined in the shader
  74391. * @param value Define the value to give to the uniform
  74392. * @return the material itself allowing "fluent" like uniform updates
  74393. */
  74394. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74395. /**
  74396. * Set a vec2 array in the shader from a number array.
  74397. * @param name Define the name of the uniform as defined in the shader
  74398. * @param value Define the value to give to the uniform
  74399. * @return the material itself allowing "fluent" like uniform updates
  74400. */
  74401. setArray2(name: string, value: number[]): ShaderMaterial;
  74402. /**
  74403. * Set a vec3 array in the shader from a number array.
  74404. * @param name Define the name of the uniform as defined in the shader
  74405. * @param value Define the value to give to the uniform
  74406. * @return the material itself allowing "fluent" like uniform updates
  74407. */
  74408. setArray3(name: string, value: number[]): ShaderMaterial;
  74409. private _checkCache;
  74410. /**
  74411. * Checks if the material is ready to render the requested mesh
  74412. * @param mesh Define the mesh to render
  74413. * @param useInstances Define whether or not the material is used with instances
  74414. * @returns true if ready, otherwise false
  74415. */
  74416. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74417. /**
  74418. * Binds the world matrix to the material
  74419. * @param world defines the world transformation matrix
  74420. */
  74421. bindOnlyWorldMatrix(world: Matrix): void;
  74422. /**
  74423. * Binds the material to the mesh
  74424. * @param world defines the world transformation matrix
  74425. * @param mesh defines the mesh to bind the material to
  74426. */
  74427. bind(world: Matrix, mesh?: Mesh): void;
  74428. /**
  74429. * Gets the active textures from the material
  74430. * @returns an array of textures
  74431. */
  74432. getActiveTextures(): BaseTexture[];
  74433. /**
  74434. * Specifies if the material uses a texture
  74435. * @param texture defines the texture to check against the material
  74436. * @returns a boolean specifying if the material uses the texture
  74437. */
  74438. hasTexture(texture: BaseTexture): boolean;
  74439. /**
  74440. * Makes a duplicate of the material, and gives it a new name
  74441. * @param name defines the new name for the duplicated material
  74442. * @returns the cloned material
  74443. */
  74444. clone(name: string): ShaderMaterial;
  74445. /**
  74446. * Disposes the material
  74447. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74448. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74449. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74450. */
  74451. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74452. /**
  74453. * Serializes this material in a JSON representation
  74454. * @returns the serialized material object
  74455. */
  74456. serialize(): any;
  74457. /**
  74458. * Creates a shader material from parsed shader material data
  74459. * @param source defines the JSON represnetation of the material
  74460. * @param scene defines the hosting scene
  74461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74462. * @returns a new material
  74463. */
  74464. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74465. }
  74466. }
  74467. declare module BABYLON {
  74468. /** @hidden */
  74469. export var colorPixelShader: {
  74470. name: string;
  74471. shader: string;
  74472. };
  74473. }
  74474. declare module BABYLON {
  74475. /** @hidden */
  74476. export var colorVertexShader: {
  74477. name: string;
  74478. shader: string;
  74479. };
  74480. }
  74481. declare module BABYLON {
  74482. /**
  74483. * Line mesh
  74484. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74485. */
  74486. export class LinesMesh extends Mesh {
  74487. /**
  74488. * If vertex color should be applied to the mesh
  74489. */
  74490. useVertexColor?: boolean | undefined;
  74491. /**
  74492. * If vertex alpha should be applied to the mesh
  74493. */
  74494. useVertexAlpha?: boolean | undefined;
  74495. /**
  74496. * Color of the line (Default: White)
  74497. */
  74498. color: Color3;
  74499. /**
  74500. * Alpha of the line (Default: 1)
  74501. */
  74502. alpha: number;
  74503. /**
  74504. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74505. * This margin is expressed in world space coordinates, so its value may vary.
  74506. * Default value is 0.1
  74507. */
  74508. intersectionThreshold: number;
  74509. private _colorShader;
  74510. /**
  74511. * Creates a new LinesMesh
  74512. * @param name defines the name
  74513. * @param scene defines the hosting scene
  74514. * @param parent defines the parent mesh if any
  74515. * @param source defines the optional source LinesMesh used to clone data from
  74516. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74517. * When false, achieved by calling a clone(), also passing False.
  74518. * This will make creation of children, recursive.
  74519. * @param useVertexColor defines if this LinesMesh supports vertex color
  74520. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74521. */
  74522. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74523. /**
  74524. * If vertex color should be applied to the mesh
  74525. */
  74526. useVertexColor?: boolean | undefined,
  74527. /**
  74528. * If vertex alpha should be applied to the mesh
  74529. */
  74530. useVertexAlpha?: boolean | undefined);
  74531. /**
  74532. * Returns the string "LineMesh"
  74533. */
  74534. getClassName(): string;
  74535. /**
  74536. * @hidden
  74537. */
  74538. /**
  74539. * @hidden
  74540. */
  74541. material: Material;
  74542. /**
  74543. * @hidden
  74544. */
  74545. readonly checkCollisions: boolean;
  74546. /** @hidden */
  74547. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74548. /** @hidden */
  74549. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74550. /**
  74551. * Disposes of the line mesh
  74552. * @param doNotRecurse If children should be disposed
  74553. */
  74554. dispose(doNotRecurse?: boolean): void;
  74555. /**
  74556. * Returns a new LineMesh object cloned from the current one.
  74557. */
  74558. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74559. /**
  74560. * Creates a new InstancedLinesMesh object from the mesh model.
  74561. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74562. * @param name defines the name of the new instance
  74563. * @returns a new InstancedLinesMesh
  74564. */
  74565. createInstance(name: string): InstancedLinesMesh;
  74566. }
  74567. /**
  74568. * Creates an instance based on a source LinesMesh
  74569. */
  74570. export class InstancedLinesMesh extends InstancedMesh {
  74571. /**
  74572. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74573. * This margin is expressed in world space coordinates, so its value may vary.
  74574. * Initilized with the intersectionThreshold value of the source LinesMesh
  74575. */
  74576. intersectionThreshold: number;
  74577. constructor(name: string, source: LinesMesh);
  74578. /**
  74579. * Returns the string "InstancedLinesMesh".
  74580. */
  74581. getClassName(): string;
  74582. }
  74583. }
  74584. declare module BABYLON {
  74585. /**
  74586. * Mesh representing the gorund
  74587. */
  74588. export class GroundMesh extends Mesh {
  74589. /** If octree should be generated */
  74590. generateOctree: boolean;
  74591. private _heightQuads;
  74592. /** @hidden */
  74593. _subdivisionsX: number;
  74594. /** @hidden */
  74595. _subdivisionsY: number;
  74596. /** @hidden */
  74597. _width: number;
  74598. /** @hidden */
  74599. _height: number;
  74600. /** @hidden */
  74601. _minX: number;
  74602. /** @hidden */
  74603. _maxX: number;
  74604. /** @hidden */
  74605. _minZ: number;
  74606. /** @hidden */
  74607. _maxZ: number;
  74608. constructor(name: string, scene: Scene);
  74609. /**
  74610. * "GroundMesh"
  74611. * @returns "GroundMesh"
  74612. */
  74613. getClassName(): string;
  74614. /**
  74615. * The minimum of x and y subdivisions
  74616. */
  74617. readonly subdivisions: number;
  74618. /**
  74619. * X subdivisions
  74620. */
  74621. readonly subdivisionsX: number;
  74622. /**
  74623. * Y subdivisions
  74624. */
  74625. readonly subdivisionsY: number;
  74626. /**
  74627. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  74628. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  74629. * @param chunksCount the number of subdivisions for x and y
  74630. * @param octreeBlocksSize (Default: 32)
  74631. */
  74632. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  74633. /**
  74634. * Returns a height (y) value in the Worl system :
  74635. * the ground altitude at the coordinates (x, z) expressed in the World system.
  74636. * @param x x coordinate
  74637. * @param z z coordinate
  74638. * @returns the ground y position if (x, z) are outside the ground surface.
  74639. */
  74640. getHeightAtCoordinates(x: number, z: number): number;
  74641. /**
  74642. * Returns a normalized vector (Vector3) orthogonal to the ground
  74643. * at the ground coordinates (x, z) expressed in the World system.
  74644. * @param x x coordinate
  74645. * @param z z coordinate
  74646. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  74647. */
  74648. getNormalAtCoordinates(x: number, z: number): Vector3;
  74649. /**
  74650. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  74651. * at the ground coordinates (x, z) expressed in the World system.
  74652. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  74653. * @param x x coordinate
  74654. * @param z z coordinate
  74655. * @param ref vector to store the result
  74656. * @returns the GroundMesh.
  74657. */
  74658. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  74659. /**
  74660. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  74661. * if the ground has been updated.
  74662. * This can be used in the render loop.
  74663. * @returns the GroundMesh.
  74664. */
  74665. updateCoordinateHeights(): GroundMesh;
  74666. private _getFacetAt;
  74667. private _initHeightQuads;
  74668. private _computeHeightQuads;
  74669. /**
  74670. * Serializes this ground mesh
  74671. * @param serializationObject object to write serialization to
  74672. */
  74673. serialize(serializationObject: any): void;
  74674. /**
  74675. * Parses a serialized ground mesh
  74676. * @param parsedMesh the serialized mesh
  74677. * @param scene the scene to create the ground mesh in
  74678. * @returns the created ground mesh
  74679. */
  74680. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  74681. }
  74682. }
  74683. declare module BABYLON {
  74684. /**
  74685. * Interface for Physics-Joint data
  74686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74687. */
  74688. export interface PhysicsJointData {
  74689. /**
  74690. * The main pivot of the joint
  74691. */
  74692. mainPivot?: Vector3;
  74693. /**
  74694. * The connected pivot of the joint
  74695. */
  74696. connectedPivot?: Vector3;
  74697. /**
  74698. * The main axis of the joint
  74699. */
  74700. mainAxis?: Vector3;
  74701. /**
  74702. * The connected axis of the joint
  74703. */
  74704. connectedAxis?: Vector3;
  74705. /**
  74706. * The collision of the joint
  74707. */
  74708. collision?: boolean;
  74709. /**
  74710. * Native Oimo/Cannon/Energy data
  74711. */
  74712. nativeParams?: any;
  74713. }
  74714. /**
  74715. * This is a holder class for the physics joint created by the physics plugin
  74716. * It holds a set of functions to control the underlying joint
  74717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74718. */
  74719. export class PhysicsJoint {
  74720. /**
  74721. * The type of the physics joint
  74722. */
  74723. type: number;
  74724. /**
  74725. * The data for the physics joint
  74726. */
  74727. jointData: PhysicsJointData;
  74728. private _physicsJoint;
  74729. protected _physicsPlugin: IPhysicsEnginePlugin;
  74730. /**
  74731. * Initializes the physics joint
  74732. * @param type The type of the physics joint
  74733. * @param jointData The data for the physics joint
  74734. */
  74735. constructor(
  74736. /**
  74737. * The type of the physics joint
  74738. */
  74739. type: number,
  74740. /**
  74741. * The data for the physics joint
  74742. */
  74743. jointData: PhysicsJointData);
  74744. /**
  74745. * Gets the physics joint
  74746. */
  74747. /**
  74748. * Sets the physics joint
  74749. */
  74750. physicsJoint: any;
  74751. /**
  74752. * Sets the physics plugin
  74753. */
  74754. physicsPlugin: IPhysicsEnginePlugin;
  74755. /**
  74756. * Execute a function that is physics-plugin specific.
  74757. * @param {Function} func the function that will be executed.
  74758. * It accepts two parameters: the physics world and the physics joint
  74759. */
  74760. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  74761. /**
  74762. * Distance-Joint type
  74763. */
  74764. static DistanceJoint: number;
  74765. /**
  74766. * Hinge-Joint type
  74767. */
  74768. static HingeJoint: number;
  74769. /**
  74770. * Ball-and-Socket joint type
  74771. */
  74772. static BallAndSocketJoint: number;
  74773. /**
  74774. * Wheel-Joint type
  74775. */
  74776. static WheelJoint: number;
  74777. /**
  74778. * Slider-Joint type
  74779. */
  74780. static SliderJoint: number;
  74781. /**
  74782. * Prismatic-Joint type
  74783. */
  74784. static PrismaticJoint: number;
  74785. /**
  74786. * Universal-Joint type
  74787. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  74788. */
  74789. static UniversalJoint: number;
  74790. /**
  74791. * Hinge-Joint 2 type
  74792. */
  74793. static Hinge2Joint: number;
  74794. /**
  74795. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  74796. */
  74797. static PointToPointJoint: number;
  74798. /**
  74799. * Spring-Joint type
  74800. */
  74801. static SpringJoint: number;
  74802. /**
  74803. * Lock-Joint type
  74804. */
  74805. static LockJoint: number;
  74806. }
  74807. /**
  74808. * A class representing a physics distance joint
  74809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74810. */
  74811. export class DistanceJoint extends PhysicsJoint {
  74812. /**
  74813. *
  74814. * @param jointData The data for the Distance-Joint
  74815. */
  74816. constructor(jointData: DistanceJointData);
  74817. /**
  74818. * Update the predefined distance.
  74819. * @param maxDistance The maximum preferred distance
  74820. * @param minDistance The minimum preferred distance
  74821. */
  74822. updateDistance(maxDistance: number, minDistance?: number): void;
  74823. }
  74824. /**
  74825. * Represents a Motor-Enabled Joint
  74826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74827. */
  74828. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  74829. /**
  74830. * Initializes the Motor-Enabled Joint
  74831. * @param type The type of the joint
  74832. * @param jointData The physica joint data for the joint
  74833. */
  74834. constructor(type: number, jointData: PhysicsJointData);
  74835. /**
  74836. * Set the motor values.
  74837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74838. * @param force the force to apply
  74839. * @param maxForce max force for this motor.
  74840. */
  74841. setMotor(force?: number, maxForce?: number): void;
  74842. /**
  74843. * Set the motor's limits.
  74844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74845. * @param upperLimit The upper limit of the motor
  74846. * @param lowerLimit The lower limit of the motor
  74847. */
  74848. setLimit(upperLimit: number, lowerLimit?: number): void;
  74849. }
  74850. /**
  74851. * This class represents a single physics Hinge-Joint
  74852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74853. */
  74854. export class HingeJoint extends MotorEnabledJoint {
  74855. /**
  74856. * Initializes the Hinge-Joint
  74857. * @param jointData The joint data for the Hinge-Joint
  74858. */
  74859. constructor(jointData: PhysicsJointData);
  74860. /**
  74861. * Set the motor values.
  74862. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74863. * @param {number} force the force to apply
  74864. * @param {number} maxForce max force for this motor.
  74865. */
  74866. setMotor(force?: number, maxForce?: number): void;
  74867. /**
  74868. * Set the motor's limits.
  74869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74870. * @param upperLimit The upper limit of the motor
  74871. * @param lowerLimit The lower limit of the motor
  74872. */
  74873. setLimit(upperLimit: number, lowerLimit?: number): void;
  74874. }
  74875. /**
  74876. * This class represents a dual hinge physics joint (same as wheel joint)
  74877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74878. */
  74879. export class Hinge2Joint extends MotorEnabledJoint {
  74880. /**
  74881. * Initializes the Hinge2-Joint
  74882. * @param jointData The joint data for the Hinge2-Joint
  74883. */
  74884. constructor(jointData: PhysicsJointData);
  74885. /**
  74886. * Set the motor values.
  74887. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74888. * @param {number} targetSpeed the speed the motor is to reach
  74889. * @param {number} maxForce max force for this motor.
  74890. * @param {motorIndex} the motor's index, 0 or 1.
  74891. */
  74892. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  74893. /**
  74894. * Set the motor limits.
  74895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74896. * @param {number} upperLimit the upper limit
  74897. * @param {number} lowerLimit lower limit
  74898. * @param {motorIndex} the motor's index, 0 or 1.
  74899. */
  74900. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74901. }
  74902. /**
  74903. * Interface for a motor enabled joint
  74904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74905. */
  74906. export interface IMotorEnabledJoint {
  74907. /**
  74908. * Physics joint
  74909. */
  74910. physicsJoint: any;
  74911. /**
  74912. * Sets the motor of the motor-enabled joint
  74913. * @param force The force of the motor
  74914. * @param maxForce The maximum force of the motor
  74915. * @param motorIndex The index of the motor
  74916. */
  74917. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74918. /**
  74919. * Sets the limit of the motor
  74920. * @param upperLimit The upper limit of the motor
  74921. * @param lowerLimit The lower limit of the motor
  74922. * @param motorIndex The index of the motor
  74923. */
  74924. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74925. }
  74926. /**
  74927. * Joint data for a Distance-Joint
  74928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74929. */
  74930. export interface DistanceJointData extends PhysicsJointData {
  74931. /**
  74932. * Max distance the 2 joint objects can be apart
  74933. */
  74934. maxDistance: number;
  74935. }
  74936. /**
  74937. * Joint data from a spring joint
  74938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74939. */
  74940. export interface SpringJointData extends PhysicsJointData {
  74941. /**
  74942. * Length of the spring
  74943. */
  74944. length: number;
  74945. /**
  74946. * Stiffness of the spring
  74947. */
  74948. stiffness: number;
  74949. /**
  74950. * Damping of the spring
  74951. */
  74952. damping: number;
  74953. /** this callback will be called when applying the force to the impostors. */
  74954. forceApplicationCallback: () => void;
  74955. }
  74956. }
  74957. declare module BABYLON {
  74958. /**
  74959. * Interface used to describe a physics joint
  74960. */
  74961. export interface PhysicsImpostorJoint {
  74962. /** Defines the main impostor to which the joint is linked */
  74963. mainImpostor: PhysicsImpostor;
  74964. /** Defines the impostor that is connected to the main impostor using this joint */
  74965. connectedImpostor: PhysicsImpostor;
  74966. /** Defines the joint itself */
  74967. joint: PhysicsJoint;
  74968. }
  74969. /** @hidden */
  74970. export interface IPhysicsEnginePlugin {
  74971. world: any;
  74972. name: string;
  74973. setGravity(gravity: Vector3): void;
  74974. setTimeStep(timeStep: number): void;
  74975. getTimeStep(): number;
  74976. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74977. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74979. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74980. removePhysicsBody(impostor: PhysicsImpostor): void;
  74981. generateJoint(joint: PhysicsImpostorJoint): void;
  74982. removeJoint(joint: PhysicsImpostorJoint): void;
  74983. isSupported(): boolean;
  74984. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74985. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74986. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74987. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74988. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74989. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74990. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74991. getBodyMass(impostor: PhysicsImpostor): number;
  74992. getBodyFriction(impostor: PhysicsImpostor): number;
  74993. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74994. getBodyRestitution(impostor: PhysicsImpostor): number;
  74995. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74996. sleepBody(impostor: PhysicsImpostor): void;
  74997. wakeUpBody(impostor: PhysicsImpostor): void;
  74998. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74999. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75000. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75001. getRadius(impostor: PhysicsImpostor): number;
  75002. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75004. dispose(): void;
  75005. }
  75006. /**
  75007. * Interface used to define a physics engine
  75008. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75009. */
  75010. export interface IPhysicsEngine {
  75011. /**
  75012. * Gets the gravity vector used by the simulation
  75013. */
  75014. gravity: Vector3;
  75015. /**
  75016. * Sets the gravity vector used by the simulation
  75017. * @param gravity defines the gravity vector to use
  75018. */
  75019. setGravity(gravity: Vector3): void;
  75020. /**
  75021. * Set the time step of the physics engine.
  75022. * Default is 1/60.
  75023. * To slow it down, enter 1/600 for example.
  75024. * To speed it up, 1/30
  75025. * @param newTimeStep the new timestep to apply to this world.
  75026. */
  75027. setTimeStep(newTimeStep: number): void;
  75028. /**
  75029. * Get the time step of the physics engine.
  75030. * @returns the current time step
  75031. */
  75032. getTimeStep(): number;
  75033. /**
  75034. * Release all resources
  75035. */
  75036. dispose(): void;
  75037. /**
  75038. * Gets the name of the current physics plugin
  75039. * @returns the name of the plugin
  75040. */
  75041. getPhysicsPluginName(): string;
  75042. /**
  75043. * Adding a new impostor for the impostor tracking.
  75044. * This will be done by the impostor itself.
  75045. * @param impostor the impostor to add
  75046. */
  75047. addImpostor(impostor: PhysicsImpostor): void;
  75048. /**
  75049. * Remove an impostor from the engine.
  75050. * This impostor and its mesh will not longer be updated by the physics engine.
  75051. * @param impostor the impostor to remove
  75052. */
  75053. removeImpostor(impostor: PhysicsImpostor): void;
  75054. /**
  75055. * Add a joint to the physics engine
  75056. * @param mainImpostor defines the main impostor to which the joint is added.
  75057. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75058. * @param joint defines the joint that will connect both impostors.
  75059. */
  75060. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75061. /**
  75062. * Removes a joint from the simulation
  75063. * @param mainImpostor defines the impostor used with the joint
  75064. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75065. * @param joint defines the joint to remove
  75066. */
  75067. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75068. /**
  75069. * Gets the current plugin used to run the simulation
  75070. * @returns current plugin
  75071. */
  75072. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75073. /**
  75074. * Gets the list of physic impostors
  75075. * @returns an array of PhysicsImpostor
  75076. */
  75077. getImpostors(): Array<PhysicsImpostor>;
  75078. /**
  75079. * Gets the impostor for a physics enabled object
  75080. * @param object defines the object impersonated by the impostor
  75081. * @returns the PhysicsImpostor or null if not found
  75082. */
  75083. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75084. /**
  75085. * Gets the impostor for a physics body object
  75086. * @param body defines physics body used by the impostor
  75087. * @returns the PhysicsImpostor or null if not found
  75088. */
  75089. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75090. /**
  75091. * Called by the scene. No need to call it.
  75092. * @param delta defines the timespam between frames
  75093. */
  75094. _step(delta: number): void;
  75095. }
  75096. }
  75097. declare module BABYLON {
  75098. /**
  75099. * The interface for the physics imposter parameters
  75100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75101. */
  75102. export interface PhysicsImpostorParameters {
  75103. /**
  75104. * The mass of the physics imposter
  75105. */
  75106. mass: number;
  75107. /**
  75108. * The friction of the physics imposter
  75109. */
  75110. friction?: number;
  75111. /**
  75112. * The coefficient of restitution of the physics imposter
  75113. */
  75114. restitution?: number;
  75115. /**
  75116. * The native options of the physics imposter
  75117. */
  75118. nativeOptions?: any;
  75119. /**
  75120. * Specifies if the parent should be ignored
  75121. */
  75122. ignoreParent?: boolean;
  75123. /**
  75124. * Specifies if bi-directional transformations should be disabled
  75125. */
  75126. disableBidirectionalTransformation?: boolean;
  75127. }
  75128. /**
  75129. * Interface for a physics-enabled object
  75130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75131. */
  75132. export interface IPhysicsEnabledObject {
  75133. /**
  75134. * The position of the physics-enabled object
  75135. */
  75136. position: Vector3;
  75137. /**
  75138. * The rotation of the physics-enabled object
  75139. */
  75140. rotationQuaternion: Nullable<Quaternion>;
  75141. /**
  75142. * The scale of the physics-enabled object
  75143. */
  75144. scaling: Vector3;
  75145. /**
  75146. * The rotation of the physics-enabled object
  75147. */
  75148. rotation?: Vector3;
  75149. /**
  75150. * The parent of the physics-enabled object
  75151. */
  75152. parent?: any;
  75153. /**
  75154. * The bounding info of the physics-enabled object
  75155. * @returns The bounding info of the physics-enabled object
  75156. */
  75157. getBoundingInfo(): BoundingInfo;
  75158. /**
  75159. * Computes the world matrix
  75160. * @param force Specifies if the world matrix should be computed by force
  75161. * @returns A world matrix
  75162. */
  75163. computeWorldMatrix(force: boolean): Matrix;
  75164. /**
  75165. * Gets the world matrix
  75166. * @returns A world matrix
  75167. */
  75168. getWorldMatrix?(): Matrix;
  75169. /**
  75170. * Gets the child meshes
  75171. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75172. * @returns An array of abstract meshes
  75173. */
  75174. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75175. /**
  75176. * Gets the vertex data
  75177. * @param kind The type of vertex data
  75178. * @returns A nullable array of numbers, or a float32 array
  75179. */
  75180. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75181. /**
  75182. * Gets the indices from the mesh
  75183. * @returns A nullable array of index arrays
  75184. */
  75185. getIndices?(): Nullable<IndicesArray>;
  75186. /**
  75187. * Gets the scene from the mesh
  75188. * @returns the indices array or null
  75189. */
  75190. getScene?(): Scene;
  75191. /**
  75192. * Gets the absolute position from the mesh
  75193. * @returns the absolute position
  75194. */
  75195. getAbsolutePosition(): Vector3;
  75196. /**
  75197. * Gets the absolute pivot point from the mesh
  75198. * @returns the absolute pivot point
  75199. */
  75200. getAbsolutePivotPoint(): Vector3;
  75201. /**
  75202. * Rotates the mesh
  75203. * @param axis The axis of rotation
  75204. * @param amount The amount of rotation
  75205. * @param space The space of the rotation
  75206. * @returns The rotation transform node
  75207. */
  75208. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75209. /**
  75210. * Translates the mesh
  75211. * @param axis The axis of translation
  75212. * @param distance The distance of translation
  75213. * @param space The space of the translation
  75214. * @returns The transform node
  75215. */
  75216. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75217. /**
  75218. * Sets the absolute position of the mesh
  75219. * @param absolutePosition The absolute position of the mesh
  75220. * @returns The transform node
  75221. */
  75222. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75223. /**
  75224. * Gets the class name of the mesh
  75225. * @returns The class name
  75226. */
  75227. getClassName(): string;
  75228. }
  75229. /**
  75230. * Represents a physics imposter
  75231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75232. */
  75233. export class PhysicsImpostor {
  75234. /**
  75235. * The physics-enabled object used as the physics imposter
  75236. */
  75237. object: IPhysicsEnabledObject;
  75238. /**
  75239. * The type of the physics imposter
  75240. */
  75241. type: number;
  75242. private _options;
  75243. private _scene?;
  75244. /**
  75245. * The default object size of the imposter
  75246. */
  75247. static DEFAULT_OBJECT_SIZE: Vector3;
  75248. /**
  75249. * The identity quaternion of the imposter
  75250. */
  75251. static IDENTITY_QUATERNION: Quaternion;
  75252. /** @hidden */
  75253. _pluginData: any;
  75254. private _physicsEngine;
  75255. private _physicsBody;
  75256. private _bodyUpdateRequired;
  75257. private _onBeforePhysicsStepCallbacks;
  75258. private _onAfterPhysicsStepCallbacks;
  75259. /** @hidden */
  75260. _onPhysicsCollideCallbacks: Array<{
  75261. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  75262. otherImpostors: Array<PhysicsImpostor>;
  75263. }>;
  75264. private _deltaPosition;
  75265. private _deltaRotation;
  75266. private _deltaRotationConjugated;
  75267. private _parent;
  75268. private _isDisposed;
  75269. private static _tmpVecs;
  75270. private static _tmpQuat;
  75271. /**
  75272. * Specifies if the physics imposter is disposed
  75273. */
  75274. readonly isDisposed: boolean;
  75275. /**
  75276. * Gets the mass of the physics imposter
  75277. */
  75278. mass: number;
  75279. /**
  75280. * Gets the coefficient of friction
  75281. */
  75282. /**
  75283. * Sets the coefficient of friction
  75284. */
  75285. friction: number;
  75286. /**
  75287. * Gets the coefficient of restitution
  75288. */
  75289. /**
  75290. * Sets the coefficient of restitution
  75291. */
  75292. restitution: number;
  75293. /**
  75294. * The unique id of the physics imposter
  75295. * set by the physics engine when adding this impostor to the array
  75296. */
  75297. uniqueId: number;
  75298. private _joints;
  75299. /**
  75300. * Initializes the physics imposter
  75301. * @param object The physics-enabled object used as the physics imposter
  75302. * @param type The type of the physics imposter
  75303. * @param _options The options for the physics imposter
  75304. * @param _scene The Babylon scene
  75305. */
  75306. constructor(
  75307. /**
  75308. * The physics-enabled object used as the physics imposter
  75309. */
  75310. object: IPhysicsEnabledObject,
  75311. /**
  75312. * The type of the physics imposter
  75313. */
  75314. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  75315. /**
  75316. * This function will completly initialize this impostor.
  75317. * It will create a new body - but only if this mesh has no parent.
  75318. * If it has, this impostor will not be used other than to define the impostor
  75319. * of the child mesh.
  75320. * @hidden
  75321. */
  75322. _init(): void;
  75323. private _getPhysicsParent;
  75324. /**
  75325. * Should a new body be generated.
  75326. * @returns boolean specifying if body initialization is required
  75327. */
  75328. isBodyInitRequired(): boolean;
  75329. /**
  75330. * Sets the updated scaling
  75331. * @param updated Specifies if the scaling is updated
  75332. */
  75333. setScalingUpdated(): void;
  75334. /**
  75335. * Force a regeneration of this or the parent's impostor's body.
  75336. * Use under cautious - This will remove all joints already implemented.
  75337. */
  75338. forceUpdate(): void;
  75339. /**
  75340. * Gets the body that holds this impostor. Either its own, or its parent.
  75341. */
  75342. /**
  75343. * Set the physics body. Used mainly by the physics engine/plugin
  75344. */
  75345. physicsBody: any;
  75346. /**
  75347. * Get the parent of the physics imposter
  75348. * @returns Physics imposter or null
  75349. */
  75350. /**
  75351. * Sets the parent of the physics imposter
  75352. */
  75353. parent: Nullable<PhysicsImpostor>;
  75354. /**
  75355. * Resets the update flags
  75356. */
  75357. resetUpdateFlags(): void;
  75358. /**
  75359. * Gets the object extend size
  75360. * @returns the object extend size
  75361. */
  75362. getObjectExtendSize(): Vector3;
  75363. /**
  75364. * Gets the object center
  75365. * @returns The object center
  75366. */
  75367. getObjectCenter(): Vector3;
  75368. /**
  75369. * Get a specific parametes from the options parameter
  75370. * @param paramName The object parameter name
  75371. * @returns The object parameter
  75372. */
  75373. getParam(paramName: string): any;
  75374. /**
  75375. * Sets a specific parameter in the options given to the physics plugin
  75376. * @param paramName The parameter name
  75377. * @param value The value of the parameter
  75378. */
  75379. setParam(paramName: string, value: number): void;
  75380. /**
  75381. * Specifically change the body's mass option. Won't recreate the physics body object
  75382. * @param mass The mass of the physics imposter
  75383. */
  75384. setMass(mass: number): void;
  75385. /**
  75386. * Gets the linear velocity
  75387. * @returns linear velocity or null
  75388. */
  75389. getLinearVelocity(): Nullable<Vector3>;
  75390. /**
  75391. * Sets the linear velocity
  75392. * @param velocity linear velocity or null
  75393. */
  75394. setLinearVelocity(velocity: Nullable<Vector3>): void;
  75395. /**
  75396. * Gets the angular velocity
  75397. * @returns angular velocity or null
  75398. */
  75399. getAngularVelocity(): Nullable<Vector3>;
  75400. /**
  75401. * Sets the angular velocity
  75402. * @param velocity The velocity or null
  75403. */
  75404. setAngularVelocity(velocity: Nullable<Vector3>): void;
  75405. /**
  75406. * Execute a function with the physics plugin native code
  75407. * Provide a function the will have two variables - the world object and the physics body object
  75408. * @param func The function to execute with the physics plugin native code
  75409. */
  75410. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  75411. /**
  75412. * Register a function that will be executed before the physics world is stepping forward
  75413. * @param func The function to execute before the physics world is stepped forward
  75414. */
  75415. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75416. /**
  75417. * Unregister a function that will be executed before the physics world is stepping forward
  75418. * @param func The function to execute before the physics world is stepped forward
  75419. */
  75420. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75421. /**
  75422. * Register a function that will be executed after the physics step
  75423. * @param func The function to execute after physics step
  75424. */
  75425. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75426. /**
  75427. * Unregisters a function that will be executed after the physics step
  75428. * @param func The function to execute after physics step
  75429. */
  75430. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75431. /**
  75432. * register a function that will be executed when this impostor collides against a different body
  75433. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  75434. * @param func Callback that is executed on collision
  75435. */
  75436. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  75437. /**
  75438. * Unregisters the physics imposter on contact
  75439. * @param collideAgainst The physics object to collide against
  75440. * @param func Callback to execute on collision
  75441. */
  75442. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  75443. private _tmpQuat;
  75444. private _tmpQuat2;
  75445. /**
  75446. * Get the parent rotation
  75447. * @returns The parent rotation
  75448. */
  75449. getParentsRotation(): Quaternion;
  75450. /**
  75451. * this function is executed by the physics engine.
  75452. */
  75453. beforeStep: () => void;
  75454. /**
  75455. * this function is executed by the physics engine
  75456. */
  75457. afterStep: () => void;
  75458. /**
  75459. * Legacy collision detection event support
  75460. */
  75461. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  75462. /**
  75463. * event and body object due to cannon's event-based architecture.
  75464. */
  75465. onCollide: (e: {
  75466. body: any;
  75467. }) => void;
  75468. /**
  75469. * Apply a force
  75470. * @param force The force to apply
  75471. * @param contactPoint The contact point for the force
  75472. * @returns The physics imposter
  75473. */
  75474. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75475. /**
  75476. * Apply an impulse
  75477. * @param force The impulse force
  75478. * @param contactPoint The contact point for the impulse force
  75479. * @returns The physics imposter
  75480. */
  75481. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75482. /**
  75483. * A help function to create a joint
  75484. * @param otherImpostor A physics imposter used to create a joint
  75485. * @param jointType The type of joint
  75486. * @param jointData The data for the joint
  75487. * @returns The physics imposter
  75488. */
  75489. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  75490. /**
  75491. * Add a joint to this impostor with a different impostor
  75492. * @param otherImpostor A physics imposter used to add a joint
  75493. * @param joint The joint to add
  75494. * @returns The physics imposter
  75495. */
  75496. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  75497. /**
  75498. * Will keep this body still, in a sleep mode.
  75499. * @returns the physics imposter
  75500. */
  75501. sleep(): PhysicsImpostor;
  75502. /**
  75503. * Wake the body up.
  75504. * @returns The physics imposter
  75505. */
  75506. wakeUp(): PhysicsImpostor;
  75507. /**
  75508. * Clones the physics imposter
  75509. * @param newObject The physics imposter clones to this physics-enabled object
  75510. * @returns A nullable physics imposter
  75511. */
  75512. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75513. /**
  75514. * Disposes the physics imposter
  75515. */
  75516. dispose(): void;
  75517. /**
  75518. * Sets the delta position
  75519. * @param position The delta position amount
  75520. */
  75521. setDeltaPosition(position: Vector3): void;
  75522. /**
  75523. * Sets the delta rotation
  75524. * @param rotation The delta rotation amount
  75525. */
  75526. setDeltaRotation(rotation: Quaternion): void;
  75527. /**
  75528. * Gets the box size of the physics imposter and stores the result in the input parameter
  75529. * @param result Stores the box size
  75530. * @returns The physics imposter
  75531. */
  75532. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  75533. /**
  75534. * Gets the radius of the physics imposter
  75535. * @returns Radius of the physics imposter
  75536. */
  75537. getRadius(): number;
  75538. /**
  75539. * Sync a bone with this impostor
  75540. * @param bone The bone to sync to the impostor.
  75541. * @param boneMesh The mesh that the bone is influencing.
  75542. * @param jointPivot The pivot of the joint / bone in local space.
  75543. * @param distToJoint Optional distance from the impostor to the joint.
  75544. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75545. */
  75546. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  75547. /**
  75548. * Sync impostor to a bone
  75549. * @param bone The bone that the impostor will be synced to.
  75550. * @param boneMesh The mesh that the bone is influencing.
  75551. * @param jointPivot The pivot of the joint / bone in local space.
  75552. * @param distToJoint Optional distance from the impostor to the joint.
  75553. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75554. * @param boneAxis Optional vector3 axis the bone is aligned with
  75555. */
  75556. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  75557. /**
  75558. * No-Imposter type
  75559. */
  75560. static NoImpostor: number;
  75561. /**
  75562. * Sphere-Imposter type
  75563. */
  75564. static SphereImpostor: number;
  75565. /**
  75566. * Box-Imposter type
  75567. */
  75568. static BoxImpostor: number;
  75569. /**
  75570. * Plane-Imposter type
  75571. */
  75572. static PlaneImpostor: number;
  75573. /**
  75574. * Mesh-imposter type
  75575. */
  75576. static MeshImpostor: number;
  75577. /**
  75578. * Cylinder-Imposter type
  75579. */
  75580. static CylinderImpostor: number;
  75581. /**
  75582. * Particle-Imposter type
  75583. */
  75584. static ParticleImpostor: number;
  75585. /**
  75586. * Heightmap-Imposter type
  75587. */
  75588. static HeightmapImpostor: number;
  75589. }
  75590. }
  75591. declare module BABYLON {
  75592. /**
  75593. * Class used to represent a specific level of detail of a mesh
  75594. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75595. */
  75596. export class MeshLODLevel {
  75597. /** Defines the distance where this level should star being displayed */
  75598. distance: number;
  75599. /** Defines the mesh to use to render this level */
  75600. mesh: Nullable<Mesh>;
  75601. /**
  75602. * Creates a new LOD level
  75603. * @param distance defines the distance where this level should star being displayed
  75604. * @param mesh defines the mesh to use to render this level
  75605. */
  75606. constructor(
  75607. /** Defines the distance where this level should star being displayed */
  75608. distance: number,
  75609. /** Defines the mesh to use to render this level */
  75610. mesh: Nullable<Mesh>);
  75611. }
  75612. /**
  75613. * @hidden
  75614. **/
  75615. export class _CreationDataStorage {
  75616. closePath?: boolean;
  75617. closeArray?: boolean;
  75618. idx: number[];
  75619. dashSize: number;
  75620. gapSize: number;
  75621. path3D: Path3D;
  75622. pathArray: Vector3[][];
  75623. arc: number;
  75624. radius: number;
  75625. cap: number;
  75626. tessellation: number;
  75627. }
  75628. /**
  75629. * @hidden
  75630. **/
  75631. class _InstanceDataStorage {
  75632. visibleInstances: any;
  75633. renderIdForInstances: number[];
  75634. batchCache: _InstancesBatch;
  75635. instancesBufferSize: number;
  75636. instancesBuffer: Nullable<Buffer>;
  75637. instancesData: Float32Array;
  75638. overridenInstanceCount: number;
  75639. }
  75640. /**
  75641. * @hidden
  75642. **/
  75643. export class _InstancesBatch {
  75644. mustReturn: boolean;
  75645. visibleInstances: Nullable<InstancedMesh[]>[];
  75646. renderSelf: boolean[];
  75647. }
  75648. /**
  75649. * Class used to represent renderable models
  75650. */
  75651. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  75652. /**
  75653. * Mesh side orientation : usually the external or front surface
  75654. */
  75655. static readonly FRONTSIDE: number;
  75656. /**
  75657. * Mesh side orientation : usually the internal or back surface
  75658. */
  75659. static readonly BACKSIDE: number;
  75660. /**
  75661. * Mesh side orientation : both internal and external or front and back surfaces
  75662. */
  75663. static readonly DOUBLESIDE: number;
  75664. /**
  75665. * Mesh side orientation : by default, `FRONTSIDE`
  75666. */
  75667. static readonly DEFAULTSIDE: number;
  75668. /**
  75669. * Mesh cap setting : no cap
  75670. */
  75671. static readonly NO_CAP: number;
  75672. /**
  75673. * Mesh cap setting : one cap at the beginning of the mesh
  75674. */
  75675. static readonly CAP_START: number;
  75676. /**
  75677. * Mesh cap setting : one cap at the end of the mesh
  75678. */
  75679. static readonly CAP_END: number;
  75680. /**
  75681. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  75682. */
  75683. static readonly CAP_ALL: number;
  75684. /**
  75685. * Gets the default side orientation.
  75686. * @param orientation the orientation to value to attempt to get
  75687. * @returns the default orientation
  75688. * @hidden
  75689. */
  75690. static _GetDefaultSideOrientation(orientation?: number): number;
  75691. private _onBeforeRenderObservable;
  75692. private _onBeforeBindObservable;
  75693. private _onAfterRenderObservable;
  75694. private _onBeforeDrawObservable;
  75695. /**
  75696. * An event triggered before rendering the mesh
  75697. */
  75698. readonly onBeforeRenderObservable: Observable<Mesh>;
  75699. /**
  75700. * An event triggered before binding the mesh
  75701. */
  75702. readonly onBeforeBindObservable: Observable<Mesh>;
  75703. /**
  75704. * An event triggered after rendering the mesh
  75705. */
  75706. readonly onAfterRenderObservable: Observable<Mesh>;
  75707. /**
  75708. * An event triggered before drawing the mesh
  75709. */
  75710. readonly onBeforeDrawObservable: Observable<Mesh>;
  75711. private _onBeforeDrawObserver;
  75712. /**
  75713. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  75714. */
  75715. onBeforeDraw: () => void;
  75716. /**
  75717. * Gets the delay loading state of the mesh (when delay loading is turned on)
  75718. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  75719. */
  75720. delayLoadState: number;
  75721. /**
  75722. * Gets the list of instances created from this mesh
  75723. * it is not supposed to be modified manually.
  75724. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  75725. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75726. */
  75727. instances: InstancedMesh[];
  75728. /**
  75729. * Gets the file containing delay loading data for this mesh
  75730. */
  75731. delayLoadingFile: string;
  75732. /** @hidden */
  75733. _binaryInfo: any;
  75734. private _LODLevels;
  75735. /**
  75736. * User defined function used to change how LOD level selection is done
  75737. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75738. */
  75739. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  75740. private _morphTargetManager;
  75741. /**
  75742. * Gets or sets the morph target manager
  75743. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75744. */
  75745. morphTargetManager: Nullable<MorphTargetManager>;
  75746. /** @hidden */
  75747. _creationDataStorage: Nullable<_CreationDataStorage>;
  75748. /** @hidden */
  75749. _geometry: Nullable<Geometry>;
  75750. /** @hidden */
  75751. _delayInfo: Array<string>;
  75752. /** @hidden */
  75753. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  75754. /** @hidden */
  75755. _instanceDataStorage: _InstanceDataStorage;
  75756. private _effectiveMaterial;
  75757. /** @hidden */
  75758. _shouldGenerateFlatShading: boolean;
  75759. private _preActivateId;
  75760. /** @hidden */
  75761. _originalBuilderSideOrientation: number;
  75762. /**
  75763. * Use this property to change the original side orientation defined at construction time
  75764. */
  75765. overrideMaterialSideOrientation: Nullable<number>;
  75766. private _areNormalsFrozen;
  75767. private _sourcePositions;
  75768. private _sourceNormals;
  75769. private _source;
  75770. private meshMap;
  75771. /**
  75772. * Gets the source mesh (the one used to clone this one from)
  75773. */
  75774. readonly source: Nullable<Mesh>;
  75775. /**
  75776. * Gets or sets a boolean indicating that this mesh does not use index buffer
  75777. */
  75778. isUnIndexed: boolean;
  75779. /**
  75780. * @constructor
  75781. * @param name The value used by scene.getMeshByName() to do a lookup.
  75782. * @param scene The scene to add this mesh to.
  75783. * @param parent The parent of this mesh, if it has one
  75784. * @param source An optional Mesh from which geometry is shared, cloned.
  75785. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75786. * When false, achieved by calling a clone(), also passing False.
  75787. * This will make creation of children, recursive.
  75788. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  75789. */
  75790. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  75791. /**
  75792. * Gets the class name
  75793. * @returns the string "Mesh".
  75794. */
  75795. getClassName(): string;
  75796. /** @hidden */
  75797. readonly _isMesh: boolean;
  75798. /**
  75799. * Returns a description of this mesh
  75800. * @param fullDetails define if full details about this mesh must be used
  75801. * @returns a descriptive string representing this mesh
  75802. */
  75803. toString(fullDetails?: boolean): string;
  75804. /** @hidden */
  75805. _unBindEffect(): void;
  75806. /**
  75807. * Gets a boolean indicating if this mesh has LOD
  75808. */
  75809. readonly hasLODLevels: boolean;
  75810. /**
  75811. * Gets the list of MeshLODLevel associated with the current mesh
  75812. * @returns an array of MeshLODLevel
  75813. */
  75814. getLODLevels(): MeshLODLevel[];
  75815. private _sortLODLevels;
  75816. /**
  75817. * Add a mesh as LOD level triggered at the given distance.
  75818. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75819. * @param distance The distance from the center of the object to show this level
  75820. * @param mesh The mesh to be added as LOD level (can be null)
  75821. * @return This mesh (for chaining)
  75822. */
  75823. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  75824. /**
  75825. * Returns the LOD level mesh at the passed distance or null if not found.
  75826. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75827. * @param distance The distance from the center of the object to show this level
  75828. * @returns a Mesh or `null`
  75829. */
  75830. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  75831. /**
  75832. * Remove a mesh from the LOD array
  75833. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75834. * @param mesh defines the mesh to be removed
  75835. * @return This mesh (for chaining)
  75836. */
  75837. removeLODLevel(mesh: Mesh): Mesh;
  75838. /**
  75839. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  75840. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75841. * @param camera defines the camera to use to compute distance
  75842. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75843. * @return This mesh (for chaining)
  75844. */
  75845. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75846. /**
  75847. * Gets the mesh internal Geometry object
  75848. */
  75849. readonly geometry: Nullable<Geometry>;
  75850. /**
  75851. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75852. * @returns the total number of vertices
  75853. */
  75854. getTotalVertices(): number;
  75855. /**
  75856. * Returns the content of an associated vertex buffer
  75857. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75858. * - VertexBuffer.PositionKind
  75859. * - VertexBuffer.UVKind
  75860. * - VertexBuffer.UV2Kind
  75861. * - VertexBuffer.UV3Kind
  75862. * - VertexBuffer.UV4Kind
  75863. * - VertexBuffer.UV5Kind
  75864. * - VertexBuffer.UV6Kind
  75865. * - VertexBuffer.ColorKind
  75866. * - VertexBuffer.MatricesIndicesKind
  75867. * - VertexBuffer.MatricesIndicesExtraKind
  75868. * - VertexBuffer.MatricesWeightsKind
  75869. * - VertexBuffer.MatricesWeightsExtraKind
  75870. * @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
  75871. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75872. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75873. */
  75874. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75875. /**
  75876. * Returns the mesh VertexBuffer object from the requested `kind`
  75877. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75878. * - VertexBuffer.PositionKind
  75879. * - VertexBuffer.UVKind
  75880. * - VertexBuffer.UV2Kind
  75881. * - VertexBuffer.UV3Kind
  75882. * - VertexBuffer.UV4Kind
  75883. * - VertexBuffer.UV5Kind
  75884. * - VertexBuffer.UV6Kind
  75885. * - VertexBuffer.ColorKind
  75886. * - VertexBuffer.MatricesIndicesKind
  75887. * - VertexBuffer.MatricesIndicesExtraKind
  75888. * - VertexBuffer.MatricesWeightsKind
  75889. * - VertexBuffer.MatricesWeightsExtraKind
  75890. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75891. */
  75892. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75893. /**
  75894. * Tests if a specific vertex buffer is associated with this mesh
  75895. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75896. * - VertexBuffer.PositionKind
  75897. * - VertexBuffer.UVKind
  75898. * - VertexBuffer.UV2Kind
  75899. * - VertexBuffer.UV3Kind
  75900. * - VertexBuffer.UV4Kind
  75901. * - VertexBuffer.UV5Kind
  75902. * - VertexBuffer.UV6Kind
  75903. * - VertexBuffer.ColorKind
  75904. * - VertexBuffer.MatricesIndicesKind
  75905. * - VertexBuffer.MatricesIndicesExtraKind
  75906. * - VertexBuffer.MatricesWeightsKind
  75907. * - VertexBuffer.MatricesWeightsExtraKind
  75908. * @returns a boolean
  75909. */
  75910. isVerticesDataPresent(kind: string): boolean;
  75911. /**
  75912. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75913. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75914. * - VertexBuffer.PositionKind
  75915. * - VertexBuffer.UVKind
  75916. * - VertexBuffer.UV2Kind
  75917. * - VertexBuffer.UV3Kind
  75918. * - VertexBuffer.UV4Kind
  75919. * - VertexBuffer.UV5Kind
  75920. * - VertexBuffer.UV6Kind
  75921. * - VertexBuffer.ColorKind
  75922. * - VertexBuffer.MatricesIndicesKind
  75923. * - VertexBuffer.MatricesIndicesExtraKind
  75924. * - VertexBuffer.MatricesWeightsKind
  75925. * - VertexBuffer.MatricesWeightsExtraKind
  75926. * @returns a boolean
  75927. */
  75928. isVertexBufferUpdatable(kind: string): boolean;
  75929. /**
  75930. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75931. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75932. * - VertexBuffer.PositionKind
  75933. * - VertexBuffer.UVKind
  75934. * - VertexBuffer.UV2Kind
  75935. * - VertexBuffer.UV3Kind
  75936. * - VertexBuffer.UV4Kind
  75937. * - VertexBuffer.UV5Kind
  75938. * - VertexBuffer.UV6Kind
  75939. * - VertexBuffer.ColorKind
  75940. * - VertexBuffer.MatricesIndicesKind
  75941. * - VertexBuffer.MatricesIndicesExtraKind
  75942. * - VertexBuffer.MatricesWeightsKind
  75943. * - VertexBuffer.MatricesWeightsExtraKind
  75944. * @returns an array of strings
  75945. */
  75946. getVerticesDataKinds(): string[];
  75947. /**
  75948. * Returns a positive integer : the total number of indices in this mesh geometry.
  75949. * @returns the numner of indices or zero if the mesh has no geometry.
  75950. */
  75951. getTotalIndices(): number;
  75952. /**
  75953. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75954. * @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.
  75955. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75956. * @returns the indices array or an empty array if the mesh has no geometry
  75957. */
  75958. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75959. readonly isBlocked: boolean;
  75960. /**
  75961. * Determine if the current mesh is ready to be rendered
  75962. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75963. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75964. * @returns true if all associated assets are ready (material, textures, shaders)
  75965. */
  75966. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75967. /**
  75968. * 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.
  75969. */
  75970. readonly areNormalsFrozen: boolean;
  75971. /**
  75972. * 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.
  75973. * @returns the current mesh
  75974. */
  75975. freezeNormals(): Mesh;
  75976. /**
  75977. * 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
  75978. * @returns the current mesh
  75979. */
  75980. unfreezeNormals(): Mesh;
  75981. /**
  75982. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75983. */
  75984. overridenInstanceCount: number;
  75985. /** @hidden */
  75986. _preActivate(): Mesh;
  75987. /** @hidden */
  75988. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75989. /** @hidden */
  75990. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75991. /**
  75992. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75993. * This means the mesh underlying bounding box and sphere are recomputed.
  75994. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75995. * @returns the current mesh
  75996. */
  75997. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75998. /** @hidden */
  75999. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76000. /**
  76001. * This function will subdivide the mesh into multiple submeshes
  76002. * @param count defines the expected number of submeshes
  76003. */
  76004. subdivide(count: number): void;
  76005. /**
  76006. * Copy a FloatArray into a specific associated vertex buffer
  76007. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76008. * - VertexBuffer.PositionKind
  76009. * - VertexBuffer.UVKind
  76010. * - VertexBuffer.UV2Kind
  76011. * - VertexBuffer.UV3Kind
  76012. * - VertexBuffer.UV4Kind
  76013. * - VertexBuffer.UV5Kind
  76014. * - VertexBuffer.UV6Kind
  76015. * - VertexBuffer.ColorKind
  76016. * - VertexBuffer.MatricesIndicesKind
  76017. * - VertexBuffer.MatricesIndicesExtraKind
  76018. * - VertexBuffer.MatricesWeightsKind
  76019. * - VertexBuffer.MatricesWeightsExtraKind
  76020. * @param data defines the data source
  76021. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76022. * @param stride defines the data stride size (can be null)
  76023. * @returns the current mesh
  76024. */
  76025. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76026. /**
  76027. * Flags an associated vertex buffer as updatable
  76028. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76029. * - VertexBuffer.PositionKind
  76030. * - VertexBuffer.UVKind
  76031. * - VertexBuffer.UV2Kind
  76032. * - VertexBuffer.UV3Kind
  76033. * - VertexBuffer.UV4Kind
  76034. * - VertexBuffer.UV5Kind
  76035. * - VertexBuffer.UV6Kind
  76036. * - VertexBuffer.ColorKind
  76037. * - VertexBuffer.MatricesIndicesKind
  76038. * - VertexBuffer.MatricesIndicesExtraKind
  76039. * - VertexBuffer.MatricesWeightsKind
  76040. * - VertexBuffer.MatricesWeightsExtraKind
  76041. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76042. */
  76043. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76044. /**
  76045. * Sets the mesh global Vertex Buffer
  76046. * @param buffer defines the buffer to use
  76047. * @returns the current mesh
  76048. */
  76049. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76050. /**
  76051. * Update a specific associated vertex buffer
  76052. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76053. * - VertexBuffer.PositionKind
  76054. * - VertexBuffer.UVKind
  76055. * - VertexBuffer.UV2Kind
  76056. * - VertexBuffer.UV3Kind
  76057. * - VertexBuffer.UV4Kind
  76058. * - VertexBuffer.UV5Kind
  76059. * - VertexBuffer.UV6Kind
  76060. * - VertexBuffer.ColorKind
  76061. * - VertexBuffer.MatricesIndicesKind
  76062. * - VertexBuffer.MatricesIndicesExtraKind
  76063. * - VertexBuffer.MatricesWeightsKind
  76064. * - VertexBuffer.MatricesWeightsExtraKind
  76065. * @param data defines the data source
  76066. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76067. * @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)
  76068. * @returns the current mesh
  76069. */
  76070. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76071. /**
  76072. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76073. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76074. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76075. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76076. * @returns the current mesh
  76077. */
  76078. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76079. /**
  76080. * Creates a un-shared specific occurence of the geometry for the mesh.
  76081. * @returns the current mesh
  76082. */
  76083. makeGeometryUnique(): Mesh;
  76084. /**
  76085. * Set the index buffer of this mesh
  76086. * @param indices defines the source data
  76087. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76088. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76089. * @returns the current mesh
  76090. */
  76091. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76092. /**
  76093. * Update the current index buffer
  76094. * @param indices defines the source data
  76095. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76096. * @returns the current mesh
  76097. */
  76098. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  76099. /**
  76100. * Invert the geometry to move from a right handed system to a left handed one.
  76101. * @returns the current mesh
  76102. */
  76103. toLeftHanded(): Mesh;
  76104. /** @hidden */
  76105. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76106. /** @hidden */
  76107. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  76108. /**
  76109. * Registers for this mesh a javascript function called just before the rendering process
  76110. * @param func defines the function to call before rendering this mesh
  76111. * @returns the current mesh
  76112. */
  76113. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76114. /**
  76115. * Disposes a previously registered javascript function called before the rendering
  76116. * @param func defines the function to remove
  76117. * @returns the current mesh
  76118. */
  76119. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76120. /**
  76121. * Registers for this mesh a javascript function called just after the rendering is complete
  76122. * @param func defines the function to call after rendering this mesh
  76123. * @returns the current mesh
  76124. */
  76125. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76126. /**
  76127. * Disposes a previously registered javascript function called after the rendering.
  76128. * @param func defines the function to remove
  76129. * @returns the current mesh
  76130. */
  76131. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76132. /** @hidden */
  76133. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76134. /** @hidden */
  76135. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76136. /** @hidden */
  76137. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76138. /**
  76139. * 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
  76140. * @param subMesh defines the subMesh to render
  76141. * @param enableAlphaMode defines if alpha mode can be changed
  76142. * @returns the current mesh
  76143. */
  76144. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  76145. private _onBeforeDraw;
  76146. /**
  76147. * Renormalize the mesh and patch it up if there are no weights
  76148. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  76149. * However in the case of zero weights then we set just a single influence to 1.
  76150. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  76151. */
  76152. cleanMatrixWeights(): void;
  76153. private normalizeSkinFourWeights;
  76154. private normalizeSkinWeightsAndExtra;
  76155. /**
  76156. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  76157. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  76158. * the user know there was an issue with importing the mesh
  76159. * @returns a validation object with skinned, valid and report string
  76160. */
  76161. validateSkinning(): {
  76162. skinned: boolean;
  76163. valid: boolean;
  76164. report: string;
  76165. };
  76166. /** @hidden */
  76167. _checkDelayState(): Mesh;
  76168. private _queueLoad;
  76169. /**
  76170. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  76171. * A mesh is in the frustum if its bounding box intersects the frustum
  76172. * @param frustumPlanes defines the frustum to test
  76173. * @returns true if the mesh is in the frustum planes
  76174. */
  76175. isInFrustum(frustumPlanes: Plane[]): boolean;
  76176. /**
  76177. * Sets the mesh material by the material or multiMaterial `id` property
  76178. * @param id is a string identifying the material or the multiMaterial
  76179. * @returns the current mesh
  76180. */
  76181. setMaterialByID(id: string): Mesh;
  76182. /**
  76183. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  76184. * @returns an array of IAnimatable
  76185. */
  76186. getAnimatables(): IAnimatable[];
  76187. /**
  76188. * Modifies the mesh geometry according to the passed transformation matrix.
  76189. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  76190. * The mesh normals are modified using the same transformation.
  76191. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76192. * @param transform defines the transform matrix to use
  76193. * @see http://doc.babylonjs.com/resources/baking_transformations
  76194. * @returns the current mesh
  76195. */
  76196. bakeTransformIntoVertices(transform: Matrix): Mesh;
  76197. /**
  76198. * Modifies the mesh geometry according to its own current World Matrix.
  76199. * The mesh World Matrix is then reset.
  76200. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  76201. * Note that, under the hood, this method sets a new VertexBuffer each call.
  76202. * @see http://doc.babylonjs.com/resources/baking_transformations
  76203. * @returns the current mesh
  76204. */
  76205. bakeCurrentTransformIntoVertices(): Mesh;
  76206. /** @hidden */
  76207. readonly _positions: Nullable<Vector3[]>;
  76208. /** @hidden */
  76209. _resetPointsArrayCache(): Mesh;
  76210. /** @hidden */
  76211. _generatePointsArray(): boolean;
  76212. /**
  76213. * Returns a new Mesh object generated from the current mesh properties.
  76214. * This method must not get confused with createInstance()
  76215. * @param name is a string, the name given to the new mesh
  76216. * @param newParent can be any Node object (default `null`)
  76217. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  76218. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  76219. * @returns a new mesh
  76220. */
  76221. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  76222. /**
  76223. * Releases resources associated with this mesh.
  76224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76226. */
  76227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76228. /**
  76229. * Modifies the mesh geometry according to a displacement map.
  76230. * 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.
  76231. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76232. * @param url is a string, the URL from the image file is to be downloaded.
  76233. * @param minHeight is the lower limit of the displacement.
  76234. * @param maxHeight is the upper limit of the displacement.
  76235. * @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.
  76236. * @param uvOffset is an optional vector2 used to offset UV.
  76237. * @param uvScale is an optional vector2 used to scale UV.
  76238. * @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.
  76239. * @returns the Mesh.
  76240. */
  76241. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76242. /**
  76243. * Modifies the mesh geometry according to a displacementMap buffer.
  76244. * 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.
  76245. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76246. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  76247. * @param heightMapWidth is the width of the buffer image.
  76248. * @param heightMapHeight is the height of the buffer image.
  76249. * @param minHeight is the lower limit of the displacement.
  76250. * @param maxHeight is the upper limit of the displacement.
  76251. * @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.
  76252. * @param uvOffset is an optional vector2 used to offset UV.
  76253. * @param uvScale is an optional vector2 used to scale UV.
  76254. * @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.
  76255. * @returns the Mesh.
  76256. */
  76257. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76258. /**
  76259. * Modify the mesh to get a flat shading rendering.
  76260. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  76261. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  76262. * @returns current mesh
  76263. */
  76264. convertToFlatShadedMesh(): Mesh;
  76265. /**
  76266. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  76267. * In other words, more vertices, no more indices and a single bigger VBO.
  76268. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  76269. * @returns current mesh
  76270. */
  76271. convertToUnIndexedMesh(): Mesh;
  76272. /**
  76273. * Inverses facet orientations.
  76274. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  76275. * @param flipNormals will also inverts the normals
  76276. * @returns current mesh
  76277. */
  76278. flipFaces(flipNormals?: boolean): Mesh;
  76279. /** @hidden */
  76280. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  76281. /** @hidden */
  76282. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  76283. /**
  76284. * Creates a new InstancedMesh object from the mesh model.
  76285. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76286. * @param name defines the name of the new instance
  76287. * @returns a new InstancedMesh
  76288. */
  76289. createInstance(name: string): InstancedMesh;
  76290. /**
  76291. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  76292. * After this call, all the mesh instances have the same submeshes than the current mesh.
  76293. * @returns the current mesh
  76294. */
  76295. synchronizeInstances(): Mesh;
  76296. /**
  76297. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  76298. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  76299. * This should be used together with the simplification to avoid disappearing triangles.
  76300. * @param successCallback an optional success callback to be called after the optimization finished.
  76301. * @returns the current mesh
  76302. */
  76303. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  76304. /**
  76305. * Serialize current mesh
  76306. * @param serializationObject defines the object which will receive the serialization data
  76307. */
  76308. serialize(serializationObject: any): void;
  76309. /** @hidden */
  76310. _syncGeometryWithMorphTargetManager(): void;
  76311. /** @hidden */
  76312. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  76313. /**
  76314. * Returns a new Mesh object parsed from the source provided.
  76315. * @param parsedMesh is the source
  76316. * @param scene defines the hosting scene
  76317. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  76318. * @returns a new Mesh
  76319. */
  76320. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  76321. /**
  76322. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  76323. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76324. * @param name defines the name of the mesh to create
  76325. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  76326. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  76327. * @param closePath creates a seam between the first and the last points of each path of the path array
  76328. * @param offset is taken in account only if the `pathArray` is containing a single path
  76329. * @param scene defines the hosting scene
  76330. * @param updatable defines if the mesh must be flagged as updatable
  76331. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76332. * @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)
  76333. * @returns a new Mesh
  76334. */
  76335. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76336. /**
  76337. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  76338. * @param name defines the name of the mesh to create
  76339. * @param radius sets the radius size (float) of the polygon (default 0.5)
  76340. * @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
  76341. * @param scene defines the hosting scene
  76342. * @param updatable defines if the mesh must be flagged as updatable
  76343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76344. * @returns a new Mesh
  76345. */
  76346. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76347. /**
  76348. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  76349. * @param name defines the name of the mesh to create
  76350. * @param size sets the size (float) of each box side (default 1)
  76351. * @param scene defines the hosting scene
  76352. * @param updatable defines if the mesh must be flagged as updatable
  76353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76354. * @returns a new Mesh
  76355. */
  76356. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76357. /**
  76358. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  76359. * @param name defines the name of the mesh to create
  76360. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  76361. * @param diameter sets the diameter size (float) of the sphere (default 1)
  76362. * @param scene defines the hosting scene
  76363. * @param updatable defines if the mesh must be flagged as updatable
  76364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76365. * @returns a new Mesh
  76366. */
  76367. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76368. /**
  76369. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  76370. * @param name defines the name of the mesh to create
  76371. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  76372. * @param diameterTop set the top cap diameter (floats, default 1)
  76373. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  76374. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  76375. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  76376. * @param scene defines the hosting scene
  76377. * @param updatable defines if the mesh must be flagged as updatable
  76378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76379. * @returns a new Mesh
  76380. */
  76381. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  76382. /**
  76383. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  76384. * @param name defines the name of the mesh to create
  76385. * @param diameter sets the diameter size (float) of the torus (default 1)
  76386. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  76387. * @param tessellation sets the number of torus sides (postive integer, default 16)
  76388. * @param scene defines the hosting scene
  76389. * @param updatable defines if the mesh must be flagged as updatable
  76390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76391. * @returns a new Mesh
  76392. */
  76393. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76394. /**
  76395. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  76396. * @param name defines the name of the mesh to create
  76397. * @param radius sets the global radius size (float) of the torus knot (default 2)
  76398. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  76399. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  76400. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  76401. * @param p the number of windings on X axis (positive integers, default 2)
  76402. * @param q the number of windings on Y axis (positive integers, default 3)
  76403. * @param scene defines the hosting scene
  76404. * @param updatable defines if the mesh must be flagged as updatable
  76405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76406. * @returns a new Mesh
  76407. */
  76408. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76409. /**
  76410. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  76411. * @param name defines the name of the mesh to create
  76412. * @param points is an array successive Vector3
  76413. * @param scene defines the hosting scene
  76414. * @param updatable defines if the mesh must be flagged as updatable
  76415. * @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).
  76416. * @returns a new Mesh
  76417. */
  76418. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  76419. /**
  76420. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  76421. * @param name defines the name of the mesh to create
  76422. * @param points is an array successive Vector3
  76423. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  76424. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76425. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  76426. * @param scene defines the hosting scene
  76427. * @param updatable defines if the mesh must be flagged as updatable
  76428. * @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)
  76429. * @returns a new Mesh
  76430. */
  76431. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  76432. /**
  76433. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  76434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  76435. * 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.
  76436. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76438. * Remember you can only change the shape positions, not their number when updating a polygon.
  76439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  76440. * @param name defines the name of the mesh to create
  76441. * @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
  76442. * @param scene defines the hosting scene
  76443. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76444. * @param updatable defines if the mesh must be flagged as updatable
  76445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76446. * @param earcutInjection can be used to inject your own earcut reference
  76447. * @returns a new Mesh
  76448. */
  76449. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76450. /**
  76451. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  76452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  76453. * @param name defines the name of the mesh to create
  76454. * @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
  76455. * @param depth defines the height of extrusion
  76456. * @param scene defines the hosting scene
  76457. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76458. * @param updatable defines if the mesh must be flagged as updatable
  76459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76460. * @param earcutInjection can be used to inject your own earcut reference
  76461. * @returns a new Mesh
  76462. */
  76463. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76464. /**
  76465. * Creates an extruded shape mesh.
  76466. * 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
  76467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76468. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76469. * @param name defines the name of the mesh to create
  76470. * @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
  76471. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76472. * @param scale is the value to scale the shape
  76473. * @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
  76474. * @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
  76475. * @param scene defines the hosting scene
  76476. * @param updatable defines if the mesh must be flagged as updatable
  76477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76478. * @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)
  76479. * @returns a new Mesh
  76480. */
  76481. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76482. /**
  76483. * Creates an custom extruded shape mesh.
  76484. * The custom extrusion is a parametric shape.
  76485. * It has no predefined shape. Its final shape will depend on the input parameters.
  76486. * Please consider using the same method from the MeshBuilder class instead
  76487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76488. * @param name defines the name of the mesh to create
  76489. * @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
  76490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76491. * @param scaleFunction is a custom Javascript function called on each path point
  76492. * @param rotationFunction is a custom Javascript function called on each path point
  76493. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  76494. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  76495. * @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
  76496. * @param scene defines the hosting scene
  76497. * @param updatable defines if the mesh must be flagged as updatable
  76498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76499. * @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)
  76500. * @returns a new Mesh
  76501. */
  76502. 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;
  76503. /**
  76504. * Creates lathe mesh.
  76505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  76506. * Please consider using the same method from the MeshBuilder class instead
  76507. * @param name defines the name of the mesh to create
  76508. * @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
  76509. * @param radius is the radius value of the lathe
  76510. * @param tessellation is the side number of the lathe.
  76511. * @param scene defines the hosting scene
  76512. * @param updatable defines if the mesh must be flagged as updatable
  76513. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76514. * @returns a new Mesh
  76515. */
  76516. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76517. /**
  76518. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  76519. * @param name defines the name of the mesh to create
  76520. * @param size sets the size (float) of both sides of the plane at once (default 1)
  76521. * @param scene defines the hosting scene
  76522. * @param updatable defines if the mesh must be flagged as updatable
  76523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76524. * @returns a new Mesh
  76525. */
  76526. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76527. /**
  76528. * Creates a ground mesh.
  76529. * Please consider using the same method from the MeshBuilder class instead
  76530. * @param name defines the name of the mesh to create
  76531. * @param width set the width of the ground
  76532. * @param height set the height of the ground
  76533. * @param subdivisions sets the number of subdivisions per side
  76534. * @param scene defines the hosting scene
  76535. * @param updatable defines if the mesh must be flagged as updatable
  76536. * @returns a new Mesh
  76537. */
  76538. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  76539. /**
  76540. * Creates a tiled ground mesh.
  76541. * Please consider using the same method from the MeshBuilder class instead
  76542. * @param name defines the name of the mesh to create
  76543. * @param xmin set the ground minimum X coordinate
  76544. * @param zmin set the ground minimum Y coordinate
  76545. * @param xmax set the ground maximum X coordinate
  76546. * @param zmax set the ground maximum Z coordinate
  76547. * @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
  76548. * @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
  76549. * @param scene defines the hosting scene
  76550. * @param updatable defines if the mesh must be flagged as updatable
  76551. * @returns a new Mesh
  76552. */
  76553. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  76554. w: number;
  76555. h: number;
  76556. }, precision: {
  76557. w: number;
  76558. h: number;
  76559. }, scene: Scene, updatable?: boolean): Mesh;
  76560. /**
  76561. * Creates a ground mesh from a height map.
  76562. * Please consider using the same method from the MeshBuilder class instead
  76563. * @see http://doc.babylonjs.com/babylon101/height_map
  76564. * @param name defines the name of the mesh to create
  76565. * @param url sets the URL of the height map image resource
  76566. * @param width set the ground width size
  76567. * @param height set the ground height size
  76568. * @param subdivisions sets the number of subdivision per side
  76569. * @param minHeight is the minimum altitude on the ground
  76570. * @param maxHeight is the maximum altitude on the ground
  76571. * @param scene defines the hosting scene
  76572. * @param updatable defines if the mesh must be flagged as updatable
  76573. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  76574. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  76575. * @returns a new Mesh
  76576. */
  76577. 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;
  76578. /**
  76579. * Creates a tube mesh.
  76580. * The tube is a parametric shape.
  76581. * It has no predefined shape. Its final shape will depend on the input parameters.
  76582. * Please consider using the same method from the MeshBuilder class instead
  76583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76584. * @param name defines the name of the mesh to create
  76585. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  76586. * @param radius sets the tube radius size
  76587. * @param tessellation is the number of sides on the tubular surface
  76588. * @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
  76589. * @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
  76590. * @param scene defines the hosting scene
  76591. * @param updatable defines if the mesh must be flagged as updatable
  76592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76593. * @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)
  76594. * @returns a new Mesh
  76595. */
  76596. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  76597. (i: number, distance: number): number;
  76598. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76599. /**
  76600. * Creates a polyhedron mesh.
  76601. * Please consider using the same method from the MeshBuilder class instead.
  76602. * * 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
  76603. * * The parameter `size` (positive float, default 1) sets the polygon size
  76604. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76605. * * 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`
  76606. * * 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
  76607. * * 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)`)
  76608. * * 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
  76609. * * 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
  76610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76611. * * If you create a double-sided mesh, you can choose what parts of 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
  76612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76613. * @param name defines the name of the mesh to create
  76614. * @param options defines the options used to create the mesh
  76615. * @param scene defines the hosting scene
  76616. * @returns a new Mesh
  76617. */
  76618. static CreatePolyhedron(name: string, options: {
  76619. type?: number;
  76620. size?: number;
  76621. sizeX?: number;
  76622. sizeY?: number;
  76623. sizeZ?: number;
  76624. custom?: any;
  76625. faceUV?: Vector4[];
  76626. faceColors?: Color4[];
  76627. updatable?: boolean;
  76628. sideOrientation?: number;
  76629. }, scene: Scene): Mesh;
  76630. /**
  76631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76633. * * 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`)
  76634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76635. * * 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
  76636. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76637. * * If you create a double-sided mesh, you can choose what parts of 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
  76638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76639. * @param name defines the name of the mesh
  76640. * @param options defines the options used to create the mesh
  76641. * @param scene defines the hosting scene
  76642. * @returns a new Mesh
  76643. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76644. */
  76645. static CreateIcoSphere(name: string, options: {
  76646. radius?: number;
  76647. flat?: boolean;
  76648. subdivisions?: number;
  76649. sideOrientation?: number;
  76650. updatable?: boolean;
  76651. }, scene: Scene): Mesh;
  76652. /**
  76653. * Creates a decal mesh.
  76654. * Please consider using the same method from the MeshBuilder class instead.
  76655. * A decal is a mesh usually applied as a model onto the surface of another mesh
  76656. * @param name defines the name of the mesh
  76657. * @param sourceMesh defines the mesh receiving the decal
  76658. * @param position sets the position of the decal in world coordinates
  76659. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  76660. * @param size sets the decal scaling
  76661. * @param angle sets the angle to rotate the decal
  76662. * @returns a new Mesh
  76663. */
  76664. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  76665. /**
  76666. * Prepare internal position array for software CPU skinning
  76667. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  76668. */
  76669. setPositionsForCPUSkinning(): Float32Array;
  76670. /**
  76671. * Prepare internal normal array for software CPU skinning
  76672. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  76673. */
  76674. setNormalsForCPUSkinning(): Float32Array;
  76675. /**
  76676. * Updates the vertex buffer by applying transformation from the bones
  76677. * @param skeleton defines the skeleton to apply to current mesh
  76678. * @returns the current mesh
  76679. */
  76680. applySkeleton(skeleton: Skeleton): Mesh;
  76681. /**
  76682. * 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
  76683. * @param meshes defines the list of meshes to scan
  76684. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  76685. */
  76686. static MinMax(meshes: AbstractMesh[]): {
  76687. min: Vector3;
  76688. max: Vector3;
  76689. };
  76690. /**
  76691. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  76692. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  76693. * @returns a vector3
  76694. */
  76695. static Center(meshesOrMinMaxVector: {
  76696. min: Vector3;
  76697. max: Vector3;
  76698. } | AbstractMesh[]): Vector3;
  76699. /**
  76700. * Merge the array of meshes into a single mesh for performance reasons.
  76701. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  76702. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  76703. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  76704. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  76705. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  76706. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  76707. * @returns a new mesh
  76708. */
  76709. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  76710. /** @hidden */
  76711. addInstance(instance: InstancedMesh): void;
  76712. /** @hidden */
  76713. removeInstance(instance: InstancedMesh): void;
  76714. }
  76715. }
  76716. declare module BABYLON {
  76717. /**
  76718. * Base class for the main features of a material in Babylon.js
  76719. */
  76720. export class Material implements IAnimatable {
  76721. /**
  76722. * Returns the triangle fill mode
  76723. */
  76724. static readonly TriangleFillMode: number;
  76725. /**
  76726. * Returns the wireframe mode
  76727. */
  76728. static readonly WireFrameFillMode: number;
  76729. /**
  76730. * Returns the point fill mode
  76731. */
  76732. static readonly PointFillMode: number;
  76733. /**
  76734. * Returns the point list draw mode
  76735. */
  76736. static readonly PointListDrawMode: number;
  76737. /**
  76738. * Returns the line list draw mode
  76739. */
  76740. static readonly LineListDrawMode: number;
  76741. /**
  76742. * Returns the line loop draw mode
  76743. */
  76744. static readonly LineLoopDrawMode: number;
  76745. /**
  76746. * Returns the line strip draw mode
  76747. */
  76748. static readonly LineStripDrawMode: number;
  76749. /**
  76750. * Returns the triangle strip draw mode
  76751. */
  76752. static readonly TriangleStripDrawMode: number;
  76753. /**
  76754. * Returns the triangle fan draw mode
  76755. */
  76756. static readonly TriangleFanDrawMode: number;
  76757. /**
  76758. * Stores the clock-wise side orientation
  76759. */
  76760. static readonly ClockWiseSideOrientation: number;
  76761. /**
  76762. * Stores the counter clock-wise side orientation
  76763. */
  76764. static readonly CounterClockWiseSideOrientation: number;
  76765. /**
  76766. * The dirty texture flag value
  76767. */
  76768. static readonly TextureDirtyFlag: number;
  76769. /**
  76770. * The dirty light flag value
  76771. */
  76772. static readonly LightDirtyFlag: number;
  76773. /**
  76774. * The dirty fresnel flag value
  76775. */
  76776. static readonly FresnelDirtyFlag: number;
  76777. /**
  76778. * The dirty attribute flag value
  76779. */
  76780. static readonly AttributesDirtyFlag: number;
  76781. /**
  76782. * The dirty misc flag value
  76783. */
  76784. static readonly MiscDirtyFlag: number;
  76785. /**
  76786. * The all dirty flag value
  76787. */
  76788. static readonly AllDirtyFlag: number;
  76789. /**
  76790. * The ID of the material
  76791. */
  76792. id: string;
  76793. /**
  76794. * Gets or sets the unique id of the material
  76795. */
  76796. uniqueId: number;
  76797. /**
  76798. * The name of the material
  76799. */
  76800. name: string;
  76801. /**
  76802. * Gets or sets user defined metadata
  76803. */
  76804. metadata: any;
  76805. /**
  76806. * For internal use only. Please do not use.
  76807. */
  76808. reservedDataStore: any;
  76809. /**
  76810. * Specifies if the ready state should be checked on each call
  76811. */
  76812. checkReadyOnEveryCall: boolean;
  76813. /**
  76814. * Specifies if the ready state should be checked once
  76815. */
  76816. checkReadyOnlyOnce: boolean;
  76817. /**
  76818. * The state of the material
  76819. */
  76820. state: string;
  76821. /**
  76822. * The alpha value of the material
  76823. */
  76824. protected _alpha: number;
  76825. /**
  76826. * Sets the alpha value of the material
  76827. */
  76828. /**
  76829. * Gets the alpha value of the material
  76830. */
  76831. alpha: number;
  76832. /**
  76833. * Specifies if back face culling is enabled
  76834. */
  76835. protected _backFaceCulling: boolean;
  76836. /**
  76837. * Sets the back-face culling state
  76838. */
  76839. /**
  76840. * Gets the back-face culling state
  76841. */
  76842. backFaceCulling: boolean;
  76843. /**
  76844. * Stores the value for side orientation
  76845. */
  76846. sideOrientation: number;
  76847. /**
  76848. * Callback triggered when the material is compiled
  76849. */
  76850. onCompiled: (effect: Effect) => void;
  76851. /**
  76852. * Callback triggered when an error occurs
  76853. */
  76854. onError: (effect: Effect, errors: string) => void;
  76855. /**
  76856. * Callback triggered to get the render target textures
  76857. */
  76858. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  76859. /**
  76860. * Gets a boolean indicating that current material needs to register RTT
  76861. */
  76862. readonly hasRenderTargetTextures: boolean;
  76863. /**
  76864. * Specifies if the material should be serialized
  76865. */
  76866. doNotSerialize: boolean;
  76867. /**
  76868. * @hidden
  76869. */
  76870. _storeEffectOnSubMeshes: boolean;
  76871. /**
  76872. * Stores the animations for the material
  76873. */
  76874. animations: Array<Animation>;
  76875. /**
  76876. * An event triggered when the material is disposed
  76877. */
  76878. onDisposeObservable: Observable<Material>;
  76879. /**
  76880. * An observer which watches for dispose events
  76881. */
  76882. private _onDisposeObserver;
  76883. private _onUnBindObservable;
  76884. /**
  76885. * Called during a dispose event
  76886. */
  76887. onDispose: () => void;
  76888. private _onBindObservable;
  76889. /**
  76890. * An event triggered when the material is bound
  76891. */
  76892. readonly onBindObservable: Observable<AbstractMesh>;
  76893. /**
  76894. * An observer which watches for bind events
  76895. */
  76896. private _onBindObserver;
  76897. /**
  76898. * Called during a bind event
  76899. */
  76900. onBind: (Mesh: AbstractMesh) => void;
  76901. /**
  76902. * An event triggered when the material is unbound
  76903. */
  76904. readonly onUnBindObservable: Observable<Material>;
  76905. /**
  76906. * Stores the value of the alpha mode
  76907. */
  76908. private _alphaMode;
  76909. /**
  76910. * Sets the value of the alpha mode.
  76911. *
  76912. * | Value | Type | Description |
  76913. * | --- | --- | --- |
  76914. * | 0 | ALPHA_DISABLE | |
  76915. * | 1 | ALPHA_ADD | |
  76916. * | 2 | ALPHA_COMBINE | |
  76917. * | 3 | ALPHA_SUBTRACT | |
  76918. * | 4 | ALPHA_MULTIPLY | |
  76919. * | 5 | ALPHA_MAXIMIZED | |
  76920. * | 6 | ALPHA_ONEONE | |
  76921. * | 7 | ALPHA_PREMULTIPLIED | |
  76922. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  76923. * | 9 | ALPHA_INTERPOLATE | |
  76924. * | 10 | ALPHA_SCREENMODE | |
  76925. *
  76926. */
  76927. /**
  76928. * Gets the value of the alpha mode
  76929. */
  76930. alphaMode: number;
  76931. /**
  76932. * Stores the state of the need depth pre-pass value
  76933. */
  76934. private _needDepthPrePass;
  76935. /**
  76936. * Sets the need depth pre-pass value
  76937. */
  76938. /**
  76939. * Gets the depth pre-pass value
  76940. */
  76941. needDepthPrePass: boolean;
  76942. /**
  76943. * Specifies if depth writing should be disabled
  76944. */
  76945. disableDepthWrite: boolean;
  76946. /**
  76947. * Specifies if depth writing should be forced
  76948. */
  76949. forceDepthWrite: boolean;
  76950. /**
  76951. * Specifies if there should be a separate pass for culling
  76952. */
  76953. separateCullingPass: boolean;
  76954. /**
  76955. * Stores the state specifing if fog should be enabled
  76956. */
  76957. private _fogEnabled;
  76958. /**
  76959. * Sets the state for enabling fog
  76960. */
  76961. /**
  76962. * Gets the value of the fog enabled state
  76963. */
  76964. fogEnabled: boolean;
  76965. /**
  76966. * Stores the size of points
  76967. */
  76968. pointSize: number;
  76969. /**
  76970. * Stores the z offset value
  76971. */
  76972. zOffset: number;
  76973. /**
  76974. * Gets a value specifying if wireframe mode is enabled
  76975. */
  76976. /**
  76977. * Sets the state of wireframe mode
  76978. */
  76979. wireframe: boolean;
  76980. /**
  76981. * Gets the value specifying if point clouds are enabled
  76982. */
  76983. /**
  76984. * Sets the state of point cloud mode
  76985. */
  76986. pointsCloud: boolean;
  76987. /**
  76988. * Gets the material fill mode
  76989. */
  76990. /**
  76991. * Sets the material fill mode
  76992. */
  76993. fillMode: number;
  76994. /**
  76995. * @hidden
  76996. * Stores the effects for the material
  76997. */
  76998. _effect: Nullable<Effect>;
  76999. /**
  77000. * @hidden
  77001. * Specifies if the material was previously ready
  77002. */
  77003. _wasPreviouslyReady: boolean;
  77004. /**
  77005. * Specifies if uniform buffers should be used
  77006. */
  77007. private _useUBO;
  77008. /**
  77009. * Stores a reference to the scene
  77010. */
  77011. private _scene;
  77012. /**
  77013. * Stores the fill mode state
  77014. */
  77015. private _fillMode;
  77016. /**
  77017. * Specifies if the depth write state should be cached
  77018. */
  77019. private _cachedDepthWriteState;
  77020. /**
  77021. * Stores the uniform buffer
  77022. */
  77023. protected _uniformBuffer: UniformBuffer;
  77024. /** @hidden */
  77025. _indexInSceneMaterialArray: number;
  77026. /** @hidden */
  77027. meshMap: Nullable<{
  77028. [id: string]: AbstractMesh | undefined;
  77029. }>;
  77030. /**
  77031. * Creates a material instance
  77032. * @param name defines the name of the material
  77033. * @param scene defines the scene to reference
  77034. * @param doNotAdd specifies if the material should be added to the scene
  77035. */
  77036. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  77037. /**
  77038. * Returns a string representation of the current material
  77039. * @param fullDetails defines a boolean indicating which levels of logging is desired
  77040. * @returns a string with material information
  77041. */
  77042. toString(fullDetails?: boolean): string;
  77043. /**
  77044. * Gets the class name of the material
  77045. * @returns a string with the class name of the material
  77046. */
  77047. getClassName(): string;
  77048. /**
  77049. * Specifies if updates for the material been locked
  77050. */
  77051. readonly isFrozen: boolean;
  77052. /**
  77053. * Locks updates for the material
  77054. */
  77055. freeze(): void;
  77056. /**
  77057. * Unlocks updates for the material
  77058. */
  77059. unfreeze(): void;
  77060. /**
  77061. * Specifies if the material is ready to be used
  77062. * @param mesh defines the mesh to check
  77063. * @param useInstances specifies if instances should be used
  77064. * @returns a boolean indicating if the material is ready to be used
  77065. */
  77066. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77067. /**
  77068. * Specifies that the submesh is ready to be used
  77069. * @param mesh defines the mesh to check
  77070. * @param subMesh defines which submesh to check
  77071. * @param useInstances specifies that instances should be used
  77072. * @returns a boolean indicating that the submesh is ready or not
  77073. */
  77074. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77075. /**
  77076. * Returns the material effect
  77077. * @returns the effect associated with the material
  77078. */
  77079. getEffect(): Nullable<Effect>;
  77080. /**
  77081. * Returns the current scene
  77082. * @returns a Scene
  77083. */
  77084. getScene(): Scene;
  77085. /**
  77086. * Specifies if the material will require alpha blending
  77087. * @returns a boolean specifying if alpha blending is needed
  77088. */
  77089. needAlphaBlending(): boolean;
  77090. /**
  77091. * Specifies if the mesh will require alpha blending
  77092. * @param mesh defines the mesh to check
  77093. * @returns a boolean specifying if alpha blending is needed for the mesh
  77094. */
  77095. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  77096. /**
  77097. * Specifies if this material should be rendered in alpha test mode
  77098. * @returns a boolean specifying if an alpha test is needed.
  77099. */
  77100. needAlphaTesting(): boolean;
  77101. /**
  77102. * Gets the texture used for the alpha test
  77103. * @returns the texture to use for alpha testing
  77104. */
  77105. getAlphaTestTexture(): Nullable<BaseTexture>;
  77106. /**
  77107. * Marks the material to indicate that it needs to be re-calculated
  77108. */
  77109. markDirty(): void;
  77110. /** @hidden */
  77111. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  77112. /**
  77113. * Binds the material to the mesh
  77114. * @param world defines the world transformation matrix
  77115. * @param mesh defines the mesh to bind the material to
  77116. */
  77117. bind(world: Matrix, mesh?: Mesh): void;
  77118. /**
  77119. * Binds the submesh to the material
  77120. * @param world defines the world transformation matrix
  77121. * @param mesh defines the mesh containing the submesh
  77122. * @param subMesh defines the submesh to bind the material to
  77123. */
  77124. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  77125. /**
  77126. * Binds the world matrix to the material
  77127. * @param world defines the world transformation matrix
  77128. */
  77129. bindOnlyWorldMatrix(world: Matrix): void;
  77130. /**
  77131. * Binds the scene's uniform buffer to the effect.
  77132. * @param effect defines the effect to bind to the scene uniform buffer
  77133. * @param sceneUbo defines the uniform buffer storing scene data
  77134. */
  77135. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  77136. /**
  77137. * Binds the view matrix to the effect
  77138. * @param effect defines the effect to bind the view matrix to
  77139. */
  77140. bindView(effect: Effect): void;
  77141. /**
  77142. * Binds the view projection matrix to the effect
  77143. * @param effect defines the effect to bind the view projection matrix to
  77144. */
  77145. bindViewProjection(effect: Effect): void;
  77146. /**
  77147. * Specifies if material alpha testing should be turned on for the mesh
  77148. * @param mesh defines the mesh to check
  77149. */
  77150. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  77151. /**
  77152. * Processes to execute after binding the material to a mesh
  77153. * @param mesh defines the rendered mesh
  77154. */
  77155. protected _afterBind(mesh?: Mesh): void;
  77156. /**
  77157. * Unbinds the material from the mesh
  77158. */
  77159. unbind(): void;
  77160. /**
  77161. * Gets the active textures from the material
  77162. * @returns an array of textures
  77163. */
  77164. getActiveTextures(): BaseTexture[];
  77165. /**
  77166. * Specifies if the material uses a texture
  77167. * @param texture defines the texture to check against the material
  77168. * @returns a boolean specifying if the material uses the texture
  77169. */
  77170. hasTexture(texture: BaseTexture): boolean;
  77171. /**
  77172. * Makes a duplicate of the material, and gives it a new name
  77173. * @param name defines the new name for the duplicated material
  77174. * @returns the cloned material
  77175. */
  77176. clone(name: string): Nullable<Material>;
  77177. /**
  77178. * Gets the meshes bound to the material
  77179. * @returns an array of meshes bound to the material
  77180. */
  77181. getBindedMeshes(): AbstractMesh[];
  77182. /**
  77183. * Force shader compilation
  77184. * @param mesh defines the mesh associated with this material
  77185. * @param onCompiled defines a function to execute once the material is compiled
  77186. * @param options defines the options to configure the compilation
  77187. */
  77188. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  77189. clipPlane: boolean;
  77190. }>): void;
  77191. /**
  77192. * Force shader compilation
  77193. * @param mesh defines the mesh that will use this material
  77194. * @param options defines additional options for compiling the shaders
  77195. * @returns a promise that resolves when the compilation completes
  77196. */
  77197. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  77198. clipPlane: boolean;
  77199. }>): Promise<void>;
  77200. private static readonly _ImageProcessingDirtyCallBack;
  77201. private static readonly _TextureDirtyCallBack;
  77202. private static readonly _FresnelDirtyCallBack;
  77203. private static readonly _MiscDirtyCallBack;
  77204. private static readonly _LightsDirtyCallBack;
  77205. private static readonly _AttributeDirtyCallBack;
  77206. private static _FresnelAndMiscDirtyCallBack;
  77207. private static _TextureAndMiscDirtyCallBack;
  77208. private static readonly _DirtyCallbackArray;
  77209. private static readonly _RunDirtyCallBacks;
  77210. /**
  77211. * Marks a define in the material to indicate that it needs to be re-computed
  77212. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  77213. */
  77214. markAsDirty(flag: number): void;
  77215. /**
  77216. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  77217. * @param func defines a function which checks material defines against the submeshes
  77218. */
  77219. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  77220. /**
  77221. * Indicates that image processing needs to be re-calculated for all submeshes
  77222. */
  77223. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  77224. /**
  77225. * Indicates that textures need to be re-calculated for all submeshes
  77226. */
  77227. protected _markAllSubMeshesAsTexturesDirty(): void;
  77228. /**
  77229. * Indicates that fresnel needs to be re-calculated for all submeshes
  77230. */
  77231. protected _markAllSubMeshesAsFresnelDirty(): void;
  77232. /**
  77233. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  77234. */
  77235. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  77236. /**
  77237. * Indicates that lights need to be re-calculated for all submeshes
  77238. */
  77239. protected _markAllSubMeshesAsLightsDirty(): void;
  77240. /**
  77241. * Indicates that attributes need to be re-calculated for all submeshes
  77242. */
  77243. protected _markAllSubMeshesAsAttributesDirty(): void;
  77244. /**
  77245. * Indicates that misc needs to be re-calculated for all submeshes
  77246. */
  77247. protected _markAllSubMeshesAsMiscDirty(): void;
  77248. /**
  77249. * Indicates that textures and misc need to be re-calculated for all submeshes
  77250. */
  77251. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  77252. /**
  77253. * Disposes the material
  77254. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77255. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77256. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77257. */
  77258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77259. /** @hidden */
  77260. private releaseVertexArrayObject;
  77261. /**
  77262. * Serializes this material
  77263. * @returns the serialized material object
  77264. */
  77265. serialize(): any;
  77266. /**
  77267. * Creates a material from parsed material data
  77268. * @param parsedMaterial defines parsed material data
  77269. * @param scene defines the hosting scene
  77270. * @param rootUrl defines the root URL to use to load textures
  77271. * @returns a new material
  77272. */
  77273. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  77274. }
  77275. }
  77276. declare module BABYLON {
  77277. /**
  77278. * Base class for submeshes
  77279. */
  77280. export class BaseSubMesh {
  77281. /** @hidden */
  77282. _materialDefines: Nullable<MaterialDefines>;
  77283. /** @hidden */
  77284. _materialEffect: Nullable<Effect>;
  77285. /**
  77286. * Gets associated effect
  77287. */
  77288. readonly effect: Nullable<Effect>;
  77289. /**
  77290. * Sets associated effect (effect used to render this submesh)
  77291. * @param effect defines the effect to associate with
  77292. * @param defines defines the set of defines used to compile this effect
  77293. */
  77294. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77295. }
  77296. /**
  77297. * Defines a subdivision inside a mesh
  77298. */
  77299. export class SubMesh extends BaseSubMesh implements ICullable {
  77300. /** the material index to use */
  77301. materialIndex: number;
  77302. /** vertex index start */
  77303. verticesStart: number;
  77304. /** vertices count */
  77305. verticesCount: number;
  77306. /** index start */
  77307. indexStart: number;
  77308. /** indices count */
  77309. indexCount: number;
  77310. /** @hidden */
  77311. _linesIndexCount: number;
  77312. private _mesh;
  77313. private _renderingMesh;
  77314. private _boundingInfo;
  77315. private _linesIndexBuffer;
  77316. /** @hidden */
  77317. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77318. /** @hidden */
  77319. _trianglePlanes: Plane[];
  77320. /** @hidden */
  77321. _lastColliderTransformMatrix: Matrix;
  77322. /** @hidden */
  77323. _renderId: number;
  77324. /** @hidden */
  77325. _alphaIndex: number;
  77326. /** @hidden */
  77327. _distanceToCamera: number;
  77328. /** @hidden */
  77329. _id: number;
  77330. private _currentMaterial;
  77331. /**
  77332. * Add a new submesh to a mesh
  77333. * @param materialIndex defines the material index to use
  77334. * @param verticesStart defines vertex index start
  77335. * @param verticesCount defines vertices count
  77336. * @param indexStart defines index start
  77337. * @param indexCount defines indices count
  77338. * @param mesh defines the parent mesh
  77339. * @param renderingMesh defines an optional rendering mesh
  77340. * @param createBoundingBox defines if bounding box should be created for this submesh
  77341. * @returns the new submesh
  77342. */
  77343. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77344. /**
  77345. * Creates a new submesh
  77346. * @param materialIndex defines the material index to use
  77347. * @param verticesStart defines vertex index start
  77348. * @param verticesCount defines vertices count
  77349. * @param indexStart defines index start
  77350. * @param indexCount defines indices count
  77351. * @param mesh defines the parent mesh
  77352. * @param renderingMesh defines an optional rendering mesh
  77353. * @param createBoundingBox defines if bounding box should be created for this submesh
  77354. */
  77355. constructor(
  77356. /** the material index to use */
  77357. materialIndex: number,
  77358. /** vertex index start */
  77359. verticesStart: number,
  77360. /** vertices count */
  77361. verticesCount: number,
  77362. /** index start */
  77363. indexStart: number,
  77364. /** indices count */
  77365. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77366. /**
  77367. * Returns true if this submesh covers the entire parent mesh
  77368. * @ignorenaming
  77369. */
  77370. readonly IsGlobal: boolean;
  77371. /**
  77372. * Returns the submesh BoudingInfo object
  77373. * @returns current bounding info (or mesh's one if the submesh is global)
  77374. */
  77375. getBoundingInfo(): BoundingInfo;
  77376. /**
  77377. * Sets the submesh BoundingInfo
  77378. * @param boundingInfo defines the new bounding info to use
  77379. * @returns the SubMesh
  77380. */
  77381. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77382. /**
  77383. * Returns the mesh of the current submesh
  77384. * @return the parent mesh
  77385. */
  77386. getMesh(): AbstractMesh;
  77387. /**
  77388. * Returns the rendering mesh of the submesh
  77389. * @returns the rendering mesh (could be different from parent mesh)
  77390. */
  77391. getRenderingMesh(): Mesh;
  77392. /**
  77393. * Returns the submesh material
  77394. * @returns null or the current material
  77395. */
  77396. getMaterial(): Nullable<Material>;
  77397. /**
  77398. * Sets a new updated BoundingInfo object to the submesh
  77399. * @returns the SubMesh
  77400. */
  77401. refreshBoundingInfo(): SubMesh;
  77402. /** @hidden */
  77403. _checkCollision(collider: Collider): boolean;
  77404. /**
  77405. * Updates the submesh BoundingInfo
  77406. * @param world defines the world matrix to use to update the bounding info
  77407. * @returns the submesh
  77408. */
  77409. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77410. /**
  77411. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77412. * @param frustumPlanes defines the frustum planes
  77413. * @returns true if the submesh is intersecting with the frustum
  77414. */
  77415. isInFrustum(frustumPlanes: Plane[]): boolean;
  77416. /**
  77417. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77418. * @param frustumPlanes defines the frustum planes
  77419. * @returns true if the submesh is inside the frustum
  77420. */
  77421. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77422. /**
  77423. * Renders the submesh
  77424. * @param enableAlphaMode defines if alpha needs to be used
  77425. * @returns the submesh
  77426. */
  77427. render(enableAlphaMode: boolean): SubMesh;
  77428. /**
  77429. * @hidden
  77430. */
  77431. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77432. /**
  77433. * Checks if the submesh intersects with a ray
  77434. * @param ray defines the ray to test
  77435. * @returns true is the passed ray intersects the submesh bounding box
  77436. */
  77437. canIntersects(ray: Ray): boolean;
  77438. /**
  77439. * Intersects current submesh with a ray
  77440. * @param ray defines the ray to test
  77441. * @param positions defines mesh's positions array
  77442. * @param indices defines mesh's indices array
  77443. * @param fastCheck defines if only bounding info should be used
  77444. * @returns intersection info or null if no intersection
  77445. */
  77446. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77447. /** @hidden */
  77448. private _intersectLines;
  77449. /** @hidden */
  77450. private _intersectTriangles;
  77451. /** @hidden */
  77452. _rebuild(): void;
  77453. /**
  77454. * Creates a new submesh from the passed mesh
  77455. * @param newMesh defines the new hosting mesh
  77456. * @param newRenderingMesh defines an optional rendering mesh
  77457. * @returns the new submesh
  77458. */
  77459. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77460. /**
  77461. * Release associated resources
  77462. */
  77463. dispose(): void;
  77464. /**
  77465. * Gets the class name
  77466. * @returns the string "SubMesh".
  77467. */
  77468. getClassName(): string;
  77469. /**
  77470. * Creates a new submesh from indices data
  77471. * @param materialIndex the index of the main mesh material
  77472. * @param startIndex the index where to start the copy in the mesh indices array
  77473. * @param indexCount the number of indices to copy then from the startIndex
  77474. * @param mesh the main mesh to create the submesh from
  77475. * @param renderingMesh the optional rendering mesh
  77476. * @returns a new submesh
  77477. */
  77478. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77479. }
  77480. }
  77481. declare module BABYLON {
  77482. /**
  77483. * Class used to store geometry data (vertex buffers + index buffer)
  77484. */
  77485. export class Geometry implements IGetSetVerticesData {
  77486. /**
  77487. * Gets or sets the ID of the geometry
  77488. */
  77489. id: string;
  77490. /**
  77491. * Gets or sets the unique ID of the geometry
  77492. */
  77493. uniqueId: number;
  77494. /**
  77495. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77496. */
  77497. delayLoadState: number;
  77498. /**
  77499. * Gets the file containing the data to load when running in delay load state
  77500. */
  77501. delayLoadingFile: Nullable<string>;
  77502. /**
  77503. * Callback called when the geometry is updated
  77504. */
  77505. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77506. private _scene;
  77507. private _engine;
  77508. private _meshes;
  77509. private _totalVertices;
  77510. /** @hidden */
  77511. _indices: IndicesArray;
  77512. /** @hidden */
  77513. _vertexBuffers: {
  77514. [key: string]: VertexBuffer;
  77515. };
  77516. private _isDisposed;
  77517. private _extend;
  77518. private _boundingBias;
  77519. /** @hidden */
  77520. _delayInfo: Array<string>;
  77521. private _indexBuffer;
  77522. private _indexBufferIsUpdatable;
  77523. /** @hidden */
  77524. _boundingInfo: Nullable<BoundingInfo>;
  77525. /** @hidden */
  77526. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77527. /** @hidden */
  77528. _softwareSkinningFrameId: number;
  77529. private _vertexArrayObjects;
  77530. private _updatable;
  77531. /** @hidden */
  77532. _positions: Nullable<Vector3[]>;
  77533. /**
  77534. * 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
  77535. */
  77536. /**
  77537. * 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
  77538. */
  77539. boundingBias: Vector2;
  77540. /**
  77541. * Static function used to attach a new empty geometry to a mesh
  77542. * @param mesh defines the mesh to attach the geometry to
  77543. * @returns the new Geometry
  77544. */
  77545. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  77546. /**
  77547. * Creates a new geometry
  77548. * @param id defines the unique ID
  77549. * @param scene defines the hosting scene
  77550. * @param vertexData defines the VertexData used to get geometry data
  77551. * @param updatable defines if geometry must be updatable (false by default)
  77552. * @param mesh defines the mesh that will be associated with the geometry
  77553. */
  77554. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  77555. /**
  77556. * Gets the current extend of the geometry
  77557. */
  77558. readonly extend: {
  77559. minimum: Vector3;
  77560. maximum: Vector3;
  77561. };
  77562. /**
  77563. * Gets the hosting scene
  77564. * @returns the hosting Scene
  77565. */
  77566. getScene(): Scene;
  77567. /**
  77568. * Gets the hosting engine
  77569. * @returns the hosting Engine
  77570. */
  77571. getEngine(): Engine;
  77572. /**
  77573. * Defines if the geometry is ready to use
  77574. * @returns true if the geometry is ready to be used
  77575. */
  77576. isReady(): boolean;
  77577. /**
  77578. * Gets a value indicating that the geometry should not be serialized
  77579. */
  77580. readonly doNotSerialize: boolean;
  77581. /** @hidden */
  77582. _rebuild(): void;
  77583. /**
  77584. * Affects all geometry data in one call
  77585. * @param vertexData defines the geometry data
  77586. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77587. */
  77588. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77589. /**
  77590. * Set specific vertex data
  77591. * @param kind defines the data kind (Position, normal, etc...)
  77592. * @param data defines the vertex data to use
  77593. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77594. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77595. */
  77596. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  77597. /**
  77598. * Removes a specific vertex data
  77599. * @param kind defines the data kind (Position, normal, etc...)
  77600. */
  77601. removeVerticesData(kind: string): void;
  77602. /**
  77603. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77604. * @param buffer defines the vertex buffer to use
  77605. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77606. */
  77607. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  77608. /**
  77609. * Update a specific vertex buffer
  77610. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77611. * It will do nothing if the buffer is not updatable
  77612. * @param kind defines the data kind (Position, normal, etc...)
  77613. * @param data defines the data to use
  77614. * @param offset defines the offset in the target buffer where to store the data
  77615. * @param useBytes set to true if the offset is in bytes
  77616. */
  77617. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  77618. /**
  77619. * Update a specific vertex buffer
  77620. * This function will create a new buffer if the current one is not updatable
  77621. * @param kind defines the data kind (Position, normal, etc...)
  77622. * @param data defines the data to use
  77623. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77624. */
  77625. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  77626. private _updateBoundingInfo;
  77627. /** @hidden */
  77628. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  77629. /**
  77630. * Gets total number of vertices
  77631. * @returns the total number of vertices
  77632. */
  77633. getTotalVertices(): number;
  77634. /**
  77635. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77636. * @param kind defines the data kind (Position, normal, etc...)
  77637. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77638. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77639. * @returns a float array containing vertex data
  77640. */
  77641. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77642. /**
  77643. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77644. * @param kind defines the data kind (Position, normal, etc...)
  77645. * @returns true if the vertex buffer with the specified kind is updatable
  77646. */
  77647. isVertexBufferUpdatable(kind: string): boolean;
  77648. /**
  77649. * Gets a specific vertex buffer
  77650. * @param kind defines the data kind (Position, normal, etc...)
  77651. * @returns a VertexBuffer
  77652. */
  77653. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77654. /**
  77655. * Returns all vertex buffers
  77656. * @return an object holding all vertex buffers indexed by kind
  77657. */
  77658. getVertexBuffers(): Nullable<{
  77659. [key: string]: VertexBuffer;
  77660. }>;
  77661. /**
  77662. * Gets a boolean indicating if specific vertex buffer is present
  77663. * @param kind defines the data kind (Position, normal, etc...)
  77664. * @returns true if data is present
  77665. */
  77666. isVerticesDataPresent(kind: string): boolean;
  77667. /**
  77668. * Gets a list of all attached data kinds (Position, normal, etc...)
  77669. * @returns a list of string containing all kinds
  77670. */
  77671. getVerticesDataKinds(): string[];
  77672. /**
  77673. * Update index buffer
  77674. * @param indices defines the indices to store in the index buffer
  77675. * @param offset defines the offset in the target buffer where to store the data
  77676. */
  77677. updateIndices(indices: IndicesArray, offset?: number): void;
  77678. /**
  77679. * Creates a new index buffer
  77680. * @param indices defines the indices to store in the index buffer
  77681. * @param totalVertices defines the total number of vertices (could be null)
  77682. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77683. */
  77684. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  77685. /**
  77686. * Return the total number of indices
  77687. * @returns the total number of indices
  77688. */
  77689. getTotalIndices(): number;
  77690. /**
  77691. * Gets the index buffer array
  77692. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77694. * @returns the index buffer array
  77695. */
  77696. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77697. /**
  77698. * Gets the index buffer
  77699. * @return the index buffer
  77700. */
  77701. getIndexBuffer(): Nullable<WebGLBuffer>;
  77702. /** @hidden */
  77703. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  77704. /**
  77705. * Release the associated resources for a specific mesh
  77706. * @param mesh defines the source mesh
  77707. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77708. */
  77709. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  77710. /**
  77711. * Apply current geometry to a given mesh
  77712. * @param mesh defines the mesh to apply geometry to
  77713. */
  77714. applyToMesh(mesh: Mesh): void;
  77715. private _updateExtend;
  77716. private _applyToMesh;
  77717. private notifyUpdate;
  77718. /**
  77719. * Load the geometry if it was flagged as delay loaded
  77720. * @param scene defines the hosting scene
  77721. * @param onLoaded defines a callback called when the geometry is loaded
  77722. */
  77723. load(scene: Scene, onLoaded?: () => void): void;
  77724. private _queueLoad;
  77725. /**
  77726. * Invert the geometry to move from a right handed system to a left handed one.
  77727. */
  77728. toLeftHanded(): void;
  77729. /** @hidden */
  77730. _resetPointsArrayCache(): void;
  77731. /** @hidden */
  77732. _generatePointsArray(): boolean;
  77733. /**
  77734. * Gets a value indicating if the geometry is disposed
  77735. * @returns true if the geometry was disposed
  77736. */
  77737. isDisposed(): boolean;
  77738. private _disposeVertexArrayObjects;
  77739. /**
  77740. * Free all associated resources
  77741. */
  77742. dispose(): void;
  77743. /**
  77744. * Clone the current geometry into a new geometry
  77745. * @param id defines the unique ID of the new geometry
  77746. * @returns a new geometry object
  77747. */
  77748. copy(id: string): Geometry;
  77749. /**
  77750. * Serialize the current geometry info (and not the vertices data) into a JSON object
  77751. * @return a JSON representation of the current geometry data (without the vertices data)
  77752. */
  77753. serialize(): any;
  77754. private toNumberArray;
  77755. /**
  77756. * Serialize all vertices data into a JSON oject
  77757. * @returns a JSON representation of the current geometry data
  77758. */
  77759. serializeVerticeData(): any;
  77760. /**
  77761. * Extracts a clone of a mesh geometry
  77762. * @param mesh defines the source mesh
  77763. * @param id defines the unique ID of the new geometry object
  77764. * @returns the new geometry object
  77765. */
  77766. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  77767. /**
  77768. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  77769. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  77770. * Be aware Math.random() could cause collisions, but:
  77771. * "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"
  77772. * @returns a string containing a new GUID
  77773. */
  77774. static RandomId(): string;
  77775. /** @hidden */
  77776. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  77777. private static _CleanMatricesWeights;
  77778. /**
  77779. * Create a new geometry from persisted data (Using .babylon file format)
  77780. * @param parsedVertexData defines the persisted data
  77781. * @param scene defines the hosting scene
  77782. * @param rootUrl defines the root url to use to load assets (like delayed data)
  77783. * @returns the new geometry object
  77784. */
  77785. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  77786. }
  77787. }
  77788. declare module BABYLON {
  77789. /**
  77790. * Define an interface for all classes that will get and set the data on vertices
  77791. */
  77792. export interface IGetSetVerticesData {
  77793. /**
  77794. * Gets a boolean indicating if specific vertex data is present
  77795. * @param kind defines the vertex data kind to use
  77796. * @returns true is data kind is present
  77797. */
  77798. isVerticesDataPresent(kind: string): boolean;
  77799. /**
  77800. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77801. * @param kind defines the data kind (Position, normal, etc...)
  77802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77804. * @returns a float array containing vertex data
  77805. */
  77806. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77807. /**
  77808. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77809. * @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.
  77810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77811. * @returns the indices array or an empty array if the mesh has no geometry
  77812. */
  77813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77814. /**
  77815. * Set specific vertex data
  77816. * @param kind defines the data kind (Position, normal, etc...)
  77817. * @param data defines the vertex data to use
  77818. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77819. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77820. */
  77821. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  77822. /**
  77823. * Update a specific associated vertex buffer
  77824. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77825. * - VertexBuffer.PositionKind
  77826. * - VertexBuffer.UVKind
  77827. * - VertexBuffer.UV2Kind
  77828. * - VertexBuffer.UV3Kind
  77829. * - VertexBuffer.UV4Kind
  77830. * - VertexBuffer.UV5Kind
  77831. * - VertexBuffer.UV6Kind
  77832. * - VertexBuffer.ColorKind
  77833. * - VertexBuffer.MatricesIndicesKind
  77834. * - VertexBuffer.MatricesIndicesExtraKind
  77835. * - VertexBuffer.MatricesWeightsKind
  77836. * - VertexBuffer.MatricesWeightsExtraKind
  77837. * @param data defines the data source
  77838. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77839. * @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)
  77840. */
  77841. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  77842. /**
  77843. * Creates a new index buffer
  77844. * @param indices defines the indices to store in the index buffer
  77845. * @param totalVertices defines the total number of vertices (could be null)
  77846. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77847. */
  77848. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  77849. }
  77850. /**
  77851. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  77852. */
  77853. export class VertexData {
  77854. /**
  77855. * Mesh side orientation : usually the external or front surface
  77856. */
  77857. static readonly FRONTSIDE: number;
  77858. /**
  77859. * Mesh side orientation : usually the internal or back surface
  77860. */
  77861. static readonly BACKSIDE: number;
  77862. /**
  77863. * Mesh side orientation : both internal and external or front and back surfaces
  77864. */
  77865. static readonly DOUBLESIDE: number;
  77866. /**
  77867. * Mesh side orientation : by default, `FRONTSIDE`
  77868. */
  77869. static readonly DEFAULTSIDE: number;
  77870. /**
  77871. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  77872. */
  77873. positions: Nullable<FloatArray>;
  77874. /**
  77875. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  77876. */
  77877. normals: Nullable<FloatArray>;
  77878. /**
  77879. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  77880. */
  77881. tangents: Nullable<FloatArray>;
  77882. /**
  77883. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77884. */
  77885. uvs: Nullable<FloatArray>;
  77886. /**
  77887. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77888. */
  77889. uvs2: Nullable<FloatArray>;
  77890. /**
  77891. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77892. */
  77893. uvs3: Nullable<FloatArray>;
  77894. /**
  77895. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77896. */
  77897. uvs4: Nullable<FloatArray>;
  77898. /**
  77899. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77900. */
  77901. uvs5: Nullable<FloatArray>;
  77902. /**
  77903. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77904. */
  77905. uvs6: Nullable<FloatArray>;
  77906. /**
  77907. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  77908. */
  77909. colors: Nullable<FloatArray>;
  77910. /**
  77911. * 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).
  77912. */
  77913. matricesIndices: Nullable<FloatArray>;
  77914. /**
  77915. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  77916. */
  77917. matricesWeights: Nullable<FloatArray>;
  77918. /**
  77919. * An array extending the number of possible indices
  77920. */
  77921. matricesIndicesExtra: Nullable<FloatArray>;
  77922. /**
  77923. * An array extending the number of possible weights when the number of indices is extended
  77924. */
  77925. matricesWeightsExtra: Nullable<FloatArray>;
  77926. /**
  77927. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  77928. */
  77929. indices: Nullable<IndicesArray>;
  77930. /**
  77931. * Uses the passed data array to set the set the values for the specified kind of data
  77932. * @param data a linear array of floating numbers
  77933. * @param kind the type of data that is being set, eg positions, colors etc
  77934. */
  77935. set(data: FloatArray, kind: string): void;
  77936. /**
  77937. * Associates the vertexData to the passed Mesh.
  77938. * Sets it as updatable or not (default `false`)
  77939. * @param mesh the mesh the vertexData is applied to
  77940. * @param updatable when used and having the value true allows new data to update the vertexData
  77941. * @returns the VertexData
  77942. */
  77943. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  77944. /**
  77945. * Associates the vertexData to the passed Geometry.
  77946. * Sets it as updatable or not (default `false`)
  77947. * @param geometry the geometry the vertexData is applied to
  77948. * @param updatable when used and having the value true allows new data to update the vertexData
  77949. * @returns VertexData
  77950. */
  77951. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  77952. /**
  77953. * Updates the associated mesh
  77954. * @param mesh the mesh to be updated
  77955. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77956. * @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
  77957. * @returns VertexData
  77958. */
  77959. updateMesh(mesh: Mesh): VertexData;
  77960. /**
  77961. * Updates the associated geometry
  77962. * @param geometry the geometry to be updated
  77963. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77964. * @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
  77965. * @returns VertexData.
  77966. */
  77967. updateGeometry(geometry: Geometry): VertexData;
  77968. private _applyTo;
  77969. private _update;
  77970. /**
  77971. * Transforms each position and each normal of the vertexData according to the passed Matrix
  77972. * @param matrix the transforming matrix
  77973. * @returns the VertexData
  77974. */
  77975. transform(matrix: Matrix): VertexData;
  77976. /**
  77977. * Merges the passed VertexData into the current one
  77978. * @param other the VertexData to be merged into the current one
  77979. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  77980. * @returns the modified VertexData
  77981. */
  77982. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  77983. private _mergeElement;
  77984. private _validate;
  77985. /**
  77986. * Serializes the VertexData
  77987. * @returns a serialized object
  77988. */
  77989. serialize(): any;
  77990. /**
  77991. * Extracts the vertexData from a mesh
  77992. * @param mesh the mesh from which to extract the VertexData
  77993. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  77994. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77995. * @returns the object VertexData associated to the passed mesh
  77996. */
  77997. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77998. /**
  77999. * Extracts the vertexData from the geometry
  78000. * @param geometry the geometry from which to extract the VertexData
  78001. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  78002. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78003. * @returns the object VertexData associated to the passed mesh
  78004. */
  78005. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78006. private static _ExtractFrom;
  78007. /**
  78008. * Creates the VertexData for a Ribbon
  78009. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  78010. * * pathArray array of paths, each of which an array of successive Vector3
  78011. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  78012. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  78013. * * 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
  78014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78015. * * 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)
  78016. * * 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)
  78017. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  78018. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  78019. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  78020. * @returns the VertexData of the ribbon
  78021. */
  78022. static CreateRibbon(options: {
  78023. pathArray: Vector3[][];
  78024. closeArray?: boolean;
  78025. closePath?: boolean;
  78026. offset?: number;
  78027. sideOrientation?: number;
  78028. frontUVs?: Vector4;
  78029. backUVs?: Vector4;
  78030. invertUV?: boolean;
  78031. uvs?: Vector2[];
  78032. colors?: Color4[];
  78033. }): VertexData;
  78034. /**
  78035. * Creates the VertexData for a box
  78036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78037. * * size sets the width, height and depth of the box to the value of size, optional default 1
  78038. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  78039. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  78040. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  78041. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  78042. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  78043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78044. * * 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)
  78045. * * 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)
  78046. * @returns the VertexData of the box
  78047. */
  78048. static CreateBox(options: {
  78049. size?: number;
  78050. width?: number;
  78051. height?: number;
  78052. depth?: number;
  78053. faceUV?: Vector4[];
  78054. faceColors?: Color4[];
  78055. sideOrientation?: number;
  78056. frontUVs?: Vector4;
  78057. backUVs?: Vector4;
  78058. }): VertexData;
  78059. /**
  78060. * Creates the VertexData for an ellipsoid, defaults to a sphere
  78061. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78062. * * segments sets the number of horizontal strips optional, default 32
  78063. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  78064. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  78065. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  78066. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  78067. * * 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
  78068. * * 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
  78069. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78070. * * 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)
  78071. * * 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)
  78072. * @returns the VertexData of the ellipsoid
  78073. */
  78074. static CreateSphere(options: {
  78075. segments?: number;
  78076. diameter?: number;
  78077. diameterX?: number;
  78078. diameterY?: number;
  78079. diameterZ?: number;
  78080. arc?: number;
  78081. slice?: number;
  78082. sideOrientation?: number;
  78083. frontUVs?: Vector4;
  78084. backUVs?: Vector4;
  78085. }): VertexData;
  78086. /**
  78087. * Creates the VertexData for a cylinder, cone or prism
  78088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78089. * * height sets the height (y direction) of the cylinder, optional, default 2
  78090. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  78091. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  78092. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  78093. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78094. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  78095. * * 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
  78096. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78097. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78098. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  78099. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  78100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78101. * * 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)
  78102. * * 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)
  78103. * @returns the VertexData of the cylinder, cone or prism
  78104. */
  78105. static CreateCylinder(options: {
  78106. height?: number;
  78107. diameterTop?: number;
  78108. diameterBottom?: number;
  78109. diameter?: number;
  78110. tessellation?: number;
  78111. subdivisions?: number;
  78112. arc?: number;
  78113. faceColors?: Color4[];
  78114. faceUV?: Vector4[];
  78115. hasRings?: boolean;
  78116. enclose?: boolean;
  78117. sideOrientation?: number;
  78118. frontUVs?: Vector4;
  78119. backUVs?: Vector4;
  78120. }): VertexData;
  78121. /**
  78122. * Creates the VertexData for a torus
  78123. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78124. * * diameter the diameter of the torus, optional default 1
  78125. * * thickness the diameter of the tube forming the torus, optional default 0.5
  78126. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78128. * * 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)
  78129. * * 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)
  78130. * @returns the VertexData of the torus
  78131. */
  78132. static CreateTorus(options: {
  78133. diameter?: number;
  78134. thickness?: number;
  78135. tessellation?: number;
  78136. sideOrientation?: number;
  78137. frontUVs?: Vector4;
  78138. backUVs?: Vector4;
  78139. }): VertexData;
  78140. /**
  78141. * Creates the VertexData of the LineSystem
  78142. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78143. * - lines an array of lines, each line being an array of successive Vector3
  78144. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78145. * @returns the VertexData of the LineSystem
  78146. */
  78147. static CreateLineSystem(options: {
  78148. lines: Vector3[][];
  78149. colors?: Nullable<Color4[][]>;
  78150. }): VertexData;
  78151. /**
  78152. * Create the VertexData for a DashedLines
  78153. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78154. * - points an array successive Vector3
  78155. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78156. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78157. * - dashNb the intended total number of dashes, optional, default 200
  78158. * @returns the VertexData for the DashedLines
  78159. */
  78160. static CreateDashedLines(options: {
  78161. points: Vector3[];
  78162. dashSize?: number;
  78163. gapSize?: number;
  78164. dashNb?: number;
  78165. }): VertexData;
  78166. /**
  78167. * Creates the VertexData for a Ground
  78168. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78169. * - width the width (x direction) of the ground, optional, default 1
  78170. * - height the height (z direction) of the ground, optional, default 1
  78171. * - subdivisions the number of subdivisions per side, optional, default 1
  78172. * @returns the VertexData of the Ground
  78173. */
  78174. static CreateGround(options: {
  78175. width?: number;
  78176. height?: number;
  78177. subdivisions?: number;
  78178. subdivisionsX?: number;
  78179. subdivisionsY?: number;
  78180. }): VertexData;
  78181. /**
  78182. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78183. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78184. * * xmin the ground minimum X coordinate, optional, default -1
  78185. * * zmin the ground minimum Z coordinate, optional, default -1
  78186. * * xmax the ground maximum X coordinate, optional, default 1
  78187. * * zmax the ground maximum Z coordinate, optional, default 1
  78188. * * 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}
  78189. * * 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}
  78190. * @returns the VertexData of the TiledGround
  78191. */
  78192. static CreateTiledGround(options: {
  78193. xmin: number;
  78194. zmin: number;
  78195. xmax: number;
  78196. zmax: number;
  78197. subdivisions?: {
  78198. w: number;
  78199. h: number;
  78200. };
  78201. precision?: {
  78202. w: number;
  78203. h: number;
  78204. };
  78205. }): VertexData;
  78206. /**
  78207. * Creates the VertexData of the Ground designed from a heightmap
  78208. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78209. * * width the width (x direction) of the ground
  78210. * * height the height (z direction) of the ground
  78211. * * subdivisions the number of subdivisions per side
  78212. * * minHeight the minimum altitude on the ground, optional, default 0
  78213. * * maxHeight the maximum altitude on the ground, optional default 1
  78214. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78215. * * buffer the array holding the image color data
  78216. * * bufferWidth the width of image
  78217. * * bufferHeight the height of image
  78218. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78219. * @returns the VertexData of the Ground designed from a heightmap
  78220. */
  78221. static CreateGroundFromHeightMap(options: {
  78222. width: number;
  78223. height: number;
  78224. subdivisions: number;
  78225. minHeight: number;
  78226. maxHeight: number;
  78227. colorFilter: Color3;
  78228. buffer: Uint8Array;
  78229. bufferWidth: number;
  78230. bufferHeight: number;
  78231. alphaFilter: number;
  78232. }): VertexData;
  78233. /**
  78234. * Creates the VertexData for a Plane
  78235. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78236. * * size sets the width and height of the plane to the value of size, optional default 1
  78237. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78238. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78239. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78240. * * 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)
  78241. * * 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)
  78242. * @returns the VertexData of the box
  78243. */
  78244. static CreatePlane(options: {
  78245. size?: number;
  78246. width?: number;
  78247. height?: number;
  78248. sideOrientation?: number;
  78249. frontUVs?: Vector4;
  78250. backUVs?: Vector4;
  78251. }): VertexData;
  78252. /**
  78253. * Creates the VertexData of the Disc or regular Polygon
  78254. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78255. * * radius the radius of the disc, optional default 0.5
  78256. * * tessellation the number of polygon sides, optional, default 64
  78257. * * 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
  78258. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78259. * * 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)
  78260. * * 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)
  78261. * @returns the VertexData of the box
  78262. */
  78263. static CreateDisc(options: {
  78264. radius?: number;
  78265. tessellation?: number;
  78266. arc?: number;
  78267. sideOrientation?: number;
  78268. frontUVs?: Vector4;
  78269. backUVs?: Vector4;
  78270. }): VertexData;
  78271. /**
  78272. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78273. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78274. * @param polygon a mesh built from polygonTriangulation.build()
  78275. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78276. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78277. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78278. * @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)
  78279. * @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)
  78280. * @returns the VertexData of the Polygon
  78281. */
  78282. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78283. /**
  78284. * Creates the VertexData of the IcoSphere
  78285. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78286. * * radius the radius of the IcoSphere, optional default 1
  78287. * * radiusX allows stretching in the x direction, optional, default radius
  78288. * * radiusY allows stretching in the y direction, optional, default radius
  78289. * * radiusZ allows stretching in the z direction, optional, default radius
  78290. * * flat when true creates a flat shaded mesh, optional, default true
  78291. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78293. * * 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)
  78294. * * 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)
  78295. * @returns the VertexData of the IcoSphere
  78296. */
  78297. static CreateIcoSphere(options: {
  78298. radius?: number;
  78299. radiusX?: number;
  78300. radiusY?: number;
  78301. radiusZ?: number;
  78302. flat?: boolean;
  78303. subdivisions?: number;
  78304. sideOrientation?: number;
  78305. frontUVs?: Vector4;
  78306. backUVs?: Vector4;
  78307. }): VertexData;
  78308. /**
  78309. * Creates the VertexData for a Polyhedron
  78310. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78311. * * type provided types are:
  78312. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78313. * * 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)
  78314. * * size the size of the IcoSphere, optional default 1
  78315. * * sizeX allows stretching in the x direction, optional, default size
  78316. * * sizeY allows stretching in the y direction, optional, default size
  78317. * * sizeZ allows stretching in the z direction, optional, default size
  78318. * * 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
  78319. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78320. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78321. * * flat when true creates a flat shaded mesh, optional, default true
  78322. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78324. * * 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)
  78325. * * 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)
  78326. * @returns the VertexData of the Polyhedron
  78327. */
  78328. static CreatePolyhedron(options: {
  78329. type?: number;
  78330. size?: number;
  78331. sizeX?: number;
  78332. sizeY?: number;
  78333. sizeZ?: number;
  78334. custom?: any;
  78335. faceUV?: Vector4[];
  78336. faceColors?: Color4[];
  78337. flat?: boolean;
  78338. sideOrientation?: number;
  78339. frontUVs?: Vector4;
  78340. backUVs?: Vector4;
  78341. }): VertexData;
  78342. /**
  78343. * Creates the VertexData for a TorusKnot
  78344. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78345. * * radius the radius of the torus knot, optional, default 2
  78346. * * tube the thickness of the tube, optional, default 0.5
  78347. * * radialSegments the number of sides on each tube segments, optional, default 32
  78348. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78349. * * p the number of windings around the z axis, optional, default 2
  78350. * * q the number of windings around the x axis, optional, default 3
  78351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78352. * * 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)
  78353. * * 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)
  78354. * @returns the VertexData of the Torus Knot
  78355. */
  78356. static CreateTorusKnot(options: {
  78357. radius?: number;
  78358. tube?: number;
  78359. radialSegments?: number;
  78360. tubularSegments?: number;
  78361. p?: number;
  78362. q?: number;
  78363. sideOrientation?: number;
  78364. frontUVs?: Vector4;
  78365. backUVs?: Vector4;
  78366. }): VertexData;
  78367. /**
  78368. * Compute normals for given positions and indices
  78369. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78370. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78371. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78372. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78373. * * facetNormals : optional array of facet normals (vector3)
  78374. * * facetPositions : optional array of facet positions (vector3)
  78375. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78376. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78377. * * bInfo : optional bounding info, required for facetPartitioning computation
  78378. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78379. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78380. * * useRightHandedSystem: optional boolean to for right handed system computation
  78381. * * depthSort : optional boolean to enable the facet depth sort computation
  78382. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78383. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78384. */
  78385. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78386. facetNormals?: any;
  78387. facetPositions?: any;
  78388. facetPartitioning?: any;
  78389. ratio?: number;
  78390. bInfo?: any;
  78391. bbSize?: Vector3;
  78392. subDiv?: any;
  78393. useRightHandedSystem?: boolean;
  78394. depthSort?: boolean;
  78395. distanceTo?: Vector3;
  78396. depthSortedFacets?: any;
  78397. }): void;
  78398. /** @hidden */
  78399. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  78400. /**
  78401. * Applies VertexData created from the imported parameters to the geometry
  78402. * @param parsedVertexData the parsed data from an imported file
  78403. * @param geometry the geometry to apply the VertexData to
  78404. */
  78405. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78406. }
  78407. }
  78408. declare module BABYLON {
  78409. /**
  78410. * Class containing static functions to help procedurally build meshes
  78411. */
  78412. export class DiscBuilder {
  78413. /**
  78414. * Creates a plane polygonal mesh. By default, this is a disc
  78415. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78416. * * 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
  78417. * * 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
  78418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78421. * @param name defines the name of the mesh
  78422. * @param options defines the options used to create the mesh
  78423. * @param scene defines the hosting scene
  78424. * @returns the plane polygonal mesh
  78425. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78426. */
  78427. static CreateDisc(name: string, options: {
  78428. radius?: number;
  78429. tessellation?: number;
  78430. arc?: number;
  78431. updatable?: boolean;
  78432. sideOrientation?: number;
  78433. frontUVs?: Vector4;
  78434. backUVs?: Vector4;
  78435. }, scene?: Nullable<Scene>): Mesh;
  78436. }
  78437. }
  78438. declare module BABYLON {
  78439. /**
  78440. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  78441. *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.
  78442. * The SPS is also a particle system. It provides some methods to manage the particles.
  78443. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  78444. *
  78445. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  78446. */
  78447. export class SolidParticleSystem implements IDisposable {
  78448. /**
  78449. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  78450. * Example : var p = SPS.particles[i];
  78451. */
  78452. particles: SolidParticle[];
  78453. /**
  78454. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  78455. */
  78456. nbParticles: number;
  78457. /**
  78458. * If the particles must ever face the camera (default false). Useful for planar particles.
  78459. */
  78460. billboard: boolean;
  78461. /**
  78462. * Recompute normals when adding a shape
  78463. */
  78464. recomputeNormals: boolean;
  78465. /**
  78466. * This a counter ofr your own usage. It's not set by any SPS functions.
  78467. */
  78468. counter: number;
  78469. /**
  78470. * The SPS name. This name is also given to the underlying mesh.
  78471. */
  78472. name: string;
  78473. /**
  78474. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  78475. */
  78476. mesh: Mesh;
  78477. /**
  78478. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  78479. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  78480. */
  78481. vars: any;
  78482. /**
  78483. * This array is populated when the SPS is set as 'pickable'.
  78484. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  78485. * Each element of this array is an object `{idx: int, faceId: int}`.
  78486. * `idx` is the picked particle index in the `SPS.particles` array
  78487. * `faceId` is the picked face index counted within this particle.
  78488. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  78489. */
  78490. pickedParticles: {
  78491. idx: number;
  78492. faceId: number;
  78493. }[];
  78494. /**
  78495. * This array is populated when `enableDepthSort` is set to true.
  78496. * Each element of this array is an instance of the class DepthSortedParticle.
  78497. */
  78498. depthSortedParticles: DepthSortedParticle[];
  78499. /**
  78500. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  78501. * @hidden
  78502. */
  78503. _bSphereOnly: boolean;
  78504. /**
  78505. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  78506. * @hidden
  78507. */
  78508. _bSphereRadiusFactor: number;
  78509. private _scene;
  78510. private _positions;
  78511. private _indices;
  78512. private _normals;
  78513. private _colors;
  78514. private _uvs;
  78515. private _indices32;
  78516. private _positions32;
  78517. private _normals32;
  78518. private _fixedNormal32;
  78519. private _colors32;
  78520. private _uvs32;
  78521. private _index;
  78522. private _updatable;
  78523. private _pickable;
  78524. private _isVisibilityBoxLocked;
  78525. private _alwaysVisible;
  78526. private _depthSort;
  78527. private _shapeCounter;
  78528. private _copy;
  78529. private _color;
  78530. private _computeParticleColor;
  78531. private _computeParticleTexture;
  78532. private _computeParticleRotation;
  78533. private _computeParticleVertex;
  78534. private _computeBoundingBox;
  78535. private _depthSortParticles;
  78536. private _camera;
  78537. private _mustUnrotateFixedNormals;
  78538. private _particlesIntersect;
  78539. private _needs32Bits;
  78540. /**
  78541. * Creates a SPS (Solid Particle System) object.
  78542. * @param name (String) is the SPS name, this will be the underlying mesh name.
  78543. * @param scene (Scene) is the scene in which the SPS is added.
  78544. * @param options defines the options of the sps e.g.
  78545. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  78546. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  78547. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  78548. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  78549. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  78550. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  78551. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  78552. */
  78553. constructor(name: string, scene: Scene, options?: {
  78554. updatable?: boolean;
  78555. isPickable?: boolean;
  78556. enableDepthSort?: boolean;
  78557. particleIntersection?: boolean;
  78558. boundingSphereOnly?: boolean;
  78559. bSphereRadiusFactor?: number;
  78560. });
  78561. /**
  78562. * Builds the SPS underlying mesh. Returns a standard Mesh.
  78563. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  78564. * @returns the created mesh
  78565. */
  78566. buildMesh(): Mesh;
  78567. /**
  78568. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  78569. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  78570. * Thus the particles generated from `digest()` have their property `position` set yet.
  78571. * @param mesh ( Mesh ) is the mesh to be digested
  78572. * @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
  78573. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  78574. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  78575. * @returns the current SPS
  78576. */
  78577. digest(mesh: Mesh, options?: {
  78578. facetNb?: number;
  78579. number?: number;
  78580. delta?: number;
  78581. }): SolidParticleSystem;
  78582. private _unrotateFixedNormals;
  78583. private _resetCopy;
  78584. private _meshBuilder;
  78585. private _posToShape;
  78586. private _uvsToShapeUV;
  78587. private _addParticle;
  78588. /**
  78589. * Adds some particles to the SPS from the model shape. Returns the shape id.
  78590. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  78591. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  78592. * @param nb (positive integer) the number of particles to be created from this model
  78593. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  78594. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  78595. * @returns the number of shapes in the system
  78596. */
  78597. addShape(mesh: Mesh, nb: number, options?: {
  78598. positionFunction?: any;
  78599. vertexFunction?: any;
  78600. }): number;
  78601. private _rebuildParticle;
  78602. /**
  78603. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  78604. * @returns the SPS.
  78605. */
  78606. rebuildMesh(): SolidParticleSystem;
  78607. /**
  78608. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  78609. * This method calls `updateParticle()` for each particle of the SPS.
  78610. * For an animated SPS, it is usually called within the render loop.
  78611. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  78612. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  78613. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  78614. * @returns the SPS.
  78615. */
  78616. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  78617. /**
  78618. * Disposes the SPS.
  78619. */
  78620. dispose(): void;
  78621. /**
  78622. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  78623. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78624. * @returns the SPS.
  78625. */
  78626. refreshVisibleSize(): SolidParticleSystem;
  78627. /**
  78628. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  78629. * @param size the size (float) of the visibility box
  78630. * note : this doesn't lock the SPS mesh bounding box.
  78631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78632. */
  78633. setVisibilityBox(size: number): void;
  78634. /**
  78635. * Gets whether the SPS as always visible or not
  78636. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78637. */
  78638. /**
  78639. * Sets the SPS as always visible or not
  78640. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78641. */
  78642. isAlwaysVisible: boolean;
  78643. /**
  78644. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78645. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78646. */
  78647. /**
  78648. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78649. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78650. */
  78651. isVisibilityBoxLocked: boolean;
  78652. /**
  78653. * Tells to `setParticles()` to compute the particle rotations or not.
  78654. * Default value : true. The SPS is faster when it's set to false.
  78655. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78656. */
  78657. /**
  78658. * Gets if `setParticles()` computes the particle rotations or not.
  78659. * Default value : true. The SPS is faster when it's set to false.
  78660. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78661. */
  78662. computeParticleRotation: boolean;
  78663. /**
  78664. * Tells to `setParticles()` to compute the particle colors or not.
  78665. * Default value : true. The SPS is faster when it's set to false.
  78666. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78667. */
  78668. /**
  78669. * Gets if `setParticles()` computes the particle colors or not.
  78670. * Default value : true. The SPS is faster when it's set to false.
  78671. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78672. */
  78673. computeParticleColor: boolean;
  78674. /**
  78675. * Gets if `setParticles()` computes the particle textures or not.
  78676. * Default value : true. The SPS is faster when it's set to false.
  78677. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  78678. */
  78679. computeParticleTexture: boolean;
  78680. /**
  78681. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  78682. * Default value : false. The SPS is faster when it's set to false.
  78683. * Note : the particle custom vertex positions aren't stored values.
  78684. */
  78685. /**
  78686. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  78687. * Default value : false. The SPS is faster when it's set to false.
  78688. * Note : the particle custom vertex positions aren't stored values.
  78689. */
  78690. computeParticleVertex: boolean;
  78691. /**
  78692. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  78693. */
  78694. /**
  78695. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  78696. */
  78697. computeBoundingBox: boolean;
  78698. /**
  78699. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  78700. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78701. * Default : `true`
  78702. */
  78703. /**
  78704. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  78705. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78706. * Default : `true`
  78707. */
  78708. depthSortParticles: boolean;
  78709. /**
  78710. * This function does nothing. It may be overwritten to set all the particle first values.
  78711. * The SPS doesn't call this function, you may have to call it by your own.
  78712. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78713. */
  78714. initParticles(): void;
  78715. /**
  78716. * This function does nothing. It may be overwritten to recycle a particle.
  78717. * The SPS doesn't call this function, you may have to call it by your own.
  78718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78719. * @param particle The particle to recycle
  78720. * @returns the recycled particle
  78721. */
  78722. recycleParticle(particle: SolidParticle): SolidParticle;
  78723. /**
  78724. * Updates a particle : this function should be overwritten by the user.
  78725. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  78726. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78727. * @example : just set a particle position or velocity and recycle conditions
  78728. * @param particle The particle to update
  78729. * @returns the updated particle
  78730. */
  78731. updateParticle(particle: SolidParticle): SolidParticle;
  78732. /**
  78733. * Updates a vertex of a particle : it can be overwritten by the user.
  78734. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  78735. * @param particle the current particle
  78736. * @param vertex the current index of the current particle
  78737. * @param pt the index of the current vertex in the particle shape
  78738. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  78739. * @example : just set a vertex particle position
  78740. * @returns the updated vertex
  78741. */
  78742. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  78743. /**
  78744. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  78745. * This does nothing and may be overwritten by the user.
  78746. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78747. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78748. * @param update the boolean update value actually passed to setParticles()
  78749. */
  78750. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78751. /**
  78752. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  78753. * This will be passed three parameters.
  78754. * This does nothing and may be overwritten by the user.
  78755. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78756. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78757. * @param update the boolean update value actually passed to setParticles()
  78758. */
  78759. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78760. }
  78761. }
  78762. declare module BABYLON {
  78763. /**
  78764. * Represents one particle of a solid particle system.
  78765. */
  78766. export class SolidParticle {
  78767. /**
  78768. * particle global index
  78769. */
  78770. idx: number;
  78771. /**
  78772. * The color of the particle
  78773. */
  78774. color: Nullable<Color4>;
  78775. /**
  78776. * The world space position of the particle.
  78777. */
  78778. position: Vector3;
  78779. /**
  78780. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  78781. */
  78782. rotation: Vector3;
  78783. /**
  78784. * The world space rotation quaternion of the particle.
  78785. */
  78786. rotationQuaternion: Nullable<Quaternion>;
  78787. /**
  78788. * The scaling of the particle.
  78789. */
  78790. scaling: Vector3;
  78791. /**
  78792. * The uvs of the particle.
  78793. */
  78794. uvs: Vector4;
  78795. /**
  78796. * The current speed of the particle.
  78797. */
  78798. velocity: Vector3;
  78799. /**
  78800. * The pivot point in the particle local space.
  78801. */
  78802. pivot: Vector3;
  78803. /**
  78804. * Must the particle be translated from its pivot point in its local space ?
  78805. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  78806. * Default : false
  78807. */
  78808. translateFromPivot: boolean;
  78809. /**
  78810. * Is the particle active or not ?
  78811. */
  78812. alive: boolean;
  78813. /**
  78814. * Is the particle visible or not ?
  78815. */
  78816. isVisible: boolean;
  78817. /**
  78818. * Index of this particle in the global "positions" array (Internal use)
  78819. * @hidden
  78820. */
  78821. _pos: number;
  78822. /**
  78823. * @hidden Index of this particle in the global "indices" array (Internal use)
  78824. */
  78825. _ind: number;
  78826. /**
  78827. * @hidden ModelShape of this particle (Internal use)
  78828. */
  78829. _model: ModelShape;
  78830. /**
  78831. * ModelShape id of this particle
  78832. */
  78833. shapeId: number;
  78834. /**
  78835. * Index of the particle in its shape id (Internal use)
  78836. */
  78837. idxInShape: number;
  78838. /**
  78839. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  78840. */
  78841. _modelBoundingInfo: BoundingInfo;
  78842. /**
  78843. * @hidden Particle BoundingInfo object (Internal use)
  78844. */
  78845. _boundingInfo: BoundingInfo;
  78846. /**
  78847. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  78848. */
  78849. _sps: SolidParticleSystem;
  78850. /**
  78851. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  78852. */
  78853. _stillInvisible: boolean;
  78854. /**
  78855. * @hidden Last computed particle rotation matrix
  78856. */
  78857. _rotationMatrix: number[];
  78858. /**
  78859. * Parent particle Id, if any.
  78860. * Default null.
  78861. */
  78862. parentId: Nullable<number>;
  78863. /**
  78864. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  78865. * The possible values are :
  78866. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78867. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78868. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78869. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78870. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78871. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  78872. * */
  78873. cullingStrategy: number;
  78874. /**
  78875. * @hidden Internal global position in the SPS.
  78876. */
  78877. _globalPosition: Vector3;
  78878. /**
  78879. * Creates a Solid Particle object.
  78880. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  78881. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  78882. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  78883. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  78884. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  78885. * @param shapeId (integer) is the model shape identifier in the SPS.
  78886. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  78887. * @param sps defines the sps it is associated to
  78888. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  78889. */
  78890. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  78891. /**
  78892. * Legacy support, changed scale to scaling
  78893. */
  78894. /**
  78895. * Legacy support, changed scale to scaling
  78896. */
  78897. scale: Vector3;
  78898. /**
  78899. * Legacy support, changed quaternion to rotationQuaternion
  78900. */
  78901. /**
  78902. * Legacy support, changed quaternion to rotationQuaternion
  78903. */
  78904. quaternion: Nullable<Quaternion>;
  78905. /**
  78906. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  78907. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  78908. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  78909. * @returns true if it intersects
  78910. */
  78911. intersectsMesh(target: Mesh | SolidParticle): boolean;
  78912. /**
  78913. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  78914. * A particle is in the frustum if its bounding box intersects the frustum
  78915. * @param frustumPlanes defines the frustum to test
  78916. * @returns true if the particle is in the frustum planes
  78917. */
  78918. isInFrustum(frustumPlanes: Plane[]): boolean;
  78919. /**
  78920. * get the rotation matrix of the particle
  78921. * @hidden
  78922. */
  78923. getRotationMatrix(m: Matrix): void;
  78924. }
  78925. /**
  78926. * Represents the shape of the model used by one particle of a solid particle system.
  78927. * SPS internal tool, don't use it manually.
  78928. */
  78929. export class ModelShape {
  78930. /**
  78931. * The shape id
  78932. * @hidden
  78933. */
  78934. shapeID: number;
  78935. /**
  78936. * flat array of model positions (internal use)
  78937. * @hidden
  78938. */
  78939. _shape: Vector3[];
  78940. /**
  78941. * flat array of model UVs (internal use)
  78942. * @hidden
  78943. */
  78944. _shapeUV: number[];
  78945. /**
  78946. * length of the shape in the model indices array (internal use)
  78947. * @hidden
  78948. */
  78949. _indicesLength: number;
  78950. /**
  78951. * Custom position function (internal use)
  78952. * @hidden
  78953. */
  78954. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  78955. /**
  78956. * Custom vertex function (internal use)
  78957. * @hidden
  78958. */
  78959. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  78960. /**
  78961. * 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.
  78962. * SPS internal tool, don't use it manually.
  78963. * @hidden
  78964. */
  78965. 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>);
  78966. }
  78967. /**
  78968. * Represents a Depth Sorted Particle in the solid particle system.
  78969. */
  78970. export class DepthSortedParticle {
  78971. /**
  78972. * Index of the particle in the "indices" array
  78973. */
  78974. ind: number;
  78975. /**
  78976. * Length of the particle shape in the "indices" array
  78977. */
  78978. indicesLength: number;
  78979. /**
  78980. * Squared distance from the particle to the camera
  78981. */
  78982. sqDistance: number;
  78983. }
  78984. }
  78985. declare module BABYLON {
  78986. /**
  78987. * Class used to store all common mesh properties
  78988. */
  78989. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  78990. /** No occlusion */
  78991. static OCCLUSION_TYPE_NONE: number;
  78992. /** Occlusion set to optimisitic */
  78993. static OCCLUSION_TYPE_OPTIMISTIC: number;
  78994. /** Occlusion set to strict */
  78995. static OCCLUSION_TYPE_STRICT: number;
  78996. /** Use an accurante occlusion algorithm */
  78997. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  78998. /** Use a conservative occlusion algorithm */
  78999. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  79000. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79001. * Test order :
  79002. * Is the bounding sphere outside the frustum ?
  79003. * If not, are the bounding box vertices outside the frustum ?
  79004. * It not, then the cullable object is in the frustum.
  79005. */
  79006. static readonly CULLINGSTRATEGY_STANDARD: number;
  79007. /** Culling strategy : Bounding Sphere Only.
  79008. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79009. * It's also less accurate than the standard because some not visible objects can still be selected.
  79010. * Test : is the bounding sphere outside the frustum ?
  79011. * If not, then the cullable object is in the frustum.
  79012. */
  79013. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79014. /** Culling strategy : Optimistic Inclusion.
  79015. * This in an inclusion test first, then the standard exclusion test.
  79016. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79017. * 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.
  79018. * Anyway, it's as accurate as the standard strategy.
  79019. * Test :
  79020. * Is the cullable object bounding sphere center in the frustum ?
  79021. * If not, apply the default culling strategy.
  79022. */
  79023. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79024. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79025. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79026. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79027. * 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.
  79028. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79029. * Test :
  79030. * Is the cullable object bounding sphere center in the frustum ?
  79031. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79032. */
  79033. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79034. /**
  79035. * No billboard
  79036. */
  79037. static readonly BILLBOARDMODE_NONE: number;
  79038. /** Billboard on X axis */
  79039. static readonly BILLBOARDMODE_X: number;
  79040. /** Billboard on Y axis */
  79041. static readonly BILLBOARDMODE_Y: number;
  79042. /** Billboard on Z axis */
  79043. static readonly BILLBOARDMODE_Z: number;
  79044. /** Billboard on all axes */
  79045. static readonly BILLBOARDMODE_ALL: number;
  79046. private _facetData;
  79047. /**
  79048. * The culling strategy to use to check whether the mesh must be rendered or not.
  79049. * This value can be changed at any time and will be used on the next render mesh selection.
  79050. * The possible values are :
  79051. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79052. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79053. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79054. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79055. * Please read each static variable documentation to get details about the culling process.
  79056. * */
  79057. cullingStrategy: number;
  79058. /**
  79059. * Gets the number of facets in the mesh
  79060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79061. */
  79062. readonly facetNb: number;
  79063. /**
  79064. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  79065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79066. */
  79067. partitioningSubdivisions: number;
  79068. /**
  79069. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  79070. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  79071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79072. */
  79073. partitioningBBoxRatio: number;
  79074. /**
  79075. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  79076. * Works only for updatable meshes.
  79077. * Doesn't work with multi-materials
  79078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79079. */
  79080. mustDepthSortFacets: boolean;
  79081. /**
  79082. * The location (Vector3) where the facet depth sort must be computed from.
  79083. * By default, the active camera position.
  79084. * Used only when facet depth sort is enabled
  79085. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79086. */
  79087. facetDepthSortFrom: Vector3;
  79088. /**
  79089. * gets a boolean indicating if facetData is enabled
  79090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79091. */
  79092. readonly isFacetDataEnabled: boolean;
  79093. /** @hidden */
  79094. _updateNonUniformScalingState(value: boolean): boolean;
  79095. /**
  79096. * An event triggered when this mesh collides with another one
  79097. */
  79098. onCollideObservable: Observable<AbstractMesh>;
  79099. private _onCollideObserver;
  79100. /** Set a function to call when this mesh collides with another one */
  79101. onCollide: () => void;
  79102. /**
  79103. * An event triggered when the collision's position changes
  79104. */
  79105. onCollisionPositionChangeObservable: Observable<Vector3>;
  79106. private _onCollisionPositionChangeObserver;
  79107. /** Set a function to call when the collision's position changes */
  79108. onCollisionPositionChange: () => void;
  79109. /**
  79110. * An event triggered when material is changed
  79111. */
  79112. onMaterialChangedObservable: Observable<AbstractMesh>;
  79113. /**
  79114. * Gets or sets the orientation for POV movement & rotation
  79115. */
  79116. definedFacingForward: boolean;
  79117. /** @hidden */
  79118. _occlusionQuery: Nullable<WebGLQuery>;
  79119. private _visibility;
  79120. /**
  79121. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79122. */
  79123. /**
  79124. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79125. */
  79126. visibility: number;
  79127. /** Gets or sets the alpha index used to sort transparent meshes
  79128. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  79129. */
  79130. alphaIndex: number;
  79131. /**
  79132. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  79133. */
  79134. isVisible: boolean;
  79135. /**
  79136. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79137. */
  79138. isPickable: boolean;
  79139. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79140. showSubMeshesBoundingBox: boolean;
  79141. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79142. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79143. */
  79144. isBlocker: boolean;
  79145. /**
  79146. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79147. */
  79148. enablePointerMoveEvents: boolean;
  79149. /**
  79150. * Specifies the rendering group id for this mesh (0 by default)
  79151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79152. */
  79153. renderingGroupId: number;
  79154. private _material;
  79155. /** Gets or sets current material */
  79156. material: Nullable<Material>;
  79157. private _receiveShadows;
  79158. /**
  79159. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79160. * @see http://doc.babylonjs.com/babylon101/shadows
  79161. */
  79162. receiveShadows: boolean;
  79163. /** Defines color to use when rendering outline */
  79164. outlineColor: Color3;
  79165. /** Define width to use when rendering outline */
  79166. outlineWidth: number;
  79167. /** Defines color to use when rendering overlay */
  79168. overlayColor: Color3;
  79169. /** Defines alpha to use when rendering overlay */
  79170. overlayAlpha: number;
  79171. private _hasVertexAlpha;
  79172. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79173. hasVertexAlpha: boolean;
  79174. private _useVertexColors;
  79175. /** 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) */
  79176. useVertexColors: boolean;
  79177. private _computeBonesUsingShaders;
  79178. /**
  79179. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79180. */
  79181. computeBonesUsingShaders: boolean;
  79182. private _numBoneInfluencers;
  79183. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79184. numBoneInfluencers: number;
  79185. private _applyFog;
  79186. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79187. applyFog: boolean;
  79188. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79189. useOctreeForRenderingSelection: boolean;
  79190. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79191. useOctreeForPicking: boolean;
  79192. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79193. useOctreeForCollisions: boolean;
  79194. private _layerMask;
  79195. /**
  79196. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79197. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79198. */
  79199. layerMask: number;
  79200. /**
  79201. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79202. */
  79203. alwaysSelectAsActiveMesh: boolean;
  79204. /**
  79205. * Gets or sets the current action manager
  79206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79207. */
  79208. actionManager: Nullable<AbstractActionManager>;
  79209. private _checkCollisions;
  79210. private _collisionMask;
  79211. private _collisionGroup;
  79212. /**
  79213. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79215. */
  79216. ellipsoid: Vector3;
  79217. /**
  79218. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79220. */
  79221. ellipsoidOffset: Vector3;
  79222. private _collider;
  79223. private _oldPositionForCollisions;
  79224. private _diffPositionForCollisions;
  79225. /**
  79226. * Gets or sets a collision mask used to mask collisions (default is -1).
  79227. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79228. */
  79229. collisionMask: number;
  79230. /**
  79231. * Gets or sets the current collision group mask (-1 by default).
  79232. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79233. */
  79234. collisionGroup: number;
  79235. /**
  79236. * Defines edge width used when edgesRenderer is enabled
  79237. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79238. */
  79239. edgesWidth: number;
  79240. /**
  79241. * Defines edge color used when edgesRenderer is enabled
  79242. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79243. */
  79244. edgesColor: Color4;
  79245. /** @hidden */
  79246. _edgesRenderer: Nullable<IEdgesRenderer>;
  79247. /** @hidden */
  79248. _masterMesh: Nullable<AbstractMesh>;
  79249. /** @hidden */
  79250. _boundingInfo: Nullable<BoundingInfo>;
  79251. /** @hidden */
  79252. _renderId: number;
  79253. /**
  79254. * Gets or sets the list of subMeshes
  79255. * @see http://doc.babylonjs.com/how_to/multi_materials
  79256. */
  79257. subMeshes: SubMesh[];
  79258. /** @hidden */
  79259. _intersectionsInProgress: AbstractMesh[];
  79260. /** @hidden */
  79261. _unIndexed: boolean;
  79262. /** @hidden */
  79263. _lightSources: Light[];
  79264. /** @hidden */
  79265. readonly _positions: Nullable<Vector3[]>;
  79266. /** @hidden */
  79267. _waitingActions: any;
  79268. /** @hidden */
  79269. _waitingFreezeWorldMatrix: Nullable<boolean>;
  79270. private _skeleton;
  79271. /** @hidden */
  79272. _bonesTransformMatrices: Nullable<Float32Array>;
  79273. /**
  79274. * Gets or sets a skeleton to apply skining transformations
  79275. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79276. */
  79277. skeleton: Nullable<Skeleton>;
  79278. /**
  79279. * An event triggered when the mesh is rebuilt.
  79280. */
  79281. onRebuildObservable: Observable<AbstractMesh>;
  79282. /**
  79283. * Creates a new AbstractMesh
  79284. * @param name defines the name of the mesh
  79285. * @param scene defines the hosting scene
  79286. */
  79287. constructor(name: string, scene?: Nullable<Scene>);
  79288. /**
  79289. * Returns the string "AbstractMesh"
  79290. * @returns "AbstractMesh"
  79291. */
  79292. getClassName(): string;
  79293. /**
  79294. * Gets a string representation of the current mesh
  79295. * @param fullDetails defines a boolean indicating if full details must be included
  79296. * @returns a string representation of the current mesh
  79297. */
  79298. toString(fullDetails?: boolean): string;
  79299. /** @hidden */
  79300. _rebuild(): void;
  79301. /** @hidden */
  79302. _resyncLightSources(): void;
  79303. /** @hidden */
  79304. _resyncLighSource(light: Light): void;
  79305. /** @hidden */
  79306. _unBindEffect(): void;
  79307. /** @hidden */
  79308. _removeLightSource(light: Light): void;
  79309. private _markSubMeshesAsDirty;
  79310. /** @hidden */
  79311. _markSubMeshesAsLightDirty(): void;
  79312. /** @hidden */
  79313. _markSubMeshesAsAttributesDirty(): void;
  79314. /** @hidden */
  79315. _markSubMeshesAsMiscDirty(): void;
  79316. /**
  79317. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79318. */
  79319. scaling: Vector3;
  79320. /**
  79321. * Returns true if the mesh is blocked. Implemented by child classes
  79322. */
  79323. readonly isBlocked: boolean;
  79324. /**
  79325. * Returns the mesh itself by default. Implemented by child classes
  79326. * @param camera defines the camera to use to pick the right LOD level
  79327. * @returns the currentAbstractMesh
  79328. */
  79329. getLOD(camera: Camera): Nullable<AbstractMesh>;
  79330. /**
  79331. * Returns 0 by default. Implemented by child classes
  79332. * @returns an integer
  79333. */
  79334. getTotalVertices(): number;
  79335. /**
  79336. * Returns a positive integer : the total number of indices in this mesh geometry.
  79337. * @returns the numner of indices or zero if the mesh has no geometry.
  79338. */
  79339. getTotalIndices(): number;
  79340. /**
  79341. * Returns null by default. Implemented by child classes
  79342. * @returns null
  79343. */
  79344. getIndices(): Nullable<IndicesArray>;
  79345. /**
  79346. * Returns the array of the requested vertex data kind. Implemented by child classes
  79347. * @param kind defines the vertex data kind to use
  79348. * @returns null
  79349. */
  79350. getVerticesData(kind: string): Nullable<FloatArray>;
  79351. /**
  79352. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79353. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79354. * Note that a new underlying VertexBuffer object is created each call.
  79355. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79356. * @param kind defines vertex data kind:
  79357. * * VertexBuffer.PositionKind
  79358. * * VertexBuffer.UVKind
  79359. * * VertexBuffer.UV2Kind
  79360. * * VertexBuffer.UV3Kind
  79361. * * VertexBuffer.UV4Kind
  79362. * * VertexBuffer.UV5Kind
  79363. * * VertexBuffer.UV6Kind
  79364. * * VertexBuffer.ColorKind
  79365. * * VertexBuffer.MatricesIndicesKind
  79366. * * VertexBuffer.MatricesIndicesExtraKind
  79367. * * VertexBuffer.MatricesWeightsKind
  79368. * * VertexBuffer.MatricesWeightsExtraKind
  79369. * @param data defines the data source
  79370. * @param updatable defines if the data must be flagged as updatable (or static)
  79371. * @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
  79372. * @returns the current mesh
  79373. */
  79374. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  79375. /**
  79376. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79377. * If the mesh has no geometry, it is simply returned as it is.
  79378. * @param kind defines vertex data kind:
  79379. * * VertexBuffer.PositionKind
  79380. * * VertexBuffer.UVKind
  79381. * * VertexBuffer.UV2Kind
  79382. * * VertexBuffer.UV3Kind
  79383. * * VertexBuffer.UV4Kind
  79384. * * VertexBuffer.UV5Kind
  79385. * * VertexBuffer.UV6Kind
  79386. * * VertexBuffer.ColorKind
  79387. * * VertexBuffer.MatricesIndicesKind
  79388. * * VertexBuffer.MatricesIndicesExtraKind
  79389. * * VertexBuffer.MatricesWeightsKind
  79390. * * VertexBuffer.MatricesWeightsExtraKind
  79391. * @param data defines the data source
  79392. * @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
  79393. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79394. * @returns the current mesh
  79395. */
  79396. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  79397. /**
  79398. * Sets the mesh indices,
  79399. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79400. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79401. * @param totalVertices Defines the total number of vertices
  79402. * @returns the current mesh
  79403. */
  79404. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  79405. /**
  79406. * Gets a boolean indicating if specific vertex data is present
  79407. * @param kind defines the vertex data kind to use
  79408. * @returns true is data kind is present
  79409. */
  79410. isVerticesDataPresent(kind: string): boolean;
  79411. /**
  79412. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79413. * @returns a BoundingInfo
  79414. */
  79415. getBoundingInfo(): BoundingInfo;
  79416. /**
  79417. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79418. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79419. * @returns the current mesh
  79420. */
  79421. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  79422. /**
  79423. * Overwrite the current bounding info
  79424. * @param boundingInfo defines the new bounding info
  79425. * @returns the current mesh
  79426. */
  79427. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  79428. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79429. readonly useBones: boolean;
  79430. /** @hidden */
  79431. _preActivate(): void;
  79432. /** @hidden */
  79433. _preActivateForIntermediateRendering(renderId: number): void;
  79434. /** @hidden */
  79435. _activate(renderId: number): void;
  79436. /**
  79437. * Gets the current world matrix
  79438. * @returns a Matrix
  79439. */
  79440. getWorldMatrix(): Matrix;
  79441. /** @hidden */
  79442. _getWorldMatrixDeterminant(): number;
  79443. /**
  79444. * Perform relative position change from the point of view of behind the front of the mesh.
  79445. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79446. * Supports definition of mesh facing forward or backward
  79447. * @param amountRight defines the distance on the right axis
  79448. * @param amountUp defines the distance on the up axis
  79449. * @param amountForward defines the distance on the forward axis
  79450. * @returns the current mesh
  79451. */
  79452. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  79453. /**
  79454. * Calculate relative position change from the point of view of behind the front of the mesh.
  79455. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79456. * Supports definition of mesh facing forward or backward
  79457. * @param amountRight defines the distance on the right axis
  79458. * @param amountUp defines the distance on the up axis
  79459. * @param amountForward defines the distance on the forward axis
  79460. * @returns the new displacement vector
  79461. */
  79462. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  79463. /**
  79464. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79465. * Supports definition of mesh facing forward or backward
  79466. * @param flipBack defines the flip
  79467. * @param twirlClockwise defines the twirl
  79468. * @param tiltRight defines the tilt
  79469. * @returns the current mesh
  79470. */
  79471. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  79472. /**
  79473. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79474. * Supports definition of mesh facing forward or backward.
  79475. * @param flipBack defines the flip
  79476. * @param twirlClockwise defines the twirl
  79477. * @param tiltRight defines the tilt
  79478. * @returns the new rotation vector
  79479. */
  79480. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  79481. /**
  79482. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79483. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79484. * @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
  79485. * @returns the new bounding vectors
  79486. */
  79487. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  79488. min: Vector3;
  79489. max: Vector3;
  79490. };
  79491. /**
  79492. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79493. * This means the mesh underlying bounding box and sphere are recomputed.
  79494. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79495. * @returns the current mesh
  79496. */
  79497. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  79498. /** @hidden */
  79499. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  79500. /** @hidden */
  79501. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  79502. /** @hidden */
  79503. _updateBoundingInfo(): AbstractMesh;
  79504. /** @hidden */
  79505. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  79506. /** @hidden */
  79507. protected _afterComputeWorldMatrix(): void;
  79508. /**
  79509. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79510. * A mesh is in the frustum if its bounding box intersects the frustum
  79511. * @param frustumPlanes defines the frustum to test
  79512. * @returns true if the mesh is in the frustum planes
  79513. */
  79514. isInFrustum(frustumPlanes: Plane[]): boolean;
  79515. /**
  79516. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79517. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79518. * @param frustumPlanes defines the frustum to test
  79519. * @returns true if the mesh is completely in the frustum planes
  79520. */
  79521. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79522. /**
  79523. * True if the mesh intersects another mesh or a SolidParticle object
  79524. * @param mesh defines a target mesh or SolidParticle to test
  79525. * @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)
  79526. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79527. * @returns true if there is an intersection
  79528. */
  79529. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  79530. /**
  79531. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79532. * @param point defines the point to test
  79533. * @returns true if there is an intersection
  79534. */
  79535. intersectsPoint(point: Vector3): boolean;
  79536. /**
  79537. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79539. */
  79540. checkCollisions: boolean;
  79541. /**
  79542. * Gets Collider object used to compute collisions (not physics)
  79543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79544. */
  79545. readonly collider: Collider;
  79546. /**
  79547. * Move the mesh using collision engine
  79548. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79549. * @param displacement defines the requested displacement vector
  79550. * @returns the current mesh
  79551. */
  79552. moveWithCollisions(displacement: Vector3): AbstractMesh;
  79553. private _onCollisionPositionChange;
  79554. /** @hidden */
  79555. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  79556. /** @hidden */
  79557. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  79558. /** @hidden */
  79559. _checkCollision(collider: Collider): AbstractMesh;
  79560. /** @hidden */
  79561. _generatePointsArray(): boolean;
  79562. /**
  79563. * Checks if the passed Ray intersects with the mesh
  79564. * @param ray defines the ray to use
  79565. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79566. * @returns the picking info
  79567. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79568. */
  79569. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  79570. /**
  79571. * Clones the current mesh
  79572. * @param name defines the mesh name
  79573. * @param newParent defines the new mesh parent
  79574. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79575. * @returns the new mesh
  79576. */
  79577. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  79578. /**
  79579. * Disposes all the submeshes of the current meshnp
  79580. * @returns the current mesh
  79581. */
  79582. releaseSubMeshes(): AbstractMesh;
  79583. /**
  79584. * Releases resources associated with this abstract mesh.
  79585. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79586. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79587. */
  79588. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79589. /**
  79590. * Adds the passed mesh as a child to the current mesh
  79591. * @param mesh defines the child mesh
  79592. * @returns the current mesh
  79593. */
  79594. addChild(mesh: AbstractMesh): AbstractMesh;
  79595. /**
  79596. * Removes the passed mesh from the current mesh children list
  79597. * @param mesh defines the child mesh
  79598. * @returns the current mesh
  79599. */
  79600. removeChild(mesh: AbstractMesh): AbstractMesh;
  79601. /** @hidden */
  79602. private _initFacetData;
  79603. /**
  79604. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79605. * This method can be called within the render loop.
  79606. * 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
  79607. * @returns the current mesh
  79608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79609. */
  79610. updateFacetData(): AbstractMesh;
  79611. /**
  79612. * Returns the facetLocalNormals array.
  79613. * The normals are expressed in the mesh local spac
  79614. * @returns an array of Vector3
  79615. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79616. */
  79617. getFacetLocalNormals(): Vector3[];
  79618. /**
  79619. * Returns the facetLocalPositions array.
  79620. * The facet positions are expressed in the mesh local space
  79621. * @returns an array of Vector3
  79622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79623. */
  79624. getFacetLocalPositions(): Vector3[];
  79625. /**
  79626. * Returns the facetLocalPartioning array
  79627. * @returns an array of array of numbers
  79628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79629. */
  79630. getFacetLocalPartitioning(): number[][];
  79631. /**
  79632. * Returns the i-th facet position in the world system.
  79633. * This method allocates a new Vector3 per call
  79634. * @param i defines the facet index
  79635. * @returns a new Vector3
  79636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79637. */
  79638. getFacetPosition(i: number): Vector3;
  79639. /**
  79640. * Sets the reference Vector3 with the i-th facet position in the world system
  79641. * @param i defines the facet index
  79642. * @param ref defines the target vector
  79643. * @returns the current mesh
  79644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79645. */
  79646. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  79647. /**
  79648. * Returns the i-th facet normal in the world system.
  79649. * This method allocates a new Vector3 per call
  79650. * @param i defines the facet index
  79651. * @returns a new Vector3
  79652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79653. */
  79654. getFacetNormal(i: number): Vector3;
  79655. /**
  79656. * Sets the reference Vector3 with the i-th facet normal in the world system
  79657. * @param i defines the facet index
  79658. * @param ref defines the target vector
  79659. * @returns the current mesh
  79660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79661. */
  79662. getFacetNormalToRef(i: number, ref: Vector3): this;
  79663. /**
  79664. * 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)
  79665. * @param x defines x coordinate
  79666. * @param y defines y coordinate
  79667. * @param z defines z coordinate
  79668. * @returns the array of facet indexes
  79669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79670. */
  79671. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  79672. /**
  79673. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79674. * @param projected sets as the (x,y,z) world projection on the facet
  79675. * @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
  79676. * @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
  79677. * @param x defines x coordinate
  79678. * @param y defines y coordinate
  79679. * @param z defines z coordinate
  79680. * @returns the face index if found (or null instead)
  79681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79682. */
  79683. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79684. /**
  79685. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79686. * @param projected sets as the (x,y,z) local projection on the facet
  79687. * @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
  79688. * @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
  79689. * @param x defines x coordinate
  79690. * @param y defines y coordinate
  79691. * @param z defines z coordinate
  79692. * @returns the face index if found (or null instead)
  79693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79694. */
  79695. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79696. /**
  79697. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79698. * @returns the parameters
  79699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79700. */
  79701. getFacetDataParameters(): any;
  79702. /**
  79703. * Disables the feature FacetData and frees the related memory
  79704. * @returns the current mesh
  79705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79706. */
  79707. disableFacetData(): AbstractMesh;
  79708. /**
  79709. * Updates the AbstractMesh indices array
  79710. * @param indices defines the data source
  79711. * @returns the current mesh
  79712. */
  79713. updateIndices(indices: IndicesArray): AbstractMesh;
  79714. /**
  79715. * Creates new normals data for the mesh
  79716. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  79717. * @returns the current mesh
  79718. */
  79719. createNormals(updatable: boolean): AbstractMesh;
  79720. /**
  79721. * Align the mesh with a normal
  79722. * @param normal defines the normal to use
  79723. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  79724. * @returns the current mesh
  79725. */
  79726. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  79727. /** @hidden */
  79728. _checkOcclusionQuery(): boolean;
  79729. }
  79730. }
  79731. declare module BABYLON {
  79732. /**
  79733. * Class used to handle skinning animations
  79734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79735. */
  79736. export class Skeleton implements IAnimatable {
  79737. /** defines the skeleton name */
  79738. name: string;
  79739. /** defines the skeleton Id */
  79740. id: string;
  79741. /**
  79742. * Defines the list of child bones
  79743. */
  79744. bones: Bone[];
  79745. /**
  79746. * Defines an estimate of the dimension of the skeleton at rest
  79747. */
  79748. dimensionsAtRest: Vector3;
  79749. /**
  79750. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79751. */
  79752. needInitialSkinMatrix: boolean;
  79753. /**
  79754. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79755. */
  79756. overrideMesh: Nullable<AbstractMesh>;
  79757. /**
  79758. * Gets the list of animations attached to this skeleton
  79759. */
  79760. animations: Array<Animation>;
  79761. private _scene;
  79762. private _isDirty;
  79763. private _transformMatrices;
  79764. private _transformMatrixTexture;
  79765. private _meshesWithPoseMatrix;
  79766. private _animatables;
  79767. private _identity;
  79768. private _synchronizedWithMesh;
  79769. private _ranges;
  79770. private _lastAbsoluteTransformsUpdateId;
  79771. private _canUseTextureForBones;
  79772. /** @hidden */
  79773. _numBonesWithLinkedTransformNode: number;
  79774. /**
  79775. * Specifies if the skeleton should be serialized
  79776. */
  79777. doNotSerialize: boolean;
  79778. /**
  79779. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79780. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79781. */
  79782. useTextureToStoreBoneMatrices: boolean;
  79783. private _animationPropertiesOverride;
  79784. /**
  79785. * Gets or sets the animation properties override
  79786. */
  79787. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79788. /**
  79789. * An observable triggered before computing the skeleton's matrices
  79790. */
  79791. onBeforeComputeObservable: Observable<Skeleton>;
  79792. /**
  79793. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79794. */
  79795. readonly isUsingTextureForMatrices: boolean;
  79796. /**
  79797. * Creates a new skeleton
  79798. * @param name defines the skeleton name
  79799. * @param id defines the skeleton Id
  79800. * @param scene defines the hosting scene
  79801. */
  79802. constructor(
  79803. /** defines the skeleton name */
  79804. name: string,
  79805. /** defines the skeleton Id */
  79806. id: string, scene: Scene);
  79807. /**
  79808. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79809. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79810. * @returns a Float32Array containing matrices data
  79811. */
  79812. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79813. /**
  79814. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79815. * @returns a raw texture containing the data
  79816. */
  79817. getTransformMatrixTexture(): Nullable<RawTexture>;
  79818. /**
  79819. * Gets the current hosting scene
  79820. * @returns a scene object
  79821. */
  79822. getScene(): Scene;
  79823. /**
  79824. * Gets a string representing the current skeleton data
  79825. * @param fullDetails defines a boolean indicating if we want a verbose version
  79826. * @returns a string representing the current skeleton data
  79827. */
  79828. toString(fullDetails?: boolean): string;
  79829. /**
  79830. * Get bone's index searching by name
  79831. * @param name defines bone's name to search for
  79832. * @return the indice of the bone. Returns -1 if not found
  79833. */
  79834. getBoneIndexByName(name: string): number;
  79835. /**
  79836. * Creater a new animation range
  79837. * @param name defines the name of the range
  79838. * @param from defines the start key
  79839. * @param to defines the end key
  79840. */
  79841. createAnimationRange(name: string, from: number, to: number): void;
  79842. /**
  79843. * Delete a specific animation range
  79844. * @param name defines the name of the range
  79845. * @param deleteFrames defines if frames must be removed as well
  79846. */
  79847. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79848. /**
  79849. * Gets a specific animation range
  79850. * @param name defines the name of the range to look for
  79851. * @returns the requested animation range or null if not found
  79852. */
  79853. getAnimationRange(name: string): Nullable<AnimationRange>;
  79854. /**
  79855. * Gets the list of all animation ranges defined on this skeleton
  79856. * @returns an array
  79857. */
  79858. getAnimationRanges(): Nullable<AnimationRange>[];
  79859. /**
  79860. * Copy animation range from a source skeleton.
  79861. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79862. * @param source defines the source skeleton
  79863. * @param name defines the name of the range to copy
  79864. * @param rescaleAsRequired defines if rescaling must be applied if required
  79865. * @returns true if operation was successful
  79866. */
  79867. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79868. /**
  79869. * Forces the skeleton to go to rest pose
  79870. */
  79871. returnToRest(): void;
  79872. private _getHighestAnimationFrame;
  79873. /**
  79874. * Begin a specific animation range
  79875. * @param name defines the name of the range to start
  79876. * @param loop defines if looping must be turned on (false by default)
  79877. * @param speedRatio defines the speed ratio to apply (1 by default)
  79878. * @param onAnimationEnd defines a callback which will be called when animation will end
  79879. * @returns a new animatable
  79880. */
  79881. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79882. /** @hidden */
  79883. _markAsDirty(): void;
  79884. /** @hidden */
  79885. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79886. /** @hidden */
  79887. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79888. private _computeTransformMatrices;
  79889. /**
  79890. * Build all resources required to render a skeleton
  79891. */
  79892. prepare(): void;
  79893. /**
  79894. * Gets the list of animatables currently running for this skeleton
  79895. * @returns an array of animatables
  79896. */
  79897. getAnimatables(): IAnimatable[];
  79898. /**
  79899. * Clone the current skeleton
  79900. * @param name defines the name of the new skeleton
  79901. * @param id defines the id of the enw skeleton
  79902. * @returns the new skeleton
  79903. */
  79904. clone(name: string, id: string): Skeleton;
  79905. /**
  79906. * Enable animation blending for this skeleton
  79907. * @param blendingSpeed defines the blending speed to apply
  79908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79909. */
  79910. enableBlending(blendingSpeed?: number): void;
  79911. /**
  79912. * Releases all resources associated with the current skeleton
  79913. */
  79914. dispose(): void;
  79915. /**
  79916. * Serialize the skeleton in a JSON object
  79917. * @returns a JSON object
  79918. */
  79919. serialize(): any;
  79920. /**
  79921. * Creates a new skeleton from serialized data
  79922. * @param parsedSkeleton defines the serialized data
  79923. * @param scene defines the hosting scene
  79924. * @returns a new skeleton
  79925. */
  79926. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79927. /**
  79928. * Compute all node absolute transforms
  79929. * @param forceUpdate defines if computation must be done even if cache is up to date
  79930. */
  79931. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79932. /**
  79933. * Gets the root pose matrix
  79934. * @returns a matrix
  79935. */
  79936. getPoseMatrix(): Nullable<Matrix>;
  79937. /**
  79938. * Sorts bones per internal index
  79939. */
  79940. sortBones(): void;
  79941. private _sortBones;
  79942. }
  79943. }
  79944. declare module BABYLON {
  79945. /**
  79946. * Class used to store bone information
  79947. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79948. */
  79949. export class Bone extends Node {
  79950. /**
  79951. * defines the bone name
  79952. */
  79953. name: string;
  79954. private static _tmpVecs;
  79955. private static _tmpQuat;
  79956. private static _tmpMats;
  79957. /**
  79958. * Gets the list of child bones
  79959. */
  79960. children: Bone[];
  79961. /** Gets the animations associated with this bone */
  79962. animations: Animation[];
  79963. /**
  79964. * Gets or sets bone length
  79965. */
  79966. length: number;
  79967. /**
  79968. * @hidden Internal only
  79969. * Set this value to map this bone to a different index in the transform matrices
  79970. * Set this value to -1 to exclude the bone from the transform matrices
  79971. */
  79972. _index: Nullable<number>;
  79973. private _skeleton;
  79974. private _localMatrix;
  79975. private _restPose;
  79976. private _baseMatrix;
  79977. private _absoluteTransform;
  79978. private _invertedAbsoluteTransform;
  79979. private _parent;
  79980. private _scalingDeterminant;
  79981. private _worldTransform;
  79982. private _localScaling;
  79983. private _localRotation;
  79984. private _localPosition;
  79985. private _needToDecompose;
  79986. private _needToCompose;
  79987. /** @hidden */
  79988. _linkedTransformNode: Nullable<TransformNode>;
  79989. /** @hidden */
  79990. /** @hidden */
  79991. _matrix: Matrix;
  79992. /**
  79993. * Create a new bone
  79994. * @param name defines the bone name
  79995. * @param skeleton defines the parent skeleton
  79996. * @param parentBone defines the parent (can be null if the bone is the root)
  79997. * @param localMatrix defines the local matrix
  79998. * @param restPose defines the rest pose matrix
  79999. * @param baseMatrix defines the base matrix
  80000. * @param index defines index of the bone in the hiearchy
  80001. */
  80002. constructor(
  80003. /**
  80004. * defines the bone name
  80005. */
  80006. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80007. /**
  80008. * Gets the parent skeleton
  80009. * @returns a skeleton
  80010. */
  80011. getSkeleton(): Skeleton;
  80012. /**
  80013. * Gets parent bone
  80014. * @returns a bone or null if the bone is the root of the bone hierarchy
  80015. */
  80016. getParent(): Nullable<Bone>;
  80017. /**
  80018. * Sets the parent bone
  80019. * @param parent defines the parent (can be null if the bone is the root)
  80020. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80021. */
  80022. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80023. /**
  80024. * Gets the local matrix
  80025. * @returns a matrix
  80026. */
  80027. getLocalMatrix(): Matrix;
  80028. /**
  80029. * Gets the base matrix (initial matrix which remains unchanged)
  80030. * @returns a matrix
  80031. */
  80032. getBaseMatrix(): Matrix;
  80033. /**
  80034. * Gets the rest pose matrix
  80035. * @returns a matrix
  80036. */
  80037. getRestPose(): Matrix;
  80038. /**
  80039. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80040. */
  80041. getWorldMatrix(): Matrix;
  80042. /**
  80043. * Sets the local matrix to rest pose matrix
  80044. */
  80045. returnToRest(): void;
  80046. /**
  80047. * Gets the inverse of the absolute transform matrix.
  80048. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80049. * @returns a matrix
  80050. */
  80051. getInvertedAbsoluteTransform(): Matrix;
  80052. /**
  80053. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80054. * @returns a matrix
  80055. */
  80056. getAbsoluteTransform(): Matrix;
  80057. /**
  80058. * Links with the given transform node.
  80059. * The local matrix of this bone is copied from the transform node every frame.
  80060. * @param transformNode defines the transform node to link to
  80061. */
  80062. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80063. /** Gets or sets current position (in local space) */
  80064. position: Vector3;
  80065. /** Gets or sets current rotation (in local space) */
  80066. rotation: Vector3;
  80067. /** Gets or sets current rotation quaternion (in local space) */
  80068. rotationQuaternion: Quaternion;
  80069. /** Gets or sets current scaling (in local space) */
  80070. scaling: Vector3;
  80071. /**
  80072. * Gets the animation properties override
  80073. */
  80074. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80075. private _decompose;
  80076. private _compose;
  80077. /**
  80078. * Update the base and local matrices
  80079. * @param matrix defines the new base or local matrix
  80080. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80081. * @param updateLocalMatrix defines if the local matrix should be updated
  80082. */
  80083. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80084. /** @hidden */
  80085. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80086. /**
  80087. * Flag the bone as dirty (Forcing it to update everything)
  80088. */
  80089. markAsDirty(): void;
  80090. private _markAsDirtyAndCompose;
  80091. private _markAsDirtyAndDecompose;
  80092. /**
  80093. * Translate the bone in local or world space
  80094. * @param vec The amount to translate the bone
  80095. * @param space The space that the translation is in
  80096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80097. */
  80098. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80099. /**
  80100. * Set the postion of the bone in local or world space
  80101. * @param position The position to set the bone
  80102. * @param space The space that the position is in
  80103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80104. */
  80105. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80106. /**
  80107. * Set the absolute position of the bone (world space)
  80108. * @param position The position to set the bone
  80109. * @param mesh The mesh that this bone is attached to
  80110. */
  80111. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80112. /**
  80113. * Scale the bone on the x, y and z axes (in local space)
  80114. * @param x The amount to scale the bone on the x axis
  80115. * @param y The amount to scale the bone on the y axis
  80116. * @param z The amount to scale the bone on the z axis
  80117. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80118. */
  80119. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80120. /**
  80121. * Set the bone scaling in local space
  80122. * @param scale defines the scaling vector
  80123. */
  80124. setScale(scale: Vector3): void;
  80125. /**
  80126. * Gets the current scaling in local space
  80127. * @returns the current scaling vector
  80128. */
  80129. getScale(): Vector3;
  80130. /**
  80131. * Gets the current scaling in local space and stores it in a target vector
  80132. * @param result defines the target vector
  80133. */
  80134. getScaleToRef(result: Vector3): void;
  80135. /**
  80136. * Set the yaw, pitch, and roll of the bone in local or world space
  80137. * @param yaw The rotation of the bone on the y axis
  80138. * @param pitch The rotation of the bone on the x axis
  80139. * @param roll The rotation of the bone on the z axis
  80140. * @param space The space that the axes of rotation are in
  80141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80142. */
  80143. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80144. /**
  80145. * Add a rotation to the bone on an axis in local or world space
  80146. * @param axis The axis to rotate the bone on
  80147. * @param amount The amount to rotate the bone
  80148. * @param space The space that the axis is in
  80149. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80150. */
  80151. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80152. /**
  80153. * Set the rotation of the bone to a particular axis angle in local or world space
  80154. * @param axis The axis to rotate the bone on
  80155. * @param angle The angle that the bone should be rotated to
  80156. * @param space The space that the axis is in
  80157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80158. */
  80159. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80160. /**
  80161. * Set the euler rotation of the bone in local of world space
  80162. * @param rotation The euler rotation that the bone should be set to
  80163. * @param space The space that the rotation is in
  80164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80165. */
  80166. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80167. /**
  80168. * Set the quaternion rotation of the bone in local of world space
  80169. * @param quat The quaternion rotation that the bone should be set to
  80170. * @param space The space that the rotation is in
  80171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80172. */
  80173. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80174. /**
  80175. * Set the rotation matrix of the bone in local of world space
  80176. * @param rotMat The rotation matrix that the bone should be set to
  80177. * @param space The space that the rotation is in
  80178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80179. */
  80180. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80181. private _rotateWithMatrix;
  80182. private _getNegativeRotationToRef;
  80183. /**
  80184. * Get the position of the bone in local or world space
  80185. * @param space The space that the returned position is in
  80186. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80187. * @returns The position of the bone
  80188. */
  80189. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80190. /**
  80191. * Copy the position of the bone to a vector3 in local or world space
  80192. * @param space The space that the returned position is in
  80193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80194. * @param result The vector3 to copy the position to
  80195. */
  80196. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80197. /**
  80198. * Get the absolute position of the bone (world space)
  80199. * @param mesh The mesh that this bone is attached to
  80200. * @returns The absolute position of the bone
  80201. */
  80202. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80203. /**
  80204. * Copy the absolute position of the bone (world space) to the result param
  80205. * @param mesh The mesh that this bone is attached to
  80206. * @param result The vector3 to copy the absolute position to
  80207. */
  80208. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80209. /**
  80210. * Compute the absolute transforms of this bone and its children
  80211. */
  80212. computeAbsoluteTransforms(): void;
  80213. /**
  80214. * Get the world direction from an axis that is in the local space of the bone
  80215. * @param localAxis The local direction that is used to compute the world direction
  80216. * @param mesh The mesh that this bone is attached to
  80217. * @returns The world direction
  80218. */
  80219. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80220. /**
  80221. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80222. * @param localAxis The local direction that is used to compute the world direction
  80223. * @param mesh The mesh that this bone is attached to
  80224. * @param result The vector3 that the world direction will be copied to
  80225. */
  80226. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80227. /**
  80228. * Get the euler rotation of the bone in local or world space
  80229. * @param space The space that the rotation should be in
  80230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80231. * @returns The euler rotation
  80232. */
  80233. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80234. /**
  80235. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80236. * @param space The space that the rotation should be in
  80237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80238. * @param result The vector3 that the rotation should be copied to
  80239. */
  80240. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80241. /**
  80242. * Get the quaternion rotation of the bone in either local or world space
  80243. * @param space The space that the rotation should be in
  80244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80245. * @returns The quaternion rotation
  80246. */
  80247. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80248. /**
  80249. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80250. * @param space The space that the rotation should be in
  80251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80252. * @param result The quaternion that the rotation should be copied to
  80253. */
  80254. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80255. /**
  80256. * Get the rotation matrix of the bone in local or world space
  80257. * @param space The space that the rotation should be in
  80258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80259. * @returns The rotation matrix
  80260. */
  80261. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80262. /**
  80263. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80264. * @param space The space that the rotation should be in
  80265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80266. * @param result The quaternion that the rotation should be copied to
  80267. */
  80268. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80269. /**
  80270. * Get the world position of a point that is in the local space of the bone
  80271. * @param position The local position
  80272. * @param mesh The mesh that this bone is attached to
  80273. * @returns The world position
  80274. */
  80275. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80276. /**
  80277. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80278. * @param position The local position
  80279. * @param mesh The mesh that this bone is attached to
  80280. * @param result The vector3 that the world position should be copied to
  80281. */
  80282. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80283. /**
  80284. * Get the local position of a point that is in world space
  80285. * @param position The world position
  80286. * @param mesh The mesh that this bone is attached to
  80287. * @returns The local position
  80288. */
  80289. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80290. /**
  80291. * Get the local position of a point that is in world space and copy it to the result param
  80292. * @param position The world position
  80293. * @param mesh The mesh that this bone is attached to
  80294. * @param result The vector3 that the local position should be copied to
  80295. */
  80296. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * Class used to store an actual running animation
  80302. */
  80303. export class Animatable {
  80304. /** defines the target object */
  80305. target: any;
  80306. /** defines the starting frame number (default is 0) */
  80307. fromFrame: number;
  80308. /** defines the ending frame number (default is 100) */
  80309. toFrame: number;
  80310. /** defines if the animation must loop (default is false) */
  80311. loopAnimation: boolean;
  80312. /** defines a callback to call when animation ends if it is not looping */
  80313. onAnimationEnd?: (() => void) | null | undefined;
  80314. /** defines a callback to call when animation loops */
  80315. onAnimationLoop?: (() => void) | null | undefined;
  80316. private _localDelayOffset;
  80317. private _pausedDelay;
  80318. private _runtimeAnimations;
  80319. private _paused;
  80320. private _scene;
  80321. private _speedRatio;
  80322. private _weight;
  80323. private _syncRoot;
  80324. /**
  80325. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80326. * This will only apply for non looping animation (default is true)
  80327. */
  80328. disposeOnEnd: boolean;
  80329. /**
  80330. * Gets a boolean indicating if the animation has started
  80331. */
  80332. animationStarted: boolean;
  80333. /**
  80334. * Observer raised when the animation ends
  80335. */
  80336. onAnimationEndObservable: Observable<Animatable>;
  80337. /**
  80338. * Observer raised when the animation loops
  80339. */
  80340. onAnimationLoopObservable: Observable<Animatable>;
  80341. /**
  80342. * Gets the root Animatable used to synchronize and normalize animations
  80343. */
  80344. readonly syncRoot: Animatable;
  80345. /**
  80346. * Gets the current frame of the first RuntimeAnimation
  80347. * Used to synchronize Animatables
  80348. */
  80349. readonly masterFrame: number;
  80350. /**
  80351. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80352. */
  80353. weight: number;
  80354. /**
  80355. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80356. */
  80357. speedRatio: number;
  80358. /**
  80359. * Creates a new Animatable
  80360. * @param scene defines the hosting scene
  80361. * @param target defines the target object
  80362. * @param fromFrame defines the starting frame number (default is 0)
  80363. * @param toFrame defines the ending frame number (default is 100)
  80364. * @param loopAnimation defines if the animation must loop (default is false)
  80365. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80366. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80367. * @param animations defines a group of animation to add to the new Animatable
  80368. * @param onAnimationLoop defines a callback to call when animation loops
  80369. */
  80370. constructor(scene: Scene,
  80371. /** defines the target object */
  80372. target: any,
  80373. /** defines the starting frame number (default is 0) */
  80374. fromFrame?: number,
  80375. /** defines the ending frame number (default is 100) */
  80376. toFrame?: number,
  80377. /** defines if the animation must loop (default is false) */
  80378. loopAnimation?: boolean, speedRatio?: number,
  80379. /** defines a callback to call when animation ends if it is not looping */
  80380. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80381. /** defines a callback to call when animation loops */
  80382. onAnimationLoop?: (() => void) | null | undefined);
  80383. /**
  80384. * Synchronize and normalize current Animatable with a source Animatable
  80385. * This is useful when using animation weights and when animations are not of the same length
  80386. * @param root defines the root Animatable to synchronize with
  80387. * @returns the current Animatable
  80388. */
  80389. syncWith(root: Animatable): Animatable;
  80390. /**
  80391. * Gets the list of runtime animations
  80392. * @returns an array of RuntimeAnimation
  80393. */
  80394. getAnimations(): RuntimeAnimation[];
  80395. /**
  80396. * Adds more animations to the current animatable
  80397. * @param target defines the target of the animations
  80398. * @param animations defines the new animations to add
  80399. */
  80400. appendAnimations(target: any, animations: Animation[]): void;
  80401. /**
  80402. * Gets the source animation for a specific property
  80403. * @param property defines the propertyu to look for
  80404. * @returns null or the source animation for the given property
  80405. */
  80406. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80407. /**
  80408. * Gets the runtime animation for a specific property
  80409. * @param property defines the propertyu to look for
  80410. * @returns null or the runtime animation for the given property
  80411. */
  80412. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80413. /**
  80414. * Resets the animatable to its original state
  80415. */
  80416. reset(): void;
  80417. /**
  80418. * Allows the animatable to blend with current running animations
  80419. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80420. * @param blendingSpeed defines the blending speed to use
  80421. */
  80422. enableBlending(blendingSpeed: number): void;
  80423. /**
  80424. * Disable animation blending
  80425. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80426. */
  80427. disableBlending(): void;
  80428. /**
  80429. * Jump directly to a given frame
  80430. * @param frame defines the frame to jump to
  80431. */
  80432. goToFrame(frame: number): void;
  80433. /**
  80434. * Pause the animation
  80435. */
  80436. pause(): void;
  80437. /**
  80438. * Restart the animation
  80439. */
  80440. restart(): void;
  80441. private _raiseOnAnimationEnd;
  80442. /**
  80443. * Stop and delete the current animation
  80444. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80445. * @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)
  80446. */
  80447. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80448. /**
  80449. * Wait asynchronously for the animation to end
  80450. * @returns a promise which will be fullfilled when the animation ends
  80451. */
  80452. waitAsync(): Promise<Animatable>;
  80453. /** @hidden */
  80454. _animate(delay: number): boolean;
  80455. }
  80456. interface Scene {
  80457. /** @hidden */
  80458. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80459. /** @hidden */
  80460. _processLateAnimationBindingsForMatrices(holder: {
  80461. totalWeight: number;
  80462. animations: RuntimeAnimation[];
  80463. originalValue: Matrix;
  80464. }): any;
  80465. /** @hidden */
  80466. _processLateAnimationBindingsForQuaternions(holder: {
  80467. totalWeight: number;
  80468. animations: RuntimeAnimation[];
  80469. originalValue: Quaternion;
  80470. }, refQuaternion: Quaternion): Quaternion;
  80471. /** @hidden */
  80472. _processLateAnimationBindings(): void;
  80473. /**
  80474. * Will start the animation sequence of a given target
  80475. * @param target defines the target
  80476. * @param from defines from which frame should animation start
  80477. * @param to defines until which frame should animation run.
  80478. * @param weight defines the weight to apply to the animation (1.0 by default)
  80479. * @param loop defines if the animation loops
  80480. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80481. * @param onAnimationEnd defines the function to be executed when the animation ends
  80482. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80483. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80484. * @param onAnimationLoop defines the callback to call when an animation loops
  80485. * @returns the animatable object created for this animation
  80486. */
  80487. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80488. /**
  80489. * Will start the animation sequence of a given target
  80490. * @param target defines the target
  80491. * @param from defines from which frame should animation start
  80492. * @param to defines until which frame should animation run.
  80493. * @param loop defines if the animation loops
  80494. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80495. * @param onAnimationEnd defines the function to be executed when the animation ends
  80496. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80497. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80498. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80499. * @param onAnimationLoop defines the callback to call when an animation loops
  80500. * @returns the animatable object created for this animation
  80501. */
  80502. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80503. /**
  80504. * Will start the animation sequence of a given target and its hierarchy
  80505. * @param target defines the target
  80506. * @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.
  80507. * @param from defines from which frame should animation start
  80508. * @param to defines until which frame should animation run.
  80509. * @param loop defines if the animation loops
  80510. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80511. * @param onAnimationEnd defines the function to be executed when the animation ends
  80512. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80513. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80514. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80515. * @param onAnimationLoop defines the callback to call when an animation loops
  80516. * @returns the list of created animatables
  80517. */
  80518. 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[];
  80519. /**
  80520. * Begin a new animation on a given node
  80521. * @param target defines the target where the animation will take place
  80522. * @param animations defines the list of animations to start
  80523. * @param from defines the initial value
  80524. * @param to defines the final value
  80525. * @param loop defines if you want animation to loop (off by default)
  80526. * @param speedRatio defines the speed ratio to apply to all animations
  80527. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80528. * @param onAnimationLoop defines the callback to call when an animation loops
  80529. * @returns the list of created animatables
  80530. */
  80531. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80532. /**
  80533. * Begin a new animation on a given node and its hierarchy
  80534. * @param target defines the root node where the animation will take place
  80535. * @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.
  80536. * @param animations defines the list of animations to start
  80537. * @param from defines the initial value
  80538. * @param to defines the final value
  80539. * @param loop defines if you want animation to loop (off by default)
  80540. * @param speedRatio defines the speed ratio to apply to all animations
  80541. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80542. * @param onAnimationLoop defines the callback to call when an animation loops
  80543. * @returns the list of animatables created for all nodes
  80544. */
  80545. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80546. /**
  80547. * Gets the animatable associated with a specific target
  80548. * @param target defines the target of the animatable
  80549. * @returns the required animatable if found
  80550. */
  80551. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80552. /**
  80553. * Gets all animatables associated with a given target
  80554. * @param target defines the target to look animatables for
  80555. * @returns an array of Animatables
  80556. */
  80557. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80558. /**
  80559. * Will stop the animation of the given target
  80560. * @param target - the target
  80561. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  80562. * @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)
  80563. */
  80564. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  80565. /**
  80566. * Stops and removes all animations that have been applied to the scene
  80567. */
  80568. stopAllAnimations(): void;
  80569. }
  80570. interface Bone {
  80571. /**
  80572. * Copy an animation range from another bone
  80573. * @param source defines the source bone
  80574. * @param rangeName defines the range name to copy
  80575. * @param frameOffset defines the frame offset
  80576. * @param rescaleAsRequired defines if rescaling must be applied if required
  80577. * @param skelDimensionsRatio defines the scaling ratio
  80578. * @returns true if operation was successful
  80579. */
  80580. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80581. }
  80582. }
  80583. declare module BABYLON {
  80584. /**
  80585. * Defines how a node can be built from a string name.
  80586. */
  80587. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80588. /**
  80589. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80590. */
  80591. export class Node implements IBehaviorAware<Node> {
  80592. /** @hidden */
  80593. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80594. private static _NodeConstructors;
  80595. /**
  80596. * Add a new node constructor
  80597. * @param type defines the type name of the node to construct
  80598. * @param constructorFunc defines the constructor function
  80599. */
  80600. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80601. /**
  80602. * Returns a node constructor based on type name
  80603. * @param type defines the type name
  80604. * @param name defines the new node name
  80605. * @param scene defines the hosting scene
  80606. * @param options defines optional options to transmit to constructors
  80607. * @returns the new constructor or null
  80608. */
  80609. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80610. /**
  80611. * Gets or sets the name of the node
  80612. */
  80613. name: string;
  80614. /**
  80615. * Gets or sets the id of the node
  80616. */
  80617. id: string;
  80618. /**
  80619. * Gets or sets the unique id of the node
  80620. */
  80621. uniqueId: number;
  80622. /**
  80623. * Gets or sets a string used to store user defined state for the node
  80624. */
  80625. state: string;
  80626. /**
  80627. * Gets or sets an object used to store user defined information for the node
  80628. */
  80629. metadata: any;
  80630. /**
  80631. * For internal use only. Please do not use.
  80632. */
  80633. reservedDataStore: any;
  80634. /**
  80635. * Gets or sets a boolean used to define if the node must be serialized
  80636. */
  80637. doNotSerialize: boolean;
  80638. /** @hidden */
  80639. _isDisposed: boolean;
  80640. /**
  80641. * Gets a list of Animations associated with the node
  80642. */
  80643. animations: Animation[];
  80644. protected _ranges: {
  80645. [name: string]: Nullable<AnimationRange>;
  80646. };
  80647. /**
  80648. * Callback raised when the node is ready to be used
  80649. */
  80650. onReady: (node: Node) => void;
  80651. private _isEnabled;
  80652. private _isParentEnabled;
  80653. private _isReady;
  80654. /** @hidden */
  80655. _currentRenderId: number;
  80656. private _parentRenderId;
  80657. protected _childRenderId: number;
  80658. /** @hidden */
  80659. _waitingParentId: Nullable<string>;
  80660. /** @hidden */
  80661. _scene: Scene;
  80662. /** @hidden */
  80663. _cache: any;
  80664. private _parentNode;
  80665. private _children;
  80666. /** @hidden */
  80667. _worldMatrix: Matrix;
  80668. /** @hidden */
  80669. _worldMatrixDeterminant: number;
  80670. /** @hidden */
  80671. private _sceneRootNodesIndex;
  80672. /**
  80673. * Gets a boolean indicating if the node has been disposed
  80674. * @returns true if the node was disposed
  80675. */
  80676. isDisposed(): boolean;
  80677. /**
  80678. * Gets or sets the parent of the node
  80679. */
  80680. parent: Nullable<Node>;
  80681. private addToSceneRootNodes;
  80682. private removeFromSceneRootNodes;
  80683. private _animationPropertiesOverride;
  80684. /**
  80685. * Gets or sets the animation properties override
  80686. */
  80687. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80688. /**
  80689. * Gets a string idenfifying the name of the class
  80690. * @returns "Node" string
  80691. */
  80692. getClassName(): string;
  80693. /** @hidden */
  80694. readonly _isNode: boolean;
  80695. /**
  80696. * An event triggered when the mesh is disposed
  80697. */
  80698. onDisposeObservable: Observable<Node>;
  80699. private _onDisposeObserver;
  80700. /**
  80701. * Sets a callback that will be raised when the node will be disposed
  80702. */
  80703. onDispose: () => void;
  80704. /**
  80705. * Creates a new Node
  80706. * @param name the name and id to be given to this node
  80707. * @param scene the scene this node will be added to
  80708. * @param addToRootNodes the node will be added to scene.rootNodes
  80709. */
  80710. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80711. /**
  80712. * Gets the scene of the node
  80713. * @returns a scene
  80714. */
  80715. getScene(): Scene;
  80716. /**
  80717. * Gets the engine of the node
  80718. * @returns a Engine
  80719. */
  80720. getEngine(): Engine;
  80721. private _behaviors;
  80722. /**
  80723. * Attach a behavior to the node
  80724. * @see http://doc.babylonjs.com/features/behaviour
  80725. * @param behavior defines the behavior to attach
  80726. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  80727. * @returns the current Node
  80728. */
  80729. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  80730. /**
  80731. * Remove an attached behavior
  80732. * @see http://doc.babylonjs.com/features/behaviour
  80733. * @param behavior defines the behavior to attach
  80734. * @returns the current Node
  80735. */
  80736. removeBehavior(behavior: Behavior<Node>): Node;
  80737. /**
  80738. * Gets the list of attached behaviors
  80739. * @see http://doc.babylonjs.com/features/behaviour
  80740. */
  80741. readonly behaviors: Behavior<Node>[];
  80742. /**
  80743. * Gets an attached behavior by name
  80744. * @param name defines the name of the behavior to look for
  80745. * @see http://doc.babylonjs.com/features/behaviour
  80746. * @returns null if behavior was not found else the requested behavior
  80747. */
  80748. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  80749. /**
  80750. * Returns the latest update of the World matrix
  80751. * @returns a Matrix
  80752. */
  80753. getWorldMatrix(): Matrix;
  80754. /** @hidden */
  80755. _getWorldMatrixDeterminant(): number;
  80756. /**
  80757. * Returns directly the latest state of the mesh World matrix.
  80758. * A Matrix is returned.
  80759. */
  80760. readonly worldMatrixFromCache: Matrix;
  80761. /** @hidden */
  80762. _initCache(): void;
  80763. /** @hidden */
  80764. updateCache(force?: boolean): void;
  80765. /** @hidden */
  80766. _updateCache(ignoreParentClass?: boolean): void;
  80767. /** @hidden */
  80768. _isSynchronized(): boolean;
  80769. /** @hidden */
  80770. _markSyncedWithParent(): void;
  80771. /** @hidden */
  80772. isSynchronizedWithParent(): boolean;
  80773. /** @hidden */
  80774. isSynchronized(): boolean;
  80775. /**
  80776. * Is this node ready to be used/rendered
  80777. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80778. * @return true if the node is ready
  80779. */
  80780. isReady(completeCheck?: boolean): boolean;
  80781. /**
  80782. * Is this node enabled?
  80783. * 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
  80784. * @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
  80785. * @return whether this node (and its parent) is enabled
  80786. */
  80787. isEnabled(checkAncestors?: boolean): boolean;
  80788. /** @hidden */
  80789. protected _syncParentEnabledState(): void;
  80790. /**
  80791. * Set the enabled state of this node
  80792. * @param value defines the new enabled state
  80793. */
  80794. setEnabled(value: boolean): void;
  80795. /**
  80796. * Is this node a descendant of the given node?
  80797. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  80798. * @param ancestor defines the parent node to inspect
  80799. * @returns a boolean indicating if this node is a descendant of the given node
  80800. */
  80801. isDescendantOf(ancestor: Node): boolean;
  80802. /** @hidden */
  80803. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  80804. /**
  80805. * Will return all nodes that have this node as ascendant
  80806. * @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
  80807. * @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
  80808. * @return all children nodes of all types
  80809. */
  80810. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  80811. /**
  80812. * Get all child-meshes of this node
  80813. * @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)
  80814. * @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
  80815. * @returns an array of AbstractMesh
  80816. */
  80817. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  80818. /**
  80819. * Get all direct children of this node
  80820. * @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
  80821. * @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)
  80822. * @returns an array of Node
  80823. */
  80824. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  80825. /** @hidden */
  80826. _setReady(state: boolean): void;
  80827. /**
  80828. * Get an animation by name
  80829. * @param name defines the name of the animation to look for
  80830. * @returns null if not found else the requested animation
  80831. */
  80832. getAnimationByName(name: string): Nullable<Animation>;
  80833. /**
  80834. * Creates an animation range for this node
  80835. * @param name defines the name of the range
  80836. * @param from defines the starting key
  80837. * @param to defines the end key
  80838. */
  80839. createAnimationRange(name: string, from: number, to: number): void;
  80840. /**
  80841. * Delete a specific animation range
  80842. * @param name defines the name of the range to delete
  80843. * @param deleteFrames defines if animation frames from the range must be deleted as well
  80844. */
  80845. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80846. /**
  80847. * Get an animation range by name
  80848. * @param name defines the name of the animation range to look for
  80849. * @returns null if not found else the requested animation range
  80850. */
  80851. getAnimationRange(name: string): Nullable<AnimationRange>;
  80852. /**
  80853. * Will start the animation sequence
  80854. * @param name defines the range frames for animation sequence
  80855. * @param loop defines if the animation should loop (false by default)
  80856. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  80857. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  80858. * @returns the object created for this animation. If range does not exist, it will return null
  80859. */
  80860. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80861. /**
  80862. * Serialize animation ranges into a JSON compatible object
  80863. * @returns serialization object
  80864. */
  80865. serializeAnimationRanges(): any;
  80866. /**
  80867. * Computes the world matrix of the node
  80868. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80869. * @returns the world matrix
  80870. */
  80871. computeWorldMatrix(force?: boolean): Matrix;
  80872. /**
  80873. * Releases resources associated with this node.
  80874. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80875. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80876. */
  80877. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80878. /**
  80879. * Parse animation range data from a serialization object and store them into a given node
  80880. * @param node defines where to store the animation ranges
  80881. * @param parsedNode defines the serialization object to read data from
  80882. * @param scene defines the hosting scene
  80883. */
  80884. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  80885. }
  80886. }
  80887. declare module BABYLON {
  80888. /**
  80889. * Class used to store any kind of animation
  80890. */
  80891. export class Animation {
  80892. /**Name of the animation */
  80893. name: string;
  80894. /**Property to animate */
  80895. targetProperty: string;
  80896. /**The frames per second of the animation */
  80897. framePerSecond: number;
  80898. /**The data type of the animation */
  80899. dataType: number;
  80900. /**The loop mode of the animation */
  80901. loopMode?: number | undefined;
  80902. /**Specifies if blending should be enabled */
  80903. enableBlending?: boolean | undefined;
  80904. /**
  80905. * Use matrix interpolation instead of using direct key value when animating matrices
  80906. */
  80907. static AllowMatricesInterpolation: boolean;
  80908. /**
  80909. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  80910. */
  80911. static AllowMatrixDecomposeForInterpolation: boolean;
  80912. /**
  80913. * Stores the key frames of the animation
  80914. */
  80915. private _keys;
  80916. /**
  80917. * Stores the easing function of the animation
  80918. */
  80919. private _easingFunction;
  80920. /**
  80921. * @hidden Internal use only
  80922. */
  80923. _runtimeAnimations: RuntimeAnimation[];
  80924. /**
  80925. * The set of event that will be linked to this animation
  80926. */
  80927. private _events;
  80928. /**
  80929. * Stores an array of target property paths
  80930. */
  80931. targetPropertyPath: string[];
  80932. /**
  80933. * Stores the blending speed of the animation
  80934. */
  80935. blendingSpeed: number;
  80936. /**
  80937. * Stores the animation ranges for the animation
  80938. */
  80939. private _ranges;
  80940. /**
  80941. * @hidden Internal use
  80942. */
  80943. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  80944. /**
  80945. * Sets up an animation
  80946. * @param property The property to animate
  80947. * @param animationType The animation type to apply
  80948. * @param framePerSecond The frames per second of the animation
  80949. * @param easingFunction The easing function used in the animation
  80950. * @returns The created animation
  80951. */
  80952. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  80953. /**
  80954. * Create and start an animation on a node
  80955. * @param name defines the name of the global animation that will be run on all nodes
  80956. * @param node defines the root node where the animation will take place
  80957. * @param targetProperty defines property to animate
  80958. * @param framePerSecond defines the number of frame per second yo use
  80959. * @param totalFrame defines the number of frames in total
  80960. * @param from defines the initial value
  80961. * @param to defines the final value
  80962. * @param loopMode defines which loop mode you want to use (off by default)
  80963. * @param easingFunction defines the easing function to use (linear by default)
  80964. * @param onAnimationEnd defines the callback to call when animation end
  80965. * @returns the animatable created for this animation
  80966. */
  80967. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80968. /**
  80969. * Create and start an animation on a node and its descendants
  80970. * @param name defines the name of the global animation that will be run on all nodes
  80971. * @param node defines the root node where the animation will take place
  80972. * @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
  80973. * @param targetProperty defines property to animate
  80974. * @param framePerSecond defines the number of frame per second to use
  80975. * @param totalFrame defines the number of frames in total
  80976. * @param from defines the initial value
  80977. * @param to defines the final value
  80978. * @param loopMode defines which loop mode you want to use (off by default)
  80979. * @param easingFunction defines the easing function to use (linear by default)
  80980. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80981. * @returns the list of animatables created for all nodes
  80982. * @example https://www.babylonjs-playground.com/#MH0VLI
  80983. */
  80984. 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[]>;
  80985. /**
  80986. * Creates a new animation, merges it with the existing animations and starts it
  80987. * @param name Name of the animation
  80988. * @param node Node which contains the scene that begins the animations
  80989. * @param targetProperty Specifies which property to animate
  80990. * @param framePerSecond The frames per second of the animation
  80991. * @param totalFrame The total number of frames
  80992. * @param from The frame at the beginning of the animation
  80993. * @param to The frame at the end of the animation
  80994. * @param loopMode Specifies the loop mode of the animation
  80995. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  80996. * @param onAnimationEnd Callback to run once the animation is complete
  80997. * @returns Nullable animation
  80998. */
  80999. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81000. /**
  81001. * Transition property of an host to the target Value
  81002. * @param property The property to transition
  81003. * @param targetValue The target Value of the property
  81004. * @param host The object where the property to animate belongs
  81005. * @param scene Scene used to run the animation
  81006. * @param frameRate Framerate (in frame/s) to use
  81007. * @param transition The transition type we want to use
  81008. * @param duration The duration of the animation, in milliseconds
  81009. * @param onAnimationEnd Callback trigger at the end of the animation
  81010. * @returns Nullable animation
  81011. */
  81012. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81013. /**
  81014. * Return the array of runtime animations currently using this animation
  81015. */
  81016. readonly runtimeAnimations: RuntimeAnimation[];
  81017. /**
  81018. * Specifies if any of the runtime animations are currently running
  81019. */
  81020. readonly hasRunningRuntimeAnimations: boolean;
  81021. /**
  81022. * Initializes the animation
  81023. * @param name Name of the animation
  81024. * @param targetProperty Property to animate
  81025. * @param framePerSecond The frames per second of the animation
  81026. * @param dataType The data type of the animation
  81027. * @param loopMode The loop mode of the animation
  81028. * @param enableBlending Specifies if blending should be enabled
  81029. */
  81030. constructor(
  81031. /**Name of the animation */
  81032. name: string,
  81033. /**Property to animate */
  81034. targetProperty: string,
  81035. /**The frames per second of the animation */
  81036. framePerSecond: number,
  81037. /**The data type of the animation */
  81038. dataType: number,
  81039. /**The loop mode of the animation */
  81040. loopMode?: number | undefined,
  81041. /**Specifies if blending should be enabled */
  81042. enableBlending?: boolean | undefined);
  81043. /**
  81044. * Converts the animation to a string
  81045. * @param fullDetails support for multiple levels of logging within scene loading
  81046. * @returns String form of the animation
  81047. */
  81048. toString(fullDetails?: boolean): string;
  81049. /**
  81050. * Add an event to this animation
  81051. * @param event Event to add
  81052. */
  81053. addEvent(event: AnimationEvent): void;
  81054. /**
  81055. * Remove all events found at the given frame
  81056. * @param frame The frame to remove events from
  81057. */
  81058. removeEvents(frame: number): void;
  81059. /**
  81060. * Retrieves all the events from the animation
  81061. * @returns Events from the animation
  81062. */
  81063. getEvents(): AnimationEvent[];
  81064. /**
  81065. * Creates an animation range
  81066. * @param name Name of the animation range
  81067. * @param from Starting frame of the animation range
  81068. * @param to Ending frame of the animation
  81069. */
  81070. createRange(name: string, from: number, to: number): void;
  81071. /**
  81072. * Deletes an animation range by name
  81073. * @param name Name of the animation range to delete
  81074. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81075. */
  81076. deleteRange(name: string, deleteFrames?: boolean): void;
  81077. /**
  81078. * Gets the animation range by name, or null if not defined
  81079. * @param name Name of the animation range
  81080. * @returns Nullable animation range
  81081. */
  81082. getRange(name: string): Nullable<AnimationRange>;
  81083. /**
  81084. * Gets the key frames from the animation
  81085. * @returns The key frames of the animation
  81086. */
  81087. getKeys(): Array<IAnimationKey>;
  81088. /**
  81089. * Gets the highest frame rate of the animation
  81090. * @returns Highest frame rate of the animation
  81091. */
  81092. getHighestFrame(): number;
  81093. /**
  81094. * Gets the easing function of the animation
  81095. * @returns Easing function of the animation
  81096. */
  81097. getEasingFunction(): IEasingFunction;
  81098. /**
  81099. * Sets the easing function of the animation
  81100. * @param easingFunction A custom mathematical formula for animation
  81101. */
  81102. setEasingFunction(easingFunction: EasingFunction): void;
  81103. /**
  81104. * Interpolates a scalar linearly
  81105. * @param startValue Start value of the animation curve
  81106. * @param endValue End value of the animation curve
  81107. * @param gradient Scalar amount to interpolate
  81108. * @returns Interpolated scalar value
  81109. */
  81110. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81111. /**
  81112. * Interpolates a scalar cubically
  81113. * @param startValue Start value of the animation curve
  81114. * @param outTangent End tangent of the animation
  81115. * @param endValue End value of the animation curve
  81116. * @param inTangent Start tangent of the animation curve
  81117. * @param gradient Scalar amount to interpolate
  81118. * @returns Interpolated scalar value
  81119. */
  81120. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81121. /**
  81122. * Interpolates a quaternion using a spherical linear interpolation
  81123. * @param startValue Start value of the animation curve
  81124. * @param endValue End value of the animation curve
  81125. * @param gradient Scalar amount to interpolate
  81126. * @returns Interpolated quaternion value
  81127. */
  81128. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81129. /**
  81130. * Interpolates a quaternion cubically
  81131. * @param startValue Start value of the animation curve
  81132. * @param outTangent End tangent of the animation curve
  81133. * @param endValue End value of the animation curve
  81134. * @param inTangent Start tangent of the animation curve
  81135. * @param gradient Scalar amount to interpolate
  81136. * @returns Interpolated quaternion value
  81137. */
  81138. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81139. /**
  81140. * Interpolates a Vector3 linearl
  81141. * @param startValue Start value of the animation curve
  81142. * @param endValue End value of the animation curve
  81143. * @param gradient Scalar amount to interpolate
  81144. * @returns Interpolated scalar value
  81145. */
  81146. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81147. /**
  81148. * Interpolates a Vector3 cubically
  81149. * @param startValue Start value of the animation curve
  81150. * @param outTangent End tangent of the animation
  81151. * @param endValue End value of the animation curve
  81152. * @param inTangent Start tangent of the animation curve
  81153. * @param gradient Scalar amount to interpolate
  81154. * @returns InterpolatedVector3 value
  81155. */
  81156. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81157. /**
  81158. * Interpolates a Vector2 linearly
  81159. * @param startValue Start value of the animation curve
  81160. * @param endValue End value of the animation curve
  81161. * @param gradient Scalar amount to interpolate
  81162. * @returns Interpolated Vector2 value
  81163. */
  81164. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81165. /**
  81166. * Interpolates a Vector2 cubically
  81167. * @param startValue Start value of the animation curve
  81168. * @param outTangent End tangent of the animation
  81169. * @param endValue End value of the animation curve
  81170. * @param inTangent Start tangent of the animation curve
  81171. * @param gradient Scalar amount to interpolate
  81172. * @returns Interpolated Vector2 value
  81173. */
  81174. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81175. /**
  81176. * Interpolates a size linearly
  81177. * @param startValue Start value of the animation curve
  81178. * @param endValue End value of the animation curve
  81179. * @param gradient Scalar amount to interpolate
  81180. * @returns Interpolated Size value
  81181. */
  81182. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81183. /**
  81184. * Interpolates a Color3 linearly
  81185. * @param startValue Start value of the animation curve
  81186. * @param endValue End value of the animation curve
  81187. * @param gradient Scalar amount to interpolate
  81188. * @returns Interpolated Color3 value
  81189. */
  81190. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81191. /**
  81192. * @hidden Internal use only
  81193. */
  81194. _getKeyValue(value: any): any;
  81195. /**
  81196. * @hidden Internal use only
  81197. */
  81198. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81199. /**
  81200. * Defines the function to use to interpolate matrices
  81201. * @param startValue defines the start matrix
  81202. * @param endValue defines the end matrix
  81203. * @param gradient defines the gradient between both matrices
  81204. * @param result defines an optional target matrix where to store the interpolation
  81205. * @returns the interpolated matrix
  81206. */
  81207. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81208. /**
  81209. * Makes a copy of the animation
  81210. * @returns Cloned animation
  81211. */
  81212. clone(): Animation;
  81213. /**
  81214. * Sets the key frames of the animation
  81215. * @param values The animation key frames to set
  81216. */
  81217. setKeys(values: Array<IAnimationKey>): void;
  81218. /**
  81219. * Serializes the animation to an object
  81220. * @returns Serialized object
  81221. */
  81222. serialize(): any;
  81223. /**
  81224. * Float animation type
  81225. */
  81226. private static _ANIMATIONTYPE_FLOAT;
  81227. /**
  81228. * Vector3 animation type
  81229. */
  81230. private static _ANIMATIONTYPE_VECTOR3;
  81231. /**
  81232. * Quaternion animation type
  81233. */
  81234. private static _ANIMATIONTYPE_QUATERNION;
  81235. /**
  81236. * Matrix animation type
  81237. */
  81238. private static _ANIMATIONTYPE_MATRIX;
  81239. /**
  81240. * Color3 animation type
  81241. */
  81242. private static _ANIMATIONTYPE_COLOR3;
  81243. /**
  81244. * Vector2 animation type
  81245. */
  81246. private static _ANIMATIONTYPE_VECTOR2;
  81247. /**
  81248. * Size animation type
  81249. */
  81250. private static _ANIMATIONTYPE_SIZE;
  81251. /**
  81252. * Relative Loop Mode
  81253. */
  81254. private static _ANIMATIONLOOPMODE_RELATIVE;
  81255. /**
  81256. * Cycle Loop Mode
  81257. */
  81258. private static _ANIMATIONLOOPMODE_CYCLE;
  81259. /**
  81260. * Constant Loop Mode
  81261. */
  81262. private static _ANIMATIONLOOPMODE_CONSTANT;
  81263. /**
  81264. * Get the float animation type
  81265. */
  81266. static readonly ANIMATIONTYPE_FLOAT: number;
  81267. /**
  81268. * Get the Vector3 animation type
  81269. */
  81270. static readonly ANIMATIONTYPE_VECTOR3: number;
  81271. /**
  81272. * Get the Vector2 animation type
  81273. */
  81274. static readonly ANIMATIONTYPE_VECTOR2: number;
  81275. /**
  81276. * Get the Size animation type
  81277. */
  81278. static readonly ANIMATIONTYPE_SIZE: number;
  81279. /**
  81280. * Get the Quaternion animation type
  81281. */
  81282. static readonly ANIMATIONTYPE_QUATERNION: number;
  81283. /**
  81284. * Get the Matrix animation type
  81285. */
  81286. static readonly ANIMATIONTYPE_MATRIX: number;
  81287. /**
  81288. * Get the Color3 animation type
  81289. */
  81290. static readonly ANIMATIONTYPE_COLOR3: number;
  81291. /**
  81292. * Get the Relative Loop Mode
  81293. */
  81294. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81295. /**
  81296. * Get the Cycle Loop Mode
  81297. */
  81298. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81299. /**
  81300. * Get the Constant Loop Mode
  81301. */
  81302. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81303. /** @hidden */
  81304. static _UniversalLerp(left: any, right: any, amount: number): any;
  81305. /**
  81306. * Parses an animation object and creates an animation
  81307. * @param parsedAnimation Parsed animation object
  81308. * @returns Animation object
  81309. */
  81310. static Parse(parsedAnimation: any): Animation;
  81311. /**
  81312. * Appends the serialized animations from the source animations
  81313. * @param source Source containing the animations
  81314. * @param destination Target to store the animations
  81315. */
  81316. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81317. }
  81318. }
  81319. declare module BABYLON {
  81320. /**
  81321. * Base class of all the textures in babylon.
  81322. * It groups all the common properties the materials, post process, lights... might need
  81323. * in order to make a correct use of the texture.
  81324. */
  81325. export class BaseTexture implements IAnimatable {
  81326. /**
  81327. * Default anisotropic filtering level for the application.
  81328. * It is set to 4 as a good tradeoff between perf and quality.
  81329. */
  81330. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81331. /**
  81332. * Gets or sets the unique id of the texture
  81333. */
  81334. uniqueId: number;
  81335. /**
  81336. * Define the name of the texture.
  81337. */
  81338. name: string;
  81339. /**
  81340. * Gets or sets an object used to store user defined information.
  81341. */
  81342. metadata: any;
  81343. /**
  81344. * For internal use only. Please do not use.
  81345. */
  81346. reservedDataStore: any;
  81347. private _hasAlpha;
  81348. /**
  81349. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81350. */
  81351. hasAlpha: boolean;
  81352. /**
  81353. * Defines if the alpha value should be determined via the rgb values.
  81354. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81355. */
  81356. getAlphaFromRGB: boolean;
  81357. /**
  81358. * Intensity or strength of the texture.
  81359. * It is commonly used by materials to fine tune the intensity of the texture
  81360. */
  81361. level: number;
  81362. /**
  81363. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81364. * This is part of the texture as textures usually maps to one uv set.
  81365. */
  81366. coordinatesIndex: number;
  81367. private _coordinatesMode;
  81368. /**
  81369. * How a texture is mapped.
  81370. *
  81371. * | Value | Type | Description |
  81372. * | ----- | ----------------------------------- | ----------- |
  81373. * | 0 | EXPLICIT_MODE | |
  81374. * | 1 | SPHERICAL_MODE | |
  81375. * | 2 | PLANAR_MODE | |
  81376. * | 3 | CUBIC_MODE | |
  81377. * | 4 | PROJECTION_MODE | |
  81378. * | 5 | SKYBOX_MODE | |
  81379. * | 6 | INVCUBIC_MODE | |
  81380. * | 7 | EQUIRECTANGULAR_MODE | |
  81381. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81382. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81383. */
  81384. coordinatesMode: number;
  81385. /**
  81386. * | Value | Type | Description |
  81387. * | ----- | ------------------ | ----------- |
  81388. * | 0 | CLAMP_ADDRESSMODE | |
  81389. * | 1 | WRAP_ADDRESSMODE | |
  81390. * | 2 | MIRROR_ADDRESSMODE | |
  81391. */
  81392. wrapU: number;
  81393. /**
  81394. * | Value | Type | Description |
  81395. * | ----- | ------------------ | ----------- |
  81396. * | 0 | CLAMP_ADDRESSMODE | |
  81397. * | 1 | WRAP_ADDRESSMODE | |
  81398. * | 2 | MIRROR_ADDRESSMODE | |
  81399. */
  81400. wrapV: number;
  81401. /**
  81402. * | Value | Type | Description |
  81403. * | ----- | ------------------ | ----------- |
  81404. * | 0 | CLAMP_ADDRESSMODE | |
  81405. * | 1 | WRAP_ADDRESSMODE | |
  81406. * | 2 | MIRROR_ADDRESSMODE | |
  81407. */
  81408. wrapR: number;
  81409. /**
  81410. * With compliant hardware and browser (supporting anisotropic filtering)
  81411. * this defines the level of anisotropic filtering in the texture.
  81412. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81413. */
  81414. anisotropicFilteringLevel: number;
  81415. /**
  81416. * Define if the texture is a cube texture or if false a 2d texture.
  81417. */
  81418. isCube: boolean;
  81419. /**
  81420. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81421. */
  81422. is3D: boolean;
  81423. /**
  81424. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81425. * HDR texture are usually stored in linear space.
  81426. * This only impacts the PBR and Background materials
  81427. */
  81428. gammaSpace: boolean;
  81429. /**
  81430. * Gets whether or not the texture contains RGBD data.
  81431. */
  81432. readonly isRGBD: boolean;
  81433. /**
  81434. * Is Z inverted in the texture (useful in a cube texture).
  81435. */
  81436. invertZ: boolean;
  81437. /**
  81438. * Are mip maps generated for this texture or not.
  81439. */
  81440. readonly noMipmap: boolean;
  81441. /**
  81442. * @hidden
  81443. */
  81444. lodLevelInAlpha: boolean;
  81445. /**
  81446. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81447. */
  81448. lodGenerationOffset: number;
  81449. /**
  81450. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81451. */
  81452. lodGenerationScale: number;
  81453. /**
  81454. * Define if the texture is a render target.
  81455. */
  81456. isRenderTarget: boolean;
  81457. /**
  81458. * Define the unique id of the texture in the scene.
  81459. */
  81460. readonly uid: string;
  81461. /**
  81462. * Return a string representation of the texture.
  81463. * @returns the texture as a string
  81464. */
  81465. toString(): string;
  81466. /**
  81467. * Get the class name of the texture.
  81468. * @returns "BaseTexture"
  81469. */
  81470. getClassName(): string;
  81471. /**
  81472. * Define the list of animation attached to the texture.
  81473. */
  81474. animations: Animation[];
  81475. /**
  81476. * An event triggered when the texture is disposed.
  81477. */
  81478. onDisposeObservable: Observable<BaseTexture>;
  81479. private _onDisposeObserver;
  81480. /**
  81481. * Callback triggered when the texture has been disposed.
  81482. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81483. */
  81484. onDispose: () => void;
  81485. /**
  81486. * Define the current state of the loading sequence when in delayed load mode.
  81487. */
  81488. delayLoadState: number;
  81489. private _scene;
  81490. /** @hidden */
  81491. _texture: Nullable<InternalTexture>;
  81492. private _uid;
  81493. /**
  81494. * Define if the texture is preventinga material to render or not.
  81495. * If not and the texture is not ready, the engine will use a default black texture instead.
  81496. */
  81497. readonly isBlocking: boolean;
  81498. /**
  81499. * Instantiates a new BaseTexture.
  81500. * Base class of all the textures in babylon.
  81501. * It groups all the common properties the materials, post process, lights... might need
  81502. * in order to make a correct use of the texture.
  81503. * @param scene Define the scene the texture blongs to
  81504. */
  81505. constructor(scene: Nullable<Scene>);
  81506. /**
  81507. * Get the scene the texture belongs to.
  81508. * @returns the scene or null if undefined
  81509. */
  81510. getScene(): Nullable<Scene>;
  81511. /**
  81512. * Get the texture transform matrix used to offset tile the texture for istance.
  81513. * @returns the transformation matrix
  81514. */
  81515. getTextureMatrix(): Matrix;
  81516. /**
  81517. * Get the texture reflection matrix used to rotate/transform the reflection.
  81518. * @returns the reflection matrix
  81519. */
  81520. getReflectionTextureMatrix(): Matrix;
  81521. /**
  81522. * Get the underlying lower level texture from Babylon.
  81523. * @returns the insternal texture
  81524. */
  81525. getInternalTexture(): Nullable<InternalTexture>;
  81526. /**
  81527. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81528. * @returns true if ready or not blocking
  81529. */
  81530. isReadyOrNotBlocking(): boolean;
  81531. /**
  81532. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81533. * @returns true if fully ready
  81534. */
  81535. isReady(): boolean;
  81536. private _cachedSize;
  81537. /**
  81538. * Get the size of the texture.
  81539. * @returns the texture size.
  81540. */
  81541. getSize(): ISize;
  81542. /**
  81543. * Get the base size of the texture.
  81544. * It can be different from the size if the texture has been resized for POT for instance
  81545. * @returns the base size
  81546. */
  81547. getBaseSize(): ISize;
  81548. /**
  81549. * Update the sampling mode of the texture.
  81550. * Default is Trilinear mode.
  81551. *
  81552. * | Value | Type | Description |
  81553. * | ----- | ------------------ | ----------- |
  81554. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81555. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81556. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81557. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81558. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81559. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81560. * | 7 | NEAREST_LINEAR | |
  81561. * | 8 | NEAREST_NEAREST | |
  81562. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81563. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81564. * | 11 | LINEAR_LINEAR | |
  81565. * | 12 | LINEAR_NEAREST | |
  81566. *
  81567. * > _mag_: magnification filter (close to the viewer)
  81568. * > _min_: minification filter (far from the viewer)
  81569. * > _mip_: filter used between mip map levels
  81570. *@param samplingMode Define the new sampling mode of the texture
  81571. */
  81572. updateSamplingMode(samplingMode: number): void;
  81573. /**
  81574. * Scales the texture if is `canRescale()`
  81575. * @param ratio the resize factor we want to use to rescale
  81576. */
  81577. scale(ratio: number): void;
  81578. /**
  81579. * Get if the texture can rescale.
  81580. */
  81581. readonly canRescale: boolean;
  81582. /** @hidden */
  81583. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81584. /** @hidden */
  81585. _rebuild(): void;
  81586. /**
  81587. * Triggers the load sequence in delayed load mode.
  81588. */
  81589. delayLoad(): void;
  81590. /**
  81591. * Clones the texture.
  81592. * @returns the cloned texture
  81593. */
  81594. clone(): Nullable<BaseTexture>;
  81595. /**
  81596. * Get the texture underlying type (INT, FLOAT...)
  81597. */
  81598. readonly textureType: number;
  81599. /**
  81600. * Get the texture underlying format (RGB, RGBA...)
  81601. */
  81602. readonly textureFormat: number;
  81603. /**
  81604. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81605. * This will returns an RGBA array buffer containing either in values (0-255) or
  81606. * float values (0-1) depending of the underlying buffer type.
  81607. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81608. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81609. * @param buffer defines a user defined buffer to fill with data (can be null)
  81610. * @returns The Array buffer containing the pixels data.
  81611. */
  81612. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81613. /**
  81614. * Release and destroy the underlying lower level texture aka internalTexture.
  81615. */
  81616. releaseInternalTexture(): void;
  81617. /**
  81618. * Get the polynomial representation of the texture data.
  81619. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81620. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81621. */
  81622. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81623. /** @hidden */
  81624. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81625. /** @hidden */
  81626. readonly _lodTextureMid: Nullable<BaseTexture>;
  81627. /** @hidden */
  81628. readonly _lodTextureLow: Nullable<BaseTexture>;
  81629. /**
  81630. * Dispose the texture and release its associated resources.
  81631. */
  81632. dispose(): void;
  81633. /**
  81634. * Serialize the texture into a JSON representation that can be parsed later on.
  81635. * @returns the JSON representation of the texture
  81636. */
  81637. serialize(): any;
  81638. /**
  81639. * Helper function to be called back once a list of texture contains only ready textures.
  81640. * @param textures Define the list of textures to wait for
  81641. * @param callback Define the callback triggered once the entire list will be ready
  81642. */
  81643. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81644. }
  81645. }
  81646. declare module BABYLON {
  81647. /**
  81648. * Uniform buffer objects.
  81649. *
  81650. * Handles blocks of uniform on the GPU.
  81651. *
  81652. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81653. *
  81654. * For more information, please refer to :
  81655. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81656. */
  81657. export class UniformBuffer {
  81658. private _engine;
  81659. private _buffer;
  81660. private _data;
  81661. private _bufferData;
  81662. private _dynamic?;
  81663. private _uniformLocations;
  81664. private _uniformSizes;
  81665. private _uniformLocationPointer;
  81666. private _needSync;
  81667. private _noUBO;
  81668. private _currentEffect;
  81669. private static _MAX_UNIFORM_SIZE;
  81670. private static _tempBuffer;
  81671. /**
  81672. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81673. * This is dynamic to allow compat with webgl 1 and 2.
  81674. * You will need to pass the name of the uniform as well as the value.
  81675. */
  81676. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81677. /**
  81678. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81679. * This is dynamic to allow compat with webgl 1 and 2.
  81680. * You will need to pass the name of the uniform as well as the value.
  81681. */
  81682. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81683. /**
  81684. * Lambda to Update a single float in a uniform buffer.
  81685. * This is dynamic to allow compat with webgl 1 and 2.
  81686. * You will need to pass the name of the uniform as well as the value.
  81687. */
  81688. updateFloat: (name: string, x: number) => void;
  81689. /**
  81690. * Lambda to Update a vec2 of float in a uniform buffer.
  81691. * This is dynamic to allow compat with webgl 1 and 2.
  81692. * You will need to pass the name of the uniform as well as the value.
  81693. */
  81694. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81695. /**
  81696. * Lambda to Update a vec3 of float in a uniform buffer.
  81697. * This is dynamic to allow compat with webgl 1 and 2.
  81698. * You will need to pass the name of the uniform as well as the value.
  81699. */
  81700. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81701. /**
  81702. * Lambda to Update a vec4 of float in a uniform buffer.
  81703. * This is dynamic to allow compat with webgl 1 and 2.
  81704. * You will need to pass the name of the uniform as well as the value.
  81705. */
  81706. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81707. /**
  81708. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81709. * This is dynamic to allow compat with webgl 1 and 2.
  81710. * You will need to pass the name of the uniform as well as the value.
  81711. */
  81712. updateMatrix: (name: string, mat: Matrix) => void;
  81713. /**
  81714. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81715. * This is dynamic to allow compat with webgl 1 and 2.
  81716. * You will need to pass the name of the uniform as well as the value.
  81717. */
  81718. updateVector3: (name: string, vector: Vector3) => void;
  81719. /**
  81720. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81721. * This is dynamic to allow compat with webgl 1 and 2.
  81722. * You will need to pass the name of the uniform as well as the value.
  81723. */
  81724. updateVector4: (name: string, vector: Vector4) => void;
  81725. /**
  81726. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81727. * This is dynamic to allow compat with webgl 1 and 2.
  81728. * You will need to pass the name of the uniform as well as the value.
  81729. */
  81730. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81731. /**
  81732. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81733. * This is dynamic to allow compat with webgl 1 and 2.
  81734. * You will need to pass the name of the uniform as well as the value.
  81735. */
  81736. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81737. /**
  81738. * Instantiates a new Uniform buffer objects.
  81739. *
  81740. * Handles blocks of uniform on the GPU.
  81741. *
  81742. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81743. *
  81744. * For more information, please refer to :
  81745. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81746. * @param engine Define the engine the buffer is associated with
  81747. * @param data Define the data contained in the buffer
  81748. * @param dynamic Define if the buffer is updatable
  81749. */
  81750. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81751. /**
  81752. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81753. * or just falling back on setUniformXXX calls.
  81754. */
  81755. readonly useUbo: boolean;
  81756. /**
  81757. * Indicates if the WebGL underlying uniform buffer is in sync
  81758. * with the javascript cache data.
  81759. */
  81760. readonly isSync: boolean;
  81761. /**
  81762. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81763. * Also, a dynamic UniformBuffer will disable cache verification and always
  81764. * update the underlying WebGL uniform buffer to the GPU.
  81765. * @returns if Dynamic, otherwise false
  81766. */
  81767. isDynamic(): boolean;
  81768. /**
  81769. * The data cache on JS side.
  81770. * @returns the underlying data as a float array
  81771. */
  81772. getData(): Float32Array;
  81773. /**
  81774. * The underlying WebGL Uniform buffer.
  81775. * @returns the webgl buffer
  81776. */
  81777. getBuffer(): Nullable<WebGLBuffer>;
  81778. /**
  81779. * std140 layout specifies how to align data within an UBO structure.
  81780. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81781. * for specs.
  81782. */
  81783. private _fillAlignment;
  81784. /**
  81785. * Adds an uniform in the buffer.
  81786. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81787. * for the layout to be correct !
  81788. * @param name Name of the uniform, as used in the uniform block in the shader.
  81789. * @param size Data size, or data directly.
  81790. */
  81791. addUniform(name: string, size: number | number[]): void;
  81792. /**
  81793. * Adds a Matrix 4x4 to the uniform buffer.
  81794. * @param name Name of the uniform, as used in the uniform block in the shader.
  81795. * @param mat A 4x4 matrix.
  81796. */
  81797. addMatrix(name: string, mat: Matrix): void;
  81798. /**
  81799. * Adds a vec2 to the uniform buffer.
  81800. * @param name Name of the uniform, as used in the uniform block in the shader.
  81801. * @param x Define the x component value of the vec2
  81802. * @param y Define the y component value of the vec2
  81803. */
  81804. addFloat2(name: string, x: number, y: number): void;
  81805. /**
  81806. * Adds a vec3 to the uniform buffer.
  81807. * @param name Name of the uniform, as used in the uniform block in the shader.
  81808. * @param x Define the x component value of the vec3
  81809. * @param y Define the y component value of the vec3
  81810. * @param z Define the z component value of the vec3
  81811. */
  81812. addFloat3(name: string, x: number, y: number, z: number): void;
  81813. /**
  81814. * Adds a vec3 to the uniform buffer.
  81815. * @param name Name of the uniform, as used in the uniform block in the shader.
  81816. * @param color Define the vec3 from a Color
  81817. */
  81818. addColor3(name: string, color: Color3): void;
  81819. /**
  81820. * Adds a vec4 to the uniform buffer.
  81821. * @param name Name of the uniform, as used in the uniform block in the shader.
  81822. * @param color Define the rgb components from a Color
  81823. * @param alpha Define the a component of the vec4
  81824. */
  81825. addColor4(name: string, color: Color3, alpha: number): void;
  81826. /**
  81827. * Adds a vec3 to the uniform buffer.
  81828. * @param name Name of the uniform, as used in the uniform block in the shader.
  81829. * @param vector Define the vec3 components from a Vector
  81830. */
  81831. addVector3(name: string, vector: Vector3): void;
  81832. /**
  81833. * Adds a Matrix 3x3 to the uniform buffer.
  81834. * @param name Name of the uniform, as used in the uniform block in the shader.
  81835. */
  81836. addMatrix3x3(name: string): void;
  81837. /**
  81838. * Adds a Matrix 2x2 to the uniform buffer.
  81839. * @param name Name of the uniform, as used in the uniform block in the shader.
  81840. */
  81841. addMatrix2x2(name: string): void;
  81842. /**
  81843. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81844. */
  81845. create(): void;
  81846. /** @hidden */
  81847. _rebuild(): void;
  81848. /**
  81849. * Updates the WebGL Uniform Buffer on the GPU.
  81850. * If the `dynamic` flag is set to true, no cache comparison is done.
  81851. * Otherwise, the buffer will be updated only if the cache differs.
  81852. */
  81853. update(): void;
  81854. /**
  81855. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81856. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81857. * @param data Define the flattened data
  81858. * @param size Define the size of the data.
  81859. */
  81860. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81861. private _updateMatrix3x3ForUniform;
  81862. private _updateMatrix3x3ForEffect;
  81863. private _updateMatrix2x2ForEffect;
  81864. private _updateMatrix2x2ForUniform;
  81865. private _updateFloatForEffect;
  81866. private _updateFloatForUniform;
  81867. private _updateFloat2ForEffect;
  81868. private _updateFloat2ForUniform;
  81869. private _updateFloat3ForEffect;
  81870. private _updateFloat3ForUniform;
  81871. private _updateFloat4ForEffect;
  81872. private _updateFloat4ForUniform;
  81873. private _updateMatrixForEffect;
  81874. private _updateMatrixForUniform;
  81875. private _updateVector3ForEffect;
  81876. private _updateVector3ForUniform;
  81877. private _updateVector4ForEffect;
  81878. private _updateVector4ForUniform;
  81879. private _updateColor3ForEffect;
  81880. private _updateColor3ForUniform;
  81881. private _updateColor4ForEffect;
  81882. private _updateColor4ForUniform;
  81883. /**
  81884. * Sets a sampler uniform on the effect.
  81885. * @param name Define the name of the sampler.
  81886. * @param texture Define the texture to set in the sampler
  81887. */
  81888. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81889. /**
  81890. * Directly updates the value of the uniform in the cache AND on the GPU.
  81891. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81892. * @param data Define the flattened data
  81893. */
  81894. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81895. /**
  81896. * Binds this uniform buffer to an effect.
  81897. * @param effect Define the effect to bind the buffer to
  81898. * @param name Name of the uniform block in the shader.
  81899. */
  81900. bindToEffect(effect: Effect, name: string): void;
  81901. /**
  81902. * Disposes the uniform buffer.
  81903. */
  81904. dispose(): void;
  81905. }
  81906. }
  81907. declare module BABYLON {
  81908. /**
  81909. * This represents the required contract to create a new type of texture loader.
  81910. */
  81911. export interface IInternalTextureLoader {
  81912. /**
  81913. * Defines wether the loader supports cascade loading the different faces.
  81914. */
  81915. supportCascades: boolean;
  81916. /**
  81917. * This returns if the loader support the current file information.
  81918. * @param extension defines the file extension of the file being loaded
  81919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81920. * @param fallback defines the fallback internal texture if any
  81921. * @param isBase64 defines whether the texture is encoded as a base64
  81922. * @param isBuffer defines whether the texture data are stored as a buffer
  81923. * @returns true if the loader can load the specified file
  81924. */
  81925. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  81926. /**
  81927. * Transform the url before loading if required.
  81928. * @param rootUrl the url of the texture
  81929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81930. * @returns the transformed texture
  81931. */
  81932. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  81933. /**
  81934. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  81935. * @param rootUrl the url of the texture
  81936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81937. * @returns the fallback texture
  81938. */
  81939. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  81940. /**
  81941. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  81942. * @param data contains the texture data
  81943. * @param texture defines the BabylonJS internal texture
  81944. * @param createPolynomials will be true if polynomials have been requested
  81945. * @param onLoad defines the callback to trigger once the texture is ready
  81946. * @param onError defines the callback to trigger in case of error
  81947. */
  81948. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81949. /**
  81950. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  81951. * @param data contains the texture data
  81952. * @param texture defines the BabylonJS internal texture
  81953. * @param callback defines the method to call once ready to upload
  81954. */
  81955. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81956. }
  81957. }
  81958. declare module BABYLON {
  81959. /**
  81960. * Creation options of the multi render target texture.
  81961. */
  81962. export interface IMultiRenderTargetOptions {
  81963. /**
  81964. * Define if the texture needs to create mip maps after render.
  81965. */
  81966. generateMipMaps?: boolean;
  81967. /**
  81968. * Define the types of all the draw buffers we want to create
  81969. */
  81970. types?: number[];
  81971. /**
  81972. * Define the sampling modes of all the draw buffers we want to create
  81973. */
  81974. samplingModes?: number[];
  81975. /**
  81976. * Define if a depth buffer is required
  81977. */
  81978. generateDepthBuffer?: boolean;
  81979. /**
  81980. * Define if a stencil buffer is required
  81981. */
  81982. generateStencilBuffer?: boolean;
  81983. /**
  81984. * Define if a depth texture is required instead of a depth buffer
  81985. */
  81986. generateDepthTexture?: boolean;
  81987. /**
  81988. * Define the number of desired draw buffers
  81989. */
  81990. textureCount?: number;
  81991. /**
  81992. * Define if aspect ratio should be adapted to the texture or stay the scene one
  81993. */
  81994. doNotChangeAspectRatio?: boolean;
  81995. /**
  81996. * Define the default type of the buffers we are creating
  81997. */
  81998. defaultType?: number;
  81999. }
  82000. /**
  82001. * A multi render target, like a render target provides the ability to render to a texture.
  82002. * Unlike the render target, it can render to several draw buffers in one draw.
  82003. * This is specially interesting in deferred rendering or for any effects requiring more than
  82004. * just one color from a single pass.
  82005. */
  82006. export class MultiRenderTarget extends RenderTargetTexture {
  82007. private _internalTextures;
  82008. private _textures;
  82009. private _multiRenderTargetOptions;
  82010. /**
  82011. * Get if draw buffers are currently supported by the used hardware and browser.
  82012. */
  82013. readonly isSupported: boolean;
  82014. /**
  82015. * Get the list of textures generated by the multi render target.
  82016. */
  82017. readonly textures: Texture[];
  82018. /**
  82019. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82020. */
  82021. readonly depthTexture: Texture;
  82022. /**
  82023. * Set the wrapping mode on U of all the textures we are rendering to.
  82024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82025. */
  82026. wrapU: number;
  82027. /**
  82028. * Set the wrapping mode on V of all the textures we are rendering to.
  82029. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82030. */
  82031. wrapV: number;
  82032. /**
  82033. * Instantiate a new multi render target texture.
  82034. * A multi render target, like a render target provides the ability to render to a texture.
  82035. * Unlike the render target, it can render to several draw buffers in one draw.
  82036. * This is specially interesting in deferred rendering or for any effects requiring more than
  82037. * just one color from a single pass.
  82038. * @param name Define the name of the texture
  82039. * @param size Define the size of the buffers to render to
  82040. * @param count Define the number of target we are rendering into
  82041. * @param scene Define the scene the texture belongs to
  82042. * @param options Define the options used to create the multi render target
  82043. */
  82044. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82045. /** @hidden */
  82046. _rebuild(): void;
  82047. private _createInternalTextures;
  82048. private _createTextures;
  82049. /**
  82050. * Define the number of samples used if MSAA is enabled.
  82051. */
  82052. samples: number;
  82053. /**
  82054. * Resize all the textures in the multi render target.
  82055. * Be carrefull as it will recreate all the data in the new texture.
  82056. * @param size Define the new size
  82057. */
  82058. resize(size: any): void;
  82059. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82060. /**
  82061. * Dispose the render targets and their associated resources
  82062. */
  82063. dispose(): void;
  82064. /**
  82065. * Release all the underlying texture used as draw buffers.
  82066. */
  82067. releaseInternalTextures(): void;
  82068. }
  82069. }
  82070. declare module BABYLON {
  82071. /**
  82072. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82074. */
  82075. export class Analyser {
  82076. /**
  82077. * Gets or sets the smoothing
  82078. * @ignorenaming
  82079. */
  82080. SMOOTHING: number;
  82081. /**
  82082. * Gets or sets the FFT table size
  82083. * @ignorenaming
  82084. */
  82085. FFT_SIZE: number;
  82086. /**
  82087. * Gets or sets the bar graph amplitude
  82088. * @ignorenaming
  82089. */
  82090. BARGRAPHAMPLITUDE: number;
  82091. /**
  82092. * Gets or sets the position of the debug canvas
  82093. * @ignorenaming
  82094. */
  82095. DEBUGCANVASPOS: {
  82096. x: number;
  82097. y: number;
  82098. };
  82099. /**
  82100. * Gets or sets the debug canvas size
  82101. * @ignorenaming
  82102. */
  82103. DEBUGCANVASSIZE: {
  82104. width: number;
  82105. height: number;
  82106. };
  82107. private _byteFreqs;
  82108. private _byteTime;
  82109. private _floatFreqs;
  82110. private _webAudioAnalyser;
  82111. private _debugCanvas;
  82112. private _debugCanvasContext;
  82113. private _scene;
  82114. private _registerFunc;
  82115. private _audioEngine;
  82116. /**
  82117. * Creates a new analyser
  82118. * @param scene defines hosting scene
  82119. */
  82120. constructor(scene: Scene);
  82121. /**
  82122. * Get the number of data values you will have to play with for the visualization
  82123. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82124. * @returns a number
  82125. */
  82126. getFrequencyBinCount(): number;
  82127. /**
  82128. * Gets the current frequency data as a byte array
  82129. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82130. * @returns a Uint8Array
  82131. */
  82132. getByteFrequencyData(): Uint8Array;
  82133. /**
  82134. * Gets the current waveform as a byte array
  82135. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82136. * @returns a Uint8Array
  82137. */
  82138. getByteTimeDomainData(): Uint8Array;
  82139. /**
  82140. * Gets the current frequency data as a float array
  82141. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82142. * @returns a Float32Array
  82143. */
  82144. getFloatFrequencyData(): Float32Array;
  82145. /**
  82146. * Renders the debug canvas
  82147. */
  82148. drawDebugCanvas(): void;
  82149. /**
  82150. * Stops rendering the debug canvas and removes it
  82151. */
  82152. stopDebugCanvas(): void;
  82153. /**
  82154. * Connects two audio nodes
  82155. * @param inputAudioNode defines first node to connect
  82156. * @param outputAudioNode defines second node to connect
  82157. */
  82158. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82159. /**
  82160. * Releases all associated resources
  82161. */
  82162. dispose(): void;
  82163. }
  82164. }
  82165. declare module BABYLON {
  82166. /**
  82167. * This represents an audio engine and it is responsible
  82168. * to play, synchronize and analyse sounds throughout the application.
  82169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82170. */
  82171. export interface IAudioEngine extends IDisposable {
  82172. /**
  82173. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82174. */
  82175. readonly canUseWebAudio: boolean;
  82176. /**
  82177. * Gets the current AudioContext if available.
  82178. */
  82179. readonly audioContext: Nullable<AudioContext>;
  82180. /**
  82181. * The master gain node defines the global audio volume of your audio engine.
  82182. */
  82183. readonly masterGain: GainNode;
  82184. /**
  82185. * Gets whether or not mp3 are supported by your browser.
  82186. */
  82187. readonly isMP3supported: boolean;
  82188. /**
  82189. * Gets whether or not ogg are supported by your browser.
  82190. */
  82191. readonly isOGGsupported: boolean;
  82192. /**
  82193. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82194. * @ignoreNaming
  82195. */
  82196. WarnedWebAudioUnsupported: boolean;
  82197. /**
  82198. * Defines if the audio engine relies on a custom unlocked button.
  82199. * In this case, the embedded button will not be displayed.
  82200. */
  82201. useCustomUnlockedButton: boolean;
  82202. /**
  82203. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82204. */
  82205. readonly unlocked: boolean;
  82206. /**
  82207. * Event raised when audio has been unlocked on the browser.
  82208. */
  82209. onAudioUnlockedObservable: Observable<AudioEngine>;
  82210. /**
  82211. * Event raised when audio has been locked on the browser.
  82212. */
  82213. onAudioLockedObservable: Observable<AudioEngine>;
  82214. /**
  82215. * Flags the audio engine in Locked state.
  82216. * This happens due to new browser policies preventing audio to autoplay.
  82217. */
  82218. lock(): void;
  82219. /**
  82220. * Unlocks the audio engine once a user action has been done on the dom.
  82221. * This is helpful to resume play once browser policies have been satisfied.
  82222. */
  82223. unlock(): void;
  82224. }
  82225. /**
  82226. * This represents the default audio engine used in babylon.
  82227. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82229. */
  82230. export class AudioEngine implements IAudioEngine {
  82231. private _audioContext;
  82232. private _audioContextInitialized;
  82233. private _muteButton;
  82234. private _hostElement;
  82235. /**
  82236. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82237. */
  82238. canUseWebAudio: boolean;
  82239. /**
  82240. * The master gain node defines the global audio volume of your audio engine.
  82241. */
  82242. masterGain: GainNode;
  82243. /**
  82244. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82245. * @ignoreNaming
  82246. */
  82247. WarnedWebAudioUnsupported: boolean;
  82248. /**
  82249. * Gets whether or not mp3 are supported by your browser.
  82250. */
  82251. isMP3supported: boolean;
  82252. /**
  82253. * Gets whether or not ogg are supported by your browser.
  82254. */
  82255. isOGGsupported: boolean;
  82256. /**
  82257. * Gets whether audio has been unlocked on the device.
  82258. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82259. * a user interaction has happened.
  82260. */
  82261. unlocked: boolean;
  82262. /**
  82263. * Defines if the audio engine relies on a custom unlocked button.
  82264. * In this case, the embedded button will not be displayed.
  82265. */
  82266. useCustomUnlockedButton: boolean;
  82267. /**
  82268. * Event raised when audio has been unlocked on the browser.
  82269. */
  82270. onAudioUnlockedObservable: Observable<AudioEngine>;
  82271. /**
  82272. * Event raised when audio has been locked on the browser.
  82273. */
  82274. onAudioLockedObservable: Observable<AudioEngine>;
  82275. /**
  82276. * Gets the current AudioContext if available.
  82277. */
  82278. readonly audioContext: Nullable<AudioContext>;
  82279. private _connectedAnalyser;
  82280. /**
  82281. * Instantiates a new audio engine.
  82282. *
  82283. * There should be only one per page as some browsers restrict the number
  82284. * of audio contexts you can create.
  82285. * @param hostElement defines the host element where to display the mute icon if necessary
  82286. */
  82287. constructor(hostElement?: Nullable<HTMLElement>);
  82288. /**
  82289. * Flags the audio engine in Locked state.
  82290. * This happens due to new browser policies preventing audio to autoplay.
  82291. */
  82292. lock(): void;
  82293. /**
  82294. * Unlocks the audio engine once a user action has been done on the dom.
  82295. * This is helpful to resume play once browser policies have been satisfied.
  82296. */
  82297. unlock(): void;
  82298. private _resumeAudioContext;
  82299. private _initializeAudioContext;
  82300. private _tryToRun;
  82301. private _triggerRunningState;
  82302. private _triggerSuspendedState;
  82303. private _displayMuteButton;
  82304. private _moveButtonToTopLeft;
  82305. private _onResize;
  82306. private _hideMuteButton;
  82307. /**
  82308. * Destroy and release the resources associated with the audio ccontext.
  82309. */
  82310. dispose(): void;
  82311. /**
  82312. * Gets the global volume sets on the master gain.
  82313. * @returns the global volume if set or -1 otherwise
  82314. */
  82315. getGlobalVolume(): number;
  82316. /**
  82317. * Sets the global volume of your experience (sets on the master gain).
  82318. * @param newVolume Defines the new global volume of the application
  82319. */
  82320. setGlobalVolume(newVolume: number): void;
  82321. /**
  82322. * Connect the audio engine to an audio analyser allowing some amazing
  82323. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82325. * @param analyser The analyser to connect to the engine
  82326. */
  82327. connectToAnalyser(analyser: Analyser): void;
  82328. }
  82329. }
  82330. declare module BABYLON {
  82331. /**
  82332. * Interface used to present a loading screen while loading a scene
  82333. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82334. */
  82335. export interface ILoadingScreen {
  82336. /**
  82337. * Function called to display the loading screen
  82338. */
  82339. displayLoadingUI: () => void;
  82340. /**
  82341. * Function called to hide the loading screen
  82342. */
  82343. hideLoadingUI: () => void;
  82344. /**
  82345. * Gets or sets the color to use for the background
  82346. */
  82347. loadingUIBackgroundColor: string;
  82348. /**
  82349. * Gets or sets the text to display while loading
  82350. */
  82351. loadingUIText: string;
  82352. }
  82353. /**
  82354. * Class used for the default loading screen
  82355. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82356. */
  82357. export class DefaultLoadingScreen implements ILoadingScreen {
  82358. private _renderingCanvas;
  82359. private _loadingText;
  82360. private _loadingDivBackgroundColor;
  82361. private _loadingDiv;
  82362. private _loadingTextDiv;
  82363. /**
  82364. * Creates a new default loading screen
  82365. * @param _renderingCanvas defines the canvas used to render the scene
  82366. * @param _loadingText defines the default text to display
  82367. * @param _loadingDivBackgroundColor defines the default background color
  82368. */
  82369. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82370. /**
  82371. * Function called to display the loading screen
  82372. */
  82373. displayLoadingUI(): void;
  82374. /**
  82375. * Function called to hide the loading screen
  82376. */
  82377. hideLoadingUI(): void;
  82378. /**
  82379. * Gets or sets the text to display while loading
  82380. */
  82381. loadingUIText: string;
  82382. /**
  82383. * Gets or sets the color to use for the background
  82384. */
  82385. loadingUIBackgroundColor: string;
  82386. private _resizeLoadingUI;
  82387. }
  82388. }
  82389. declare module BABYLON {
  82390. /**
  82391. * Settings for finer control over video usage
  82392. */
  82393. export interface VideoTextureSettings {
  82394. /**
  82395. * Applies `autoplay` to video, if specified
  82396. */
  82397. autoPlay?: boolean;
  82398. /**
  82399. * Applies `loop` to video, if specified
  82400. */
  82401. loop?: boolean;
  82402. /**
  82403. * Automatically updates internal texture from video at every frame in the render loop
  82404. */
  82405. autoUpdateTexture: boolean;
  82406. /**
  82407. * Image src displayed during the video loading or until the user interacts with the video.
  82408. */
  82409. poster?: string;
  82410. }
  82411. /**
  82412. * If you want to display a video in your scene, this is the special texture for that.
  82413. * This special texture works similar to other textures, with the exception of a few parameters.
  82414. * @see https://doc.babylonjs.com/how_to/video_texture
  82415. */
  82416. export class VideoTexture extends Texture {
  82417. /**
  82418. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82419. */
  82420. readonly autoUpdateTexture: boolean;
  82421. /**
  82422. * The video instance used by the texture internally
  82423. */
  82424. readonly video: HTMLVideoElement;
  82425. private _onUserActionRequestedObservable;
  82426. /**
  82427. * Event triggerd when a dom action is required by the user to play the video.
  82428. * This happens due to recent changes in browser policies preventing video to auto start.
  82429. */
  82430. readonly onUserActionRequestedObservable: Observable<Texture>;
  82431. private _generateMipMaps;
  82432. private _engine;
  82433. private _stillImageCaptured;
  82434. private _displayingPosterTexture;
  82435. private _settings;
  82436. private _createInternalTextureOnEvent;
  82437. /**
  82438. * Creates a video texture.
  82439. * If you want to display a video in your scene, this is the special texture for that.
  82440. * This special texture works similar to other textures, with the exception of a few parameters.
  82441. * @see https://doc.babylonjs.com/how_to/video_texture
  82442. * @param name optional name, will detect from video source, if not defined
  82443. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82444. * @param scene is obviously the current scene.
  82445. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82446. * @param invertY is false by default but can be used to invert video on Y axis
  82447. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82448. * @param settings allows finer control over video usage
  82449. */
  82450. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82451. private _getName;
  82452. private _getVideo;
  82453. private _createInternalTexture;
  82454. private reset;
  82455. /**
  82456. * @hidden Internal method to initiate `update`.
  82457. */
  82458. _rebuild(): void;
  82459. /**
  82460. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82461. */
  82462. update(): void;
  82463. /**
  82464. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82465. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82466. */
  82467. updateTexture(isVisible: boolean): void;
  82468. protected _updateInternalTexture: () => void;
  82469. /**
  82470. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82471. * @param url New url.
  82472. */
  82473. updateURL(url: string): void;
  82474. /**
  82475. * Dispose the texture and release its associated resources.
  82476. */
  82477. dispose(): void;
  82478. /**
  82479. * Creates a video texture straight from your WebCam video feed.
  82480. * @param scene Define the scene the texture should be created in
  82481. * @param onReady Define a callback to triggered once the texture will be ready
  82482. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82483. */
  82484. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82485. minWidth: number;
  82486. maxWidth: number;
  82487. minHeight: number;
  82488. maxHeight: number;
  82489. deviceId: string;
  82490. }): void;
  82491. }
  82492. }
  82493. declare module BABYLON {
  82494. /**
  82495. * Interface for attribute information associated with buffer instanciation
  82496. */
  82497. export class InstancingAttributeInfo {
  82498. /**
  82499. * Index/offset of the attribute in the vertex shader
  82500. */
  82501. index: number;
  82502. /**
  82503. * size of the attribute, 1, 2, 3 or 4
  82504. */
  82505. attributeSize: number;
  82506. /**
  82507. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82508. * default is FLOAT
  82509. */
  82510. attribyteType: number;
  82511. /**
  82512. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82513. */
  82514. normalized: boolean;
  82515. /**
  82516. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82517. */
  82518. offset: number;
  82519. /**
  82520. * Name of the GLSL attribute, for debugging purpose only
  82521. */
  82522. attributeName: string;
  82523. }
  82524. /**
  82525. * Define options used to create a depth texture
  82526. */
  82527. export class DepthTextureCreationOptions {
  82528. /** Specifies whether or not a stencil should be allocated in the texture */
  82529. generateStencil?: boolean;
  82530. /** Specifies whether or not bilinear filtering is enable on the texture */
  82531. bilinearFiltering?: boolean;
  82532. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82533. comparisonFunction?: number;
  82534. /** Specifies if the created texture is a cube texture */
  82535. isCube?: boolean;
  82536. }
  82537. /**
  82538. * Class used to describe the capabilities of the engine relatively to the current browser
  82539. */
  82540. export class EngineCapabilities {
  82541. /** Maximum textures units per fragment shader */
  82542. maxTexturesImageUnits: number;
  82543. /** Maximum texture units per vertex shader */
  82544. maxVertexTextureImageUnits: number;
  82545. /** Maximum textures units in the entire pipeline */
  82546. maxCombinedTexturesImageUnits: number;
  82547. /** Maximum texture size */
  82548. maxTextureSize: number;
  82549. /** Maximum cube texture size */
  82550. maxCubemapTextureSize: number;
  82551. /** Maximum render texture size */
  82552. maxRenderTextureSize: number;
  82553. /** Maximum number of vertex attributes */
  82554. maxVertexAttribs: number;
  82555. /** Maximum number of varyings */
  82556. maxVaryingVectors: number;
  82557. /** Maximum number of uniforms per vertex shader */
  82558. maxVertexUniformVectors: number;
  82559. /** Maximum number of uniforms per fragment shader */
  82560. maxFragmentUniformVectors: number;
  82561. /** Defines if standard derivates (dx/dy) are supported */
  82562. standardDerivatives: boolean;
  82563. /** Defines if s3tc texture compression is supported */
  82564. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82565. /** Defines if pvrtc texture compression is supported */
  82566. pvrtc: any;
  82567. /** Defines if etc1 texture compression is supported */
  82568. etc1: any;
  82569. /** Defines if etc2 texture compression is supported */
  82570. etc2: any;
  82571. /** Defines if astc texture compression is supported */
  82572. astc: any;
  82573. /** Defines if float textures are supported */
  82574. textureFloat: boolean;
  82575. /** Defines if vertex array objects are supported */
  82576. vertexArrayObject: boolean;
  82577. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82578. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82579. /** Gets the maximum level of anisotropy supported */
  82580. maxAnisotropy: number;
  82581. /** Defines if instancing is supported */
  82582. instancedArrays: boolean;
  82583. /** Defines if 32 bits indices are supported */
  82584. uintIndices: boolean;
  82585. /** Defines if high precision shaders are supported */
  82586. highPrecisionShaderSupported: boolean;
  82587. /** Defines if depth reading in the fragment shader is supported */
  82588. fragmentDepthSupported: boolean;
  82589. /** Defines if float texture linear filtering is supported*/
  82590. textureFloatLinearFiltering: boolean;
  82591. /** Defines if rendering to float textures is supported */
  82592. textureFloatRender: boolean;
  82593. /** Defines if half float textures are supported*/
  82594. textureHalfFloat: boolean;
  82595. /** Defines if half float texture linear filtering is supported*/
  82596. textureHalfFloatLinearFiltering: boolean;
  82597. /** Defines if rendering to half float textures is supported */
  82598. textureHalfFloatRender: boolean;
  82599. /** Defines if textureLOD shader command is supported */
  82600. textureLOD: boolean;
  82601. /** Defines if draw buffers extension is supported */
  82602. drawBuffersExtension: boolean;
  82603. /** Defines if depth textures are supported */
  82604. depthTextureExtension: boolean;
  82605. /** Defines if float color buffer are supported */
  82606. colorBufferFloat: boolean;
  82607. /** Gets disjoint timer query extension (null if not supported) */
  82608. timerQuery: EXT_disjoint_timer_query;
  82609. /** Defines if timestamp can be used with timer query */
  82610. canUseTimestampForTimerQuery: boolean;
  82611. /** Function used to let the system compiles shaders in background */
  82612. parallelShaderCompile: {
  82613. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82614. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82615. COMPLETION_STATUS_KHR: number;
  82616. };
  82617. }
  82618. /** Interface defining initialization parameters for Engine class */
  82619. export interface EngineOptions extends WebGLContextAttributes {
  82620. /**
  82621. * Defines if the engine should no exceed a specified device ratio
  82622. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82623. */
  82624. limitDeviceRatio?: number;
  82625. /**
  82626. * Defines if webvr should be enabled automatically
  82627. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82628. */
  82629. autoEnableWebVR?: boolean;
  82630. /**
  82631. * Defines if webgl2 should be turned off even if supported
  82632. * @see http://doc.babylonjs.com/features/webgl2
  82633. */
  82634. disableWebGL2Support?: boolean;
  82635. /**
  82636. * Defines if webaudio should be initialized as well
  82637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82638. */
  82639. audioEngine?: boolean;
  82640. /**
  82641. * Defines if animations should run using a deterministic lock step
  82642. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82643. */
  82644. deterministicLockstep?: boolean;
  82645. /** Defines the maximum steps to use with deterministic lock step mode */
  82646. lockstepMaxSteps?: number;
  82647. /**
  82648. * Defines that engine should ignore context lost events
  82649. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82650. */
  82651. doNotHandleContextLost?: boolean;
  82652. /**
  82653. * Defines that engine should ignore modifying touch action attribute and style
  82654. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82655. */
  82656. doNotHandleTouchAction?: boolean;
  82657. }
  82658. /**
  82659. * Defines the interface used by display changed events
  82660. */
  82661. export interface IDisplayChangedEventArgs {
  82662. /** Gets the vrDisplay object (if any) */
  82663. vrDisplay: Nullable<any>;
  82664. /** Gets a boolean indicating if webVR is supported */
  82665. vrSupported: boolean;
  82666. }
  82667. /**
  82668. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82669. */
  82670. export class Engine {
  82671. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82672. static ExceptionList: ({
  82673. key: string;
  82674. capture: string;
  82675. captureConstraint: number;
  82676. targets: string[];
  82677. } | {
  82678. key: string;
  82679. capture: null;
  82680. captureConstraint: null;
  82681. targets: string[];
  82682. })[];
  82683. /** Gets the list of created engines */
  82684. static readonly Instances: Engine[];
  82685. /**
  82686. * Gets the latest created engine
  82687. */
  82688. static readonly LastCreatedEngine: Nullable<Engine>;
  82689. /**
  82690. * Gets the latest created scene
  82691. */
  82692. static readonly LastCreatedScene: Nullable<Scene>;
  82693. /**
  82694. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82695. * @param flag defines which part of the materials must be marked as dirty
  82696. * @param predicate defines a predicate used to filter which materials should be affected
  82697. */
  82698. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82699. /**
  82700. * Hidden
  82701. */
  82702. static _TextureLoaders: IInternalTextureLoader[];
  82703. /** Defines that alpha blending is disabled */
  82704. static readonly ALPHA_DISABLE: number;
  82705. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82706. static readonly ALPHA_ADD: number;
  82707. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82708. static readonly ALPHA_COMBINE: number;
  82709. /** Defines that alpha blending to DEST - SRC * DEST */
  82710. static readonly ALPHA_SUBTRACT: number;
  82711. /** Defines that alpha blending to SRC * DEST */
  82712. static readonly ALPHA_MULTIPLY: number;
  82713. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  82714. static readonly ALPHA_MAXIMIZED: number;
  82715. /** Defines that alpha blending to SRC + DEST */
  82716. static readonly ALPHA_ONEONE: number;
  82717. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  82718. static readonly ALPHA_PREMULTIPLIED: number;
  82719. /**
  82720. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  82721. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82722. */
  82723. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82724. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  82725. static readonly ALPHA_INTERPOLATE: number;
  82726. /**
  82727. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  82728. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82729. */
  82730. static readonly ALPHA_SCREENMODE: number;
  82731. /** Defines that the ressource is not delayed*/
  82732. static readonly DELAYLOADSTATE_NONE: number;
  82733. /** Defines that the ressource was successfully delay loaded */
  82734. static readonly DELAYLOADSTATE_LOADED: number;
  82735. /** Defines that the ressource is currently delay loading */
  82736. static readonly DELAYLOADSTATE_LOADING: number;
  82737. /** Defines that the ressource is delayed and has not started loading */
  82738. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82739. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82740. static readonly NEVER: number;
  82741. /** 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 */
  82742. static readonly ALWAYS: number;
  82743. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82744. static readonly LESS: number;
  82745. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82746. static readonly EQUAL: number;
  82747. /** 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 */
  82748. static readonly LEQUAL: number;
  82749. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82750. static readonly GREATER: number;
  82751. /** 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 */
  82752. static readonly GEQUAL: number;
  82753. /** 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 */
  82754. static readonly NOTEQUAL: number;
  82755. /** Passed to stencilOperation to specify that stencil value must be kept */
  82756. static readonly KEEP: number;
  82757. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82758. static readonly REPLACE: number;
  82759. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82760. static readonly INCR: number;
  82761. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82762. static readonly DECR: number;
  82763. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82764. static readonly INVERT: number;
  82765. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82766. static readonly INCR_WRAP: number;
  82767. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82768. static readonly DECR_WRAP: number;
  82769. /** Texture is not repeating outside of 0..1 UVs */
  82770. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82771. /** Texture is repeating outside of 0..1 UVs */
  82772. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82773. /** Texture is repeating and mirrored */
  82774. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82775. /** ALPHA */
  82776. static readonly TEXTUREFORMAT_ALPHA: number;
  82777. /** LUMINANCE */
  82778. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82779. /** LUMINANCE_ALPHA */
  82780. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82781. /** RGB */
  82782. static readonly TEXTUREFORMAT_RGB: number;
  82783. /** RGBA */
  82784. static readonly TEXTUREFORMAT_RGBA: number;
  82785. /** RED */
  82786. static readonly TEXTUREFORMAT_RED: number;
  82787. /** RED (2nd reference) */
  82788. static readonly TEXTUREFORMAT_R: number;
  82789. /** RG */
  82790. static readonly TEXTUREFORMAT_RG: number;
  82791. /** RED_INTEGER */
  82792. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82793. /** RED_INTEGER (2nd reference) */
  82794. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82795. /** RG_INTEGER */
  82796. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82797. /** RGB_INTEGER */
  82798. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82799. /** RGBA_INTEGER */
  82800. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82801. /** UNSIGNED_BYTE */
  82802. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82803. /** UNSIGNED_BYTE (2nd reference) */
  82804. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82805. /** FLOAT */
  82806. static readonly TEXTURETYPE_FLOAT: number;
  82807. /** HALF_FLOAT */
  82808. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82809. /** BYTE */
  82810. static readonly TEXTURETYPE_BYTE: number;
  82811. /** SHORT */
  82812. static readonly TEXTURETYPE_SHORT: number;
  82813. /** UNSIGNED_SHORT */
  82814. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82815. /** INT */
  82816. static readonly TEXTURETYPE_INT: number;
  82817. /** UNSIGNED_INT */
  82818. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82819. /** UNSIGNED_SHORT_4_4_4_4 */
  82820. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82821. /** UNSIGNED_SHORT_5_5_5_1 */
  82822. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82823. /** UNSIGNED_SHORT_5_6_5 */
  82824. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82825. /** UNSIGNED_INT_2_10_10_10_REV */
  82826. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82827. /** UNSIGNED_INT_24_8 */
  82828. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82829. /** UNSIGNED_INT_10F_11F_11F_REV */
  82830. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82831. /** UNSIGNED_INT_5_9_9_9_REV */
  82832. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82833. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82834. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82835. /** nearest is mag = nearest and min = nearest and mip = linear */
  82836. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82838. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82839. /** Trilinear is mag = linear and min = linear and mip = linear */
  82840. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82841. /** nearest is mag = nearest and min = nearest and mip = linear */
  82842. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82843. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82844. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82845. /** Trilinear is mag = linear and min = linear and mip = linear */
  82846. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82847. /** mag = nearest and min = nearest and mip = nearest */
  82848. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82849. /** mag = nearest and min = linear and mip = nearest */
  82850. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82851. /** mag = nearest and min = linear and mip = linear */
  82852. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82853. /** mag = nearest and min = linear and mip = none */
  82854. static readonly TEXTURE_NEAREST_LINEAR: number;
  82855. /** mag = nearest and min = nearest and mip = none */
  82856. static readonly TEXTURE_NEAREST_NEAREST: number;
  82857. /** mag = linear and min = nearest and mip = nearest */
  82858. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82859. /** mag = linear and min = nearest and mip = linear */
  82860. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82861. /** mag = linear and min = linear and mip = none */
  82862. static readonly TEXTURE_LINEAR_LINEAR: number;
  82863. /** mag = linear and min = nearest and mip = none */
  82864. static readonly TEXTURE_LINEAR_NEAREST: number;
  82865. /** Explicit coordinates mode */
  82866. static readonly TEXTURE_EXPLICIT_MODE: number;
  82867. /** Spherical coordinates mode */
  82868. static readonly TEXTURE_SPHERICAL_MODE: number;
  82869. /** Planar coordinates mode */
  82870. static readonly TEXTURE_PLANAR_MODE: number;
  82871. /** Cubic coordinates mode */
  82872. static readonly TEXTURE_CUBIC_MODE: number;
  82873. /** Projection coordinates mode */
  82874. static readonly TEXTURE_PROJECTION_MODE: number;
  82875. /** Skybox coordinates mode */
  82876. static readonly TEXTURE_SKYBOX_MODE: number;
  82877. /** Inverse Cubic coordinates mode */
  82878. static readonly TEXTURE_INVCUBIC_MODE: number;
  82879. /** Equirectangular coordinates mode */
  82880. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82881. /** Equirectangular Fixed coordinates mode */
  82882. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82883. /** Equirectangular Fixed Mirrored coordinates mode */
  82884. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82885. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82886. static readonly SCALEMODE_FLOOR: number;
  82887. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82888. static readonly SCALEMODE_NEAREST: number;
  82889. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82890. static readonly SCALEMODE_CEILING: number;
  82891. /**
  82892. * Returns the current version of the framework
  82893. */
  82894. static readonly Version: string;
  82895. /**
  82896. * Returns a string describing the current engine
  82897. */
  82898. readonly description: string;
  82899. /**
  82900. * Gets or sets the epsilon value used by collision engine
  82901. */
  82902. static CollisionsEpsilon: number;
  82903. /**
  82904. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  82905. */
  82906. static ShadersRepository: string;
  82907. /**
  82908. * Method called to create the default loading screen.
  82909. * This can be overriden in your own app.
  82910. * @param canvas The rendering canvas element
  82911. * @returns The loading screen
  82912. */
  82913. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  82914. /**
  82915. * Method called to create the default rescale post process on each engine.
  82916. */
  82917. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  82918. /**
  82919. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  82920. */
  82921. forcePOTTextures: boolean;
  82922. /**
  82923. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  82924. */
  82925. isFullscreen: boolean;
  82926. /**
  82927. * Gets a boolean indicating if the pointer is currently locked
  82928. */
  82929. isPointerLock: boolean;
  82930. /**
  82931. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  82932. */
  82933. cullBackFaces: boolean;
  82934. /**
  82935. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  82936. */
  82937. renderEvenInBackground: boolean;
  82938. /**
  82939. * Gets or sets a boolean indicating that cache can be kept between frames
  82940. */
  82941. preventCacheWipeBetweenFrames: boolean;
  82942. /**
  82943. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  82944. **/
  82945. enableOfflineSupport: boolean;
  82946. /**
  82947. * 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)
  82948. **/
  82949. disableManifestCheck: boolean;
  82950. /**
  82951. * Gets the list of created scenes
  82952. */
  82953. scenes: Scene[];
  82954. /**
  82955. * Event raised when a new scene is created
  82956. */
  82957. onNewSceneAddedObservable: Observable<Scene>;
  82958. /**
  82959. * Gets the list of created postprocesses
  82960. */
  82961. postProcesses: PostProcess[];
  82962. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  82963. validateShaderPrograms: boolean;
  82964. /**
  82965. * Observable event triggered each time the rendering canvas is resized
  82966. */
  82967. onResizeObservable: Observable<Engine>;
  82968. /**
  82969. * Observable event triggered each time the canvas loses focus
  82970. */
  82971. onCanvasBlurObservable: Observable<Engine>;
  82972. /**
  82973. * Observable event triggered each time the canvas gains focus
  82974. */
  82975. onCanvasFocusObservable: Observable<Engine>;
  82976. /**
  82977. * Observable event triggered each time the canvas receives pointerout event
  82978. */
  82979. onCanvasPointerOutObservable: Observable<PointerEvent>;
  82980. /**
  82981. * Observable event triggered before each texture is initialized
  82982. */
  82983. onBeforeTextureInitObservable: Observable<Texture>;
  82984. private _vrDisplay;
  82985. private _vrSupported;
  82986. private _oldSize;
  82987. private _oldHardwareScaleFactor;
  82988. private _vrExclusivePointerMode;
  82989. private _webVRInitPromise;
  82990. /**
  82991. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82992. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82993. */
  82994. readonly isInVRExclusivePointerMode: boolean;
  82995. /**
  82996. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  82997. */
  82998. disableUniformBuffers: boolean;
  82999. /** @hidden */
  83000. _uniformBuffers: UniformBuffer[];
  83001. /**
  83002. * Gets a boolean indicating that the engine supports uniform buffers
  83003. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83004. */
  83005. readonly supportsUniformBuffers: boolean;
  83006. /**
  83007. * Observable raised when the engine begins a new frame
  83008. */
  83009. onBeginFrameObservable: Observable<Engine>;
  83010. /**
  83011. * If set, will be used to request the next animation frame for the render loop
  83012. */
  83013. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83014. /**
  83015. * Observable raised when the engine ends the current frame
  83016. */
  83017. onEndFrameObservable: Observable<Engine>;
  83018. /**
  83019. * Observable raised when the engine is about to compile a shader
  83020. */
  83021. onBeforeShaderCompilationObservable: Observable<Engine>;
  83022. /**
  83023. * Observable raised when the engine has jsut compiled a shader
  83024. */
  83025. onAfterShaderCompilationObservable: Observable<Engine>;
  83026. /** @hidden */
  83027. _gl: WebGLRenderingContext;
  83028. private _renderingCanvas;
  83029. private _windowIsBackground;
  83030. private _webGLVersion;
  83031. /**
  83032. * Gets a boolean indicating that only power of 2 textures are supported
  83033. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83034. */
  83035. readonly needPOTTextures: boolean;
  83036. /** @hidden */
  83037. _badOS: boolean;
  83038. /** @hidden */
  83039. _badDesktopOS: boolean;
  83040. /**
  83041. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83042. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83043. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83044. */
  83045. disableTextureBindingOptimization: boolean;
  83046. /**
  83047. * Gets the audio engine
  83048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83049. * @ignorenaming
  83050. */
  83051. static audioEngine: IAudioEngine;
  83052. /**
  83053. * Default AudioEngine factory responsible of creating the Audio Engine.
  83054. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83055. */
  83056. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83057. /**
  83058. * Default offline support factory responsible of creating a tool used to store data locally.
  83059. * By default, this will create a Database object if the workload has been embedded.
  83060. */
  83061. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83062. private _onFocus;
  83063. private _onBlur;
  83064. private _onCanvasPointerOut;
  83065. private _onCanvasBlur;
  83066. private _onCanvasFocus;
  83067. private _onFullscreenChange;
  83068. private _onPointerLockChange;
  83069. private _onVRDisplayPointerRestricted;
  83070. private _onVRDisplayPointerUnrestricted;
  83071. private _onVrDisplayConnect;
  83072. private _onVrDisplayDisconnect;
  83073. private _onVrDisplayPresentChange;
  83074. /**
  83075. * Observable signaled when VR display mode changes
  83076. */
  83077. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83078. /**
  83079. * Observable signaled when VR request present is complete
  83080. */
  83081. onVRRequestPresentComplete: Observable<boolean>;
  83082. /**
  83083. * Observable signaled when VR request present starts
  83084. */
  83085. onVRRequestPresentStart: Observable<Engine>;
  83086. private _hardwareScalingLevel;
  83087. /** @hidden */
  83088. protected _caps: EngineCapabilities;
  83089. private _pointerLockRequested;
  83090. private _isStencilEnable;
  83091. private _colorWrite;
  83092. private _loadingScreen;
  83093. /** @hidden */
  83094. _drawCalls: PerfCounter;
  83095. /** @hidden */
  83096. _textureCollisions: PerfCounter;
  83097. private _glVersion;
  83098. private _glRenderer;
  83099. private _glVendor;
  83100. private _videoTextureSupported;
  83101. private _renderingQueueLaunched;
  83102. private _activeRenderLoops;
  83103. private _deterministicLockstep;
  83104. private _lockstepMaxSteps;
  83105. /**
  83106. * Observable signaled when a context lost event is raised
  83107. */
  83108. onContextLostObservable: Observable<Engine>;
  83109. /**
  83110. * Observable signaled when a context restored event is raised
  83111. */
  83112. onContextRestoredObservable: Observable<Engine>;
  83113. private _onContextLost;
  83114. private _onContextRestored;
  83115. private _contextWasLost;
  83116. private _doNotHandleContextLost;
  83117. /**
  83118. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83120. */
  83121. doNotHandleContextLost: boolean;
  83122. private _performanceMonitor;
  83123. private _fps;
  83124. private _deltaTime;
  83125. /**
  83126. * Turn this value on if you want to pause FPS computation when in background
  83127. */
  83128. disablePerformanceMonitorInBackground: boolean;
  83129. /**
  83130. * Gets the performance monitor attached to this engine
  83131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83132. */
  83133. readonly performanceMonitor: PerformanceMonitor;
  83134. /** @hidden */
  83135. protected _depthCullingState: _DepthCullingState;
  83136. /** @hidden */
  83137. protected _stencilState: _StencilState;
  83138. /** @hidden */
  83139. protected _alphaState: _AlphaState;
  83140. /** @hidden */
  83141. protected _alphaMode: number;
  83142. protected _internalTexturesCache: InternalTexture[];
  83143. /** @hidden */
  83144. protected _activeChannel: number;
  83145. private _currentTextureChannel;
  83146. /** @hidden */
  83147. protected _boundTexturesCache: {
  83148. [key: string]: Nullable<InternalTexture>;
  83149. };
  83150. /** @hidden */
  83151. protected _currentEffect: Nullable<Effect>;
  83152. /** @hidden */
  83153. protected _currentProgram: Nullable<WebGLProgram>;
  83154. private _compiledEffects;
  83155. private _vertexAttribArraysEnabled;
  83156. /** @hidden */
  83157. protected _cachedViewport: Nullable<Viewport>;
  83158. private _cachedVertexArrayObject;
  83159. /** @hidden */
  83160. protected _cachedVertexBuffers: any;
  83161. /** @hidden */
  83162. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83163. /** @hidden */
  83164. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83165. /** @hidden */
  83166. protected _currentRenderTarget: Nullable<InternalTexture>;
  83167. private _uintIndicesCurrentlySet;
  83168. private _currentBoundBuffer;
  83169. /** @hidden */
  83170. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83171. private _currentBufferPointers;
  83172. private _currentInstanceLocations;
  83173. private _currentInstanceBuffers;
  83174. private _textureUnits;
  83175. private _firstBoundInternalTextureTracker;
  83176. private _lastBoundInternalTextureTracker;
  83177. private _workingCanvas;
  83178. private _workingContext;
  83179. private _rescalePostProcess;
  83180. private _dummyFramebuffer;
  83181. private _externalData;
  83182. private _bindedRenderFunction;
  83183. private _vaoRecordInProgress;
  83184. private _mustWipeVertexAttributes;
  83185. private _emptyTexture;
  83186. private _emptyCubeTexture;
  83187. private _emptyTexture3D;
  83188. /** @hidden */
  83189. _frameHandler: number;
  83190. private _nextFreeTextureSlots;
  83191. private _maxSimultaneousTextures;
  83192. private _activeRequests;
  83193. private _texturesSupported;
  83194. private _textureFormatInUse;
  83195. /**
  83196. * Gets the list of texture formats supported
  83197. */
  83198. readonly texturesSupported: Array<string>;
  83199. /**
  83200. * Gets the list of texture formats in use
  83201. */
  83202. readonly textureFormatInUse: Nullable<string>;
  83203. /**
  83204. * Gets the current viewport
  83205. */
  83206. readonly currentViewport: Nullable<Viewport>;
  83207. /**
  83208. * Gets the default empty texture
  83209. */
  83210. readonly emptyTexture: InternalTexture;
  83211. /**
  83212. * Gets the default empty 3D texture
  83213. */
  83214. readonly emptyTexture3D: InternalTexture;
  83215. /**
  83216. * Gets the default empty cube texture
  83217. */
  83218. readonly emptyCubeTexture: InternalTexture;
  83219. /**
  83220. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83221. */
  83222. readonly premultipliedAlpha: boolean;
  83223. /**
  83224. * Creates a new engine
  83225. * @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
  83226. * @param antialias defines enable antialiasing (default: false)
  83227. * @param options defines further options to be sent to the getContext() function
  83228. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83229. */
  83230. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83231. private _disableTouchAction;
  83232. private _rebuildInternalTextures;
  83233. private _rebuildEffects;
  83234. /**
  83235. * Gets a boolean indicating if all created effects are ready
  83236. * @returns true if all effects are ready
  83237. */
  83238. areAllEffectsReady(): boolean;
  83239. private _rebuildBuffers;
  83240. private _initGLContext;
  83241. /**
  83242. * Gets version of the current webGL context
  83243. */
  83244. readonly webGLVersion: number;
  83245. /**
  83246. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83247. */
  83248. readonly isStencilEnable: boolean;
  83249. private _prepareWorkingCanvas;
  83250. /**
  83251. * Reset the texture cache to empty state
  83252. */
  83253. resetTextureCache(): void;
  83254. /**
  83255. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83257. * @returns true if engine is in deterministic lock step mode
  83258. */
  83259. isDeterministicLockStep(): boolean;
  83260. /**
  83261. * Gets the max steps when engine is running in deterministic lock step
  83262. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83263. * @returns the max steps
  83264. */
  83265. getLockstepMaxSteps(): number;
  83266. /**
  83267. * Gets an object containing information about the current webGL context
  83268. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83269. */
  83270. getGlInfo(): {
  83271. vendor: string;
  83272. renderer: string;
  83273. version: string;
  83274. };
  83275. /**
  83276. * Gets current aspect ratio
  83277. * @param camera defines the camera to use to get the aspect ratio
  83278. * @param useScreen defines if screen size must be used (or the current render target if any)
  83279. * @returns a number defining the aspect ratio
  83280. */
  83281. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83282. /**
  83283. * Gets current screen aspect ratio
  83284. * @returns a number defining the aspect ratio
  83285. */
  83286. getScreenAspectRatio(): number;
  83287. /**
  83288. * Gets the current render width
  83289. * @param useScreen defines if screen size must be used (or the current render target if any)
  83290. * @returns a number defining the current render width
  83291. */
  83292. getRenderWidth(useScreen?: boolean): number;
  83293. /**
  83294. * Gets the current render height
  83295. * @param useScreen defines if screen size must be used (or the current render target if any)
  83296. * @returns a number defining the current render height
  83297. */
  83298. getRenderHeight(useScreen?: boolean): number;
  83299. /**
  83300. * Gets the HTML canvas attached with the current webGL context
  83301. * @returns a HTML canvas
  83302. */
  83303. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83304. /**
  83305. * Gets the client rect of the HTML canvas attached with the current webGL context
  83306. * @returns a client rectanglee
  83307. */
  83308. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83309. /**
  83310. * Defines the hardware scaling level.
  83311. * By default the hardware scaling level is computed from the window device ratio.
  83312. * 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.
  83313. * @param level defines the level to use
  83314. */
  83315. setHardwareScalingLevel(level: number): void;
  83316. /**
  83317. * Gets the current hardware scaling level.
  83318. * By default the hardware scaling level is computed from the window device ratio.
  83319. * 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.
  83320. * @returns a number indicating the current hardware scaling level
  83321. */
  83322. getHardwareScalingLevel(): number;
  83323. /**
  83324. * Gets the list of loaded textures
  83325. * @returns an array containing all loaded textures
  83326. */
  83327. getLoadedTexturesCache(): InternalTexture[];
  83328. /**
  83329. * Gets the object containing all engine capabilities
  83330. * @returns the EngineCapabilities object
  83331. */
  83332. getCaps(): EngineCapabilities;
  83333. /**
  83334. * Gets the current depth function
  83335. * @returns a number defining the depth function
  83336. */
  83337. getDepthFunction(): Nullable<number>;
  83338. /**
  83339. * Sets the current depth function
  83340. * @param depthFunc defines the function to use
  83341. */
  83342. setDepthFunction(depthFunc: number): void;
  83343. /**
  83344. * Sets the current depth function to GREATER
  83345. */
  83346. setDepthFunctionToGreater(): void;
  83347. /**
  83348. * Sets the current depth function to GEQUAL
  83349. */
  83350. setDepthFunctionToGreaterOrEqual(): void;
  83351. /**
  83352. * Sets the current depth function to LESS
  83353. */
  83354. setDepthFunctionToLess(): void;
  83355. /**
  83356. * Sets the current depth function to LEQUAL
  83357. */
  83358. setDepthFunctionToLessOrEqual(): void;
  83359. /**
  83360. * Gets a boolean indicating if stencil buffer is enabled
  83361. * @returns the current stencil buffer state
  83362. */
  83363. getStencilBuffer(): boolean;
  83364. /**
  83365. * Enable or disable the stencil buffer
  83366. * @param enable defines if the stencil buffer must be enabled or disabled
  83367. */
  83368. setStencilBuffer(enable: boolean): void;
  83369. /**
  83370. * Gets the current stencil mask
  83371. * @returns a number defining the new stencil mask to use
  83372. */
  83373. getStencilMask(): number;
  83374. /**
  83375. * Sets the current stencil mask
  83376. * @param mask defines the new stencil mask to use
  83377. */
  83378. setStencilMask(mask: number): void;
  83379. /**
  83380. * Gets the current stencil function
  83381. * @returns a number defining the stencil function to use
  83382. */
  83383. getStencilFunction(): number;
  83384. /**
  83385. * Gets the current stencil reference value
  83386. * @returns a number defining the stencil reference value to use
  83387. */
  83388. getStencilFunctionReference(): number;
  83389. /**
  83390. * Gets the current stencil mask
  83391. * @returns a number defining the stencil mask to use
  83392. */
  83393. getStencilFunctionMask(): number;
  83394. /**
  83395. * Sets the current stencil function
  83396. * @param stencilFunc defines the new stencil function to use
  83397. */
  83398. setStencilFunction(stencilFunc: number): void;
  83399. /**
  83400. * Sets the current stencil reference
  83401. * @param reference defines the new stencil reference to use
  83402. */
  83403. setStencilFunctionReference(reference: number): void;
  83404. /**
  83405. * Sets the current stencil mask
  83406. * @param mask defines the new stencil mask to use
  83407. */
  83408. setStencilFunctionMask(mask: number): void;
  83409. /**
  83410. * Gets the current stencil operation when stencil fails
  83411. * @returns a number defining stencil operation to use when stencil fails
  83412. */
  83413. getStencilOperationFail(): number;
  83414. /**
  83415. * Gets the current stencil operation when depth fails
  83416. * @returns a number defining stencil operation to use when depth fails
  83417. */
  83418. getStencilOperationDepthFail(): number;
  83419. /**
  83420. * Gets the current stencil operation when stencil passes
  83421. * @returns a number defining stencil operation to use when stencil passes
  83422. */
  83423. getStencilOperationPass(): number;
  83424. /**
  83425. * Sets the stencil operation to use when stencil fails
  83426. * @param operation defines the stencil operation to use when stencil fails
  83427. */
  83428. setStencilOperationFail(operation: number): void;
  83429. /**
  83430. * Sets the stencil operation to use when depth fails
  83431. * @param operation defines the stencil operation to use when depth fails
  83432. */
  83433. setStencilOperationDepthFail(operation: number): void;
  83434. /**
  83435. * Sets the stencil operation to use when stencil passes
  83436. * @param operation defines the stencil operation to use when stencil passes
  83437. */
  83438. setStencilOperationPass(operation: number): void;
  83439. /**
  83440. * Sets a boolean indicating if the dithering state is enabled or disabled
  83441. * @param value defines the dithering state
  83442. */
  83443. setDitheringState(value: boolean): void;
  83444. /**
  83445. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83446. * @param value defines the rasterizer state
  83447. */
  83448. setRasterizerState(value: boolean): void;
  83449. /**
  83450. * stop executing a render loop function and remove it from the execution array
  83451. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83452. */
  83453. stopRenderLoop(renderFunction?: () => void): void;
  83454. /** @hidden */
  83455. _renderLoop(): void;
  83456. /**
  83457. * Register and execute a render loop. The engine can have more than one render function
  83458. * @param renderFunction defines the function to continuously execute
  83459. */
  83460. runRenderLoop(renderFunction: () => void): void;
  83461. /**
  83462. * Toggle full screen mode
  83463. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83464. */
  83465. switchFullscreen(requestPointerLock: boolean): void;
  83466. /**
  83467. * Enters full screen mode
  83468. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83469. */
  83470. enterFullscreen(requestPointerLock: boolean): void;
  83471. /**
  83472. * Exits full screen mode
  83473. */
  83474. exitFullscreen(): void;
  83475. /**
  83476. * Clear the current render buffer or the current render target (if any is set up)
  83477. * @param color defines the color to use
  83478. * @param backBuffer defines if the back buffer must be cleared
  83479. * @param depth defines if the depth buffer must be cleared
  83480. * @param stencil defines if the stencil buffer must be cleared
  83481. */
  83482. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83483. /**
  83484. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83485. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83486. * @param y defines the y-coordinate of the corner of the clear rectangle
  83487. * @param width defines the width of the clear rectangle
  83488. * @param height defines the height of the clear rectangle
  83489. * @param clearColor defines the clear color
  83490. */
  83491. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83492. /**
  83493. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83494. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83495. * @param y defines the y-coordinate of the corner of the clear rectangle
  83496. * @param width defines the width of the clear rectangle
  83497. * @param height defines the height of the clear rectangle
  83498. */
  83499. enableScissor(x: number, y: number, width: number, height: number): void;
  83500. /**
  83501. * Disable previously set scissor test rectangle
  83502. */
  83503. disableScissor(): void;
  83504. private _viewportCached;
  83505. /** @hidden */
  83506. _viewport(x: number, y: number, width: number, height: number): void;
  83507. /**
  83508. * Set the WebGL's viewport
  83509. * @param viewport defines the viewport element to be used
  83510. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83511. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83512. */
  83513. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83514. /**
  83515. * Directly set the WebGL Viewport
  83516. * @param x defines the x coordinate of the viewport (in screen space)
  83517. * @param y defines the y coordinate of the viewport (in screen space)
  83518. * @param width defines the width of the viewport (in screen space)
  83519. * @param height defines the height of the viewport (in screen space)
  83520. * @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
  83521. */
  83522. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83523. /**
  83524. * Begin a new frame
  83525. */
  83526. beginFrame(): void;
  83527. /**
  83528. * Enf the current frame
  83529. */
  83530. endFrame(): void;
  83531. /**
  83532. * Resize the view according to the canvas' size
  83533. */
  83534. resize(): void;
  83535. /**
  83536. * Force a specific size of the canvas
  83537. * @param width defines the new canvas' width
  83538. * @param height defines the new canvas' height
  83539. */
  83540. setSize(width: number, height: number): void;
  83541. /**
  83542. * Gets a boolean indicating if a webVR device was detected
  83543. * @returns true if a webVR device was detected
  83544. */
  83545. isVRDevicePresent(): boolean;
  83546. /**
  83547. * Gets the current webVR device
  83548. * @returns the current webVR device (or null)
  83549. */
  83550. getVRDevice(): any;
  83551. /**
  83552. * Initializes a webVR display and starts listening to display change events
  83553. * The onVRDisplayChangedObservable will be notified upon these changes
  83554. * @returns The onVRDisplayChangedObservable
  83555. */
  83556. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83557. /**
  83558. * Initializes a webVR display and starts listening to display change events
  83559. * The onVRDisplayChangedObservable will be notified upon these changes
  83560. * @returns A promise containing a VRDisplay and if vr is supported
  83561. */
  83562. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83563. /**
  83564. * Call this function to switch to webVR mode
  83565. * Will do nothing if webVR is not supported or if there is no webVR device
  83566. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83567. */
  83568. enableVR(): void;
  83569. /**
  83570. * Call this function to leave webVR mode
  83571. * Will do nothing if webVR is not supported or if there is no webVR device
  83572. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83573. */
  83574. disableVR(): void;
  83575. private _onVRFullScreenTriggered;
  83576. private _getVRDisplaysAsync;
  83577. /**
  83578. * Binds the frame buffer to the specified texture.
  83579. * @param texture The texture to render to or null for the default canvas
  83580. * @param faceIndex The face of the texture to render to in case of cube texture
  83581. * @param requiredWidth The width of the target to render to
  83582. * @param requiredHeight The height of the target to render to
  83583. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83584. * @param depthStencilTexture The depth stencil texture to use to render
  83585. * @param lodLevel defines le lod level to bind to the frame buffer
  83586. */
  83587. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83588. private bindUnboundFramebuffer;
  83589. /**
  83590. * Unbind the current render target texture from the webGL context
  83591. * @param texture defines the render target texture to unbind
  83592. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83593. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83594. */
  83595. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83596. /**
  83597. * Unbind a list of render target textures from the webGL context
  83598. * This is used only when drawBuffer extension or webGL2 are active
  83599. * @param textures defines the render target textures to unbind
  83600. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83601. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83602. */
  83603. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83604. /**
  83605. * Force the mipmap generation for the given render target texture
  83606. * @param texture defines the render target texture to use
  83607. */
  83608. generateMipMapsForCubemap(texture: InternalTexture): void;
  83609. /**
  83610. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83611. */
  83612. flushFramebuffer(): void;
  83613. /**
  83614. * Unbind the current render target and bind the default framebuffer
  83615. */
  83616. restoreDefaultFramebuffer(): void;
  83617. /**
  83618. * Create an uniform buffer
  83619. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83620. * @param elements defines the content of the uniform buffer
  83621. * @returns the webGL uniform buffer
  83622. */
  83623. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83624. /**
  83625. * Create a dynamic uniform buffer
  83626. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83627. * @param elements defines the content of the uniform buffer
  83628. * @returns the webGL uniform buffer
  83629. */
  83630. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83631. /**
  83632. * Update an existing uniform buffer
  83633. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83634. * @param uniformBuffer defines the target uniform buffer
  83635. * @param elements defines the content to update
  83636. * @param offset defines the offset in the uniform buffer where update should start
  83637. * @param count defines the size of the data to update
  83638. */
  83639. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83640. private _resetVertexBufferBinding;
  83641. /**
  83642. * Creates a vertex buffer
  83643. * @param data the data for the vertex buffer
  83644. * @returns the new WebGL static buffer
  83645. */
  83646. createVertexBuffer(data: DataArray): WebGLBuffer;
  83647. /**
  83648. * Creates a dynamic vertex buffer
  83649. * @param data the data for the dynamic vertex buffer
  83650. * @returns the new WebGL dynamic buffer
  83651. */
  83652. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83653. /**
  83654. * Update a dynamic index buffer
  83655. * @param indexBuffer defines the target index buffer
  83656. * @param indices defines the data to update
  83657. * @param offset defines the offset in the target index buffer where update should start
  83658. */
  83659. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83660. /**
  83661. * Updates a dynamic vertex buffer.
  83662. * @param vertexBuffer the vertex buffer to update
  83663. * @param data the data used to update the vertex buffer
  83664. * @param byteOffset the byte offset of the data
  83665. * @param byteLength the byte length of the data
  83666. */
  83667. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83668. private _resetIndexBufferBinding;
  83669. /**
  83670. * Creates a new index buffer
  83671. * @param indices defines the content of the index buffer
  83672. * @param updatable defines if the index buffer must be updatable
  83673. * @returns a new webGL buffer
  83674. */
  83675. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83676. /**
  83677. * Bind a webGL buffer to the webGL context
  83678. * @param buffer defines the buffer to bind
  83679. */
  83680. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83681. /**
  83682. * Bind an uniform buffer to the current webGL context
  83683. * @param buffer defines the buffer to bind
  83684. */
  83685. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83686. /**
  83687. * Bind a buffer to the current webGL context at a given location
  83688. * @param buffer defines the buffer to bind
  83689. * @param location defines the index where to bind the buffer
  83690. */
  83691. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83692. /**
  83693. * Bind a specific block at a given index in a specific shader program
  83694. * @param shaderProgram defines the shader program
  83695. * @param blockName defines the block name
  83696. * @param index defines the index where to bind the block
  83697. */
  83698. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83699. private bindIndexBuffer;
  83700. private bindBuffer;
  83701. /**
  83702. * update the bound buffer with the given data
  83703. * @param data defines the data to update
  83704. */
  83705. updateArrayBuffer(data: Float32Array): void;
  83706. private _vertexAttribPointer;
  83707. private _bindIndexBufferWithCache;
  83708. private _bindVertexBuffersAttributes;
  83709. /**
  83710. * Records a vertex array object
  83711. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83712. * @param vertexBuffers defines the list of vertex buffers to store
  83713. * @param indexBuffer defines the index buffer to store
  83714. * @param effect defines the effect to store
  83715. * @returns the new vertex array object
  83716. */
  83717. recordVertexArrayObject(vertexBuffers: {
  83718. [key: string]: VertexBuffer;
  83719. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  83720. /**
  83721. * Bind a specific vertex array object
  83722. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83723. * @param vertexArrayObject defines the vertex array object to bind
  83724. * @param indexBuffer defines the index buffer to bind
  83725. */
  83726. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  83727. /**
  83728. * Bind webGl buffers directly to the webGL context
  83729. * @param vertexBuffer defines the vertex buffer to bind
  83730. * @param indexBuffer defines the index buffer to bind
  83731. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  83732. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  83733. * @param effect defines the effect associated with the vertex buffer
  83734. */
  83735. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  83736. private _unbindVertexArrayObject;
  83737. /**
  83738. * Bind a list of vertex buffers to the webGL context
  83739. * @param vertexBuffers defines the list of vertex buffers to bind
  83740. * @param indexBuffer defines the index buffer to bind
  83741. * @param effect defines the effect associated with the vertex buffers
  83742. */
  83743. bindBuffers(vertexBuffers: {
  83744. [key: string]: Nullable<VertexBuffer>;
  83745. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  83746. /**
  83747. * Unbind all instance attributes
  83748. */
  83749. unbindInstanceAttributes(): void;
  83750. /**
  83751. * Release and free the memory of a vertex array object
  83752. * @param vao defines the vertex array object to delete
  83753. */
  83754. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  83755. /** @hidden */
  83756. _releaseBuffer(buffer: WebGLBuffer): boolean;
  83757. /**
  83758. * Creates a webGL buffer to use with instanciation
  83759. * @param capacity defines the size of the buffer
  83760. * @returns the webGL buffer
  83761. */
  83762. createInstancesBuffer(capacity: number): WebGLBuffer;
  83763. /**
  83764. * Delete a webGL buffer used with instanciation
  83765. * @param buffer defines the webGL buffer to delete
  83766. */
  83767. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  83768. /**
  83769. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  83770. * @param instancesBuffer defines the webGL buffer to update and bind
  83771. * @param data defines the data to store in the buffer
  83772. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  83773. */
  83774. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  83775. /**
  83776. * Apply all cached states (depth, culling, stencil and alpha)
  83777. */
  83778. applyStates(): void;
  83779. /**
  83780. * Send a draw order
  83781. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83782. * @param indexStart defines the starting index
  83783. * @param indexCount defines the number of index to draw
  83784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83785. */
  83786. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  83787. /**
  83788. * Draw a list of points
  83789. * @param verticesStart defines the index of first vertex to draw
  83790. * @param verticesCount defines the count of vertices to draw
  83791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83792. */
  83793. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83794. /**
  83795. * Draw a list of unindexed primitives
  83796. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83797. * @param verticesStart defines the index of first vertex to draw
  83798. * @param verticesCount defines the count of vertices to draw
  83799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83800. */
  83801. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83802. /**
  83803. * Draw a list of indexed primitives
  83804. * @param fillMode defines the primitive to use
  83805. * @param indexStart defines the starting index
  83806. * @param indexCount defines the number of index to draw
  83807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83808. */
  83809. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  83810. /**
  83811. * Draw a list of unindexed primitives
  83812. * @param fillMode defines the primitive to use
  83813. * @param verticesStart defines the index of first vertex to draw
  83814. * @param verticesCount defines the count of vertices to draw
  83815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83816. */
  83817. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83818. private _drawMode;
  83819. /** @hidden */
  83820. _releaseEffect(effect: Effect): void;
  83821. /** @hidden */
  83822. _deleteProgram(program: WebGLProgram): void;
  83823. /**
  83824. * Create a new effect (used to store vertex/fragment shaders)
  83825. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  83826. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  83827. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  83828. * @param samplers defines an array of string used to represent textures
  83829. * @param defines defines the string containing the defines to use to compile the shaders
  83830. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  83831. * @param onCompiled defines a function to call when the effect creation is successful
  83832. * @param onError defines a function to call when the effect creation has failed
  83833. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  83834. * @returns the new Effect
  83835. */
  83836. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  83837. private _compileShader;
  83838. private _compileRawShader;
  83839. /**
  83840. * Directly creates a webGL program
  83841. * @param vertexCode defines the vertex shader code to use
  83842. * @param fragmentCode defines the fragment shader code to use
  83843. * @param context defines the webGL context to use (if not set, the current one will be used)
  83844. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83845. * @returns the new webGL program
  83846. */
  83847. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83848. /**
  83849. * Creates a webGL program
  83850. * @param vertexCode defines the vertex shader code to use
  83851. * @param fragmentCode defines the fragment shader code to use
  83852. * @param defines defines the string containing the defines to use to compile the shaders
  83853. * @param context defines the webGL context to use (if not set, the current one will be used)
  83854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83855. * @returns the new webGL program
  83856. */
  83857. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83858. private _createShaderProgram;
  83859. private _finalizeProgram;
  83860. /** @hidden */
  83861. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  83862. /** @hidden */
  83863. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  83864. /**
  83865. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  83866. * @param shaderProgram defines the webGL program to use
  83867. * @param uniformsNames defines the list of uniform names
  83868. * @returns an array of webGL uniform locations
  83869. */
  83870. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  83871. /**
  83872. * Gets the lsit of active attributes for a given webGL program
  83873. * @param shaderProgram defines the webGL program to use
  83874. * @param attributesNames defines the list of attribute names to get
  83875. * @returns an array of indices indicating the offset of each attribute
  83876. */
  83877. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  83878. /**
  83879. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  83880. * @param effect defines the effect to activate
  83881. */
  83882. enableEffect(effect: Nullable<Effect>): void;
  83883. /**
  83884. * Set the value of an uniform to an array of int32
  83885. * @param uniform defines the webGL uniform location where to store the value
  83886. * @param array defines the array of int32 to store
  83887. */
  83888. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83889. /**
  83890. * Set the value of an uniform to an array of int32 (stored as vec2)
  83891. * @param uniform defines the webGL uniform location where to store the value
  83892. * @param array defines the array of int32 to store
  83893. */
  83894. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83895. /**
  83896. * Set the value of an uniform to an array of int32 (stored as vec3)
  83897. * @param uniform defines the webGL uniform location where to store the value
  83898. * @param array defines the array of int32 to store
  83899. */
  83900. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83901. /**
  83902. * Set the value of an uniform to an array of int32 (stored as vec4)
  83903. * @param uniform defines the webGL uniform location where to store the value
  83904. * @param array defines the array of int32 to store
  83905. */
  83906. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83907. /**
  83908. * Set the value of an uniform to an array of float32
  83909. * @param uniform defines the webGL uniform location where to store the value
  83910. * @param array defines the array of float32 to store
  83911. */
  83912. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83913. /**
  83914. * Set the value of an uniform to an array of float32 (stored as vec2)
  83915. * @param uniform defines the webGL uniform location where to store the value
  83916. * @param array defines the array of float32 to store
  83917. */
  83918. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83919. /**
  83920. * Set the value of an uniform to an array of float32 (stored as vec3)
  83921. * @param uniform defines the webGL uniform location where to store the value
  83922. * @param array defines the array of float32 to store
  83923. */
  83924. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83925. /**
  83926. * Set the value of an uniform to an array of float32 (stored as vec4)
  83927. * @param uniform defines the webGL uniform location where to store the value
  83928. * @param array defines the array of float32 to store
  83929. */
  83930. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83931. /**
  83932. * Set the value of an uniform to an array of number
  83933. * @param uniform defines the webGL uniform location where to store the value
  83934. * @param array defines the array of number to store
  83935. */
  83936. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83937. /**
  83938. * Set the value of an uniform to an array of number (stored as vec2)
  83939. * @param uniform defines the webGL uniform location where to store the value
  83940. * @param array defines the array of number to store
  83941. */
  83942. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83943. /**
  83944. * Set the value of an uniform to an array of number (stored as vec3)
  83945. * @param uniform defines the webGL uniform location where to store the value
  83946. * @param array defines the array of number to store
  83947. */
  83948. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83949. /**
  83950. * Set the value of an uniform to an array of number (stored as vec4)
  83951. * @param uniform defines the webGL uniform location where to store the value
  83952. * @param array defines the array of number to store
  83953. */
  83954. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83955. /**
  83956. * Set the value of an uniform to an array of float32 (stored as matrices)
  83957. * @param uniform defines the webGL uniform location where to store the value
  83958. * @param matrices defines the array of float32 to store
  83959. */
  83960. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  83961. /**
  83962. * Set the value of an uniform to a matrix
  83963. * @param uniform defines the webGL uniform location where to store the value
  83964. * @param matrix defines the matrix to store
  83965. */
  83966. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  83967. /**
  83968. * Set the value of an uniform to a matrix (3x3)
  83969. * @param uniform defines the webGL uniform location where to store the value
  83970. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  83971. */
  83972. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83973. /**
  83974. * Set the value of an uniform to a matrix (2x2)
  83975. * @param uniform defines the webGL uniform location where to store the value
  83976. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  83977. */
  83978. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83979. /**
  83980. * Set the value of an uniform to a number (int)
  83981. * @param uniform defines the webGL uniform location where to store the value
  83982. * @param value defines the int number to store
  83983. */
  83984. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83985. /**
  83986. * Set the value of an uniform to a number (float)
  83987. * @param uniform defines the webGL uniform location where to store the value
  83988. * @param value defines the float number to store
  83989. */
  83990. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83991. /**
  83992. * Set the value of an uniform to a vec2
  83993. * @param uniform defines the webGL uniform location where to store the value
  83994. * @param x defines the 1st component of the value
  83995. * @param y defines the 2nd component of the value
  83996. */
  83997. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  83998. /**
  83999. * Set the value of an uniform to a vec3
  84000. * @param uniform defines the webGL uniform location where to store the value
  84001. * @param x defines the 1st component of the value
  84002. * @param y defines the 2nd component of the value
  84003. * @param z defines the 3rd component of the value
  84004. */
  84005. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84006. /**
  84007. * Set the value of an uniform to a boolean
  84008. * @param uniform defines the webGL uniform location where to store the value
  84009. * @param bool defines the boolean to store
  84010. */
  84011. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84012. /**
  84013. * Set the value of an uniform to a vec4
  84014. * @param uniform defines the webGL uniform location where to store the value
  84015. * @param x defines the 1st component of the value
  84016. * @param y defines the 2nd component of the value
  84017. * @param z defines the 3rd component of the value
  84018. * @param w defines the 4th component of the value
  84019. */
  84020. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84021. /**
  84022. * Set the value of an uniform to a Color3
  84023. * @param uniform defines the webGL uniform location where to store the value
  84024. * @param color3 defines the color to store
  84025. */
  84026. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84027. /**
  84028. * Set the value of an uniform to a Color3 and an alpha value
  84029. * @param uniform defines the webGL uniform location where to store the value
  84030. * @param color3 defines the color to store
  84031. * @param alpha defines the alpha component to store
  84032. */
  84033. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84034. /**
  84035. * Sets a Color4 on a uniform variable
  84036. * @param uniform defines the uniform location
  84037. * @param color4 defines the value to be set
  84038. */
  84039. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84040. /**
  84041. * Set various states to the webGL context
  84042. * @param culling defines backface culling state
  84043. * @param zOffset defines the value to apply to zOffset (0 by default)
  84044. * @param force defines if states must be applied even if cache is up to date
  84045. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84046. */
  84047. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84048. /**
  84049. * Set the z offset to apply to current rendering
  84050. * @param value defines the offset to apply
  84051. */
  84052. setZOffset(value: number): void;
  84053. /**
  84054. * Gets the current value of the zOffset
  84055. * @returns the current zOffset state
  84056. */
  84057. getZOffset(): number;
  84058. /**
  84059. * Enable or disable depth buffering
  84060. * @param enable defines the state to set
  84061. */
  84062. setDepthBuffer(enable: boolean): void;
  84063. /**
  84064. * Gets a boolean indicating if depth writing is enabled
  84065. * @returns the current depth writing state
  84066. */
  84067. getDepthWrite(): boolean;
  84068. /**
  84069. * Enable or disable depth writing
  84070. * @param enable defines the state to set
  84071. */
  84072. setDepthWrite(enable: boolean): void;
  84073. /**
  84074. * Enable or disable color writing
  84075. * @param enable defines the state to set
  84076. */
  84077. setColorWrite(enable: boolean): void;
  84078. /**
  84079. * Gets a boolean indicating if color writing is enabled
  84080. * @returns the current color writing state
  84081. */
  84082. getColorWrite(): boolean;
  84083. /**
  84084. * Sets alpha constants used by some alpha blending modes
  84085. * @param r defines the red component
  84086. * @param g defines the green component
  84087. * @param b defines the blue component
  84088. * @param a defines the alpha component
  84089. */
  84090. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84091. /**
  84092. * Sets the current alpha mode
  84093. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84094. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84096. */
  84097. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84098. /**
  84099. * Gets the current alpha mode
  84100. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84101. * @returns the current alpha mode
  84102. */
  84103. getAlphaMode(): number;
  84104. /**
  84105. * Clears the list of texture accessible through engine.
  84106. * This can help preventing texture load conflict due to name collision.
  84107. */
  84108. clearInternalTexturesCache(): void;
  84109. /**
  84110. * Force the entire cache to be cleared
  84111. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84112. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84113. */
  84114. wipeCaches(bruteForce?: boolean): void;
  84115. /**
  84116. * Set the compressed texture format to use, based on the formats you have, and the formats
  84117. * supported by the hardware / browser.
  84118. *
  84119. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84120. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84121. * to API arguments needed to compressed textures. This puts the burden on the container
  84122. * generator to house the arcane code for determining these for current & future formats.
  84123. *
  84124. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84125. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84126. *
  84127. * Note: The result of this call is not taken into account when a texture is base64.
  84128. *
  84129. * @param formatsAvailable defines the list of those format families you have created
  84130. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84131. *
  84132. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84133. * @returns The extension selected.
  84134. */
  84135. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84136. private _getSamplingParameters;
  84137. private _partialLoadImg;
  84138. private _cascadeLoadImgs;
  84139. /** @hidden */
  84140. _createTexture(): WebGLTexture;
  84141. /**
  84142. * Usually called from Texture.ts.
  84143. * Passed information to create a WebGLTexture
  84144. * @param urlArg defines a value which contains one of the following:
  84145. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84146. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84147. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84148. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84149. * @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)
  84150. * @param scene needed for loading to the correct scene
  84151. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84152. * @param onLoad optional callback to be called upon successful completion
  84153. * @param onError optional callback to be called upon failure
  84154. * @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
  84155. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84156. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84157. * @param forcedExtension defines the extension to use to pick the right loader
  84158. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84159. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84160. */
  84161. 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;
  84162. private _rescaleTexture;
  84163. /**
  84164. * Update a raw texture
  84165. * @param texture defines the texture to update
  84166. * @param data defines the data to store in the texture
  84167. * @param format defines the format of the data
  84168. * @param invertY defines if data must be stored with Y axis inverted
  84169. * @param compression defines the compression used (null by default)
  84170. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84171. */
  84172. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84173. /**
  84174. * Creates a raw texture
  84175. * @param data defines the data to store in the texture
  84176. * @param width defines the width of the texture
  84177. * @param height defines the height of the texture
  84178. * @param format defines the format of the data
  84179. * @param generateMipMaps defines if the engine should generate the mip levels
  84180. * @param invertY defines if data must be stored with Y axis inverted
  84181. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84182. * @param compression defines the compression used (null by default)
  84183. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84184. * @returns the raw texture inside an InternalTexture
  84185. */
  84186. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84187. private _unpackFlipYCached;
  84188. /**
  84189. * In case you are sharing the context with other applications, it might
  84190. * be interested to not cache the unpack flip y state to ensure a consistent
  84191. * value would be set.
  84192. */
  84193. enableUnpackFlipYCached: boolean;
  84194. /** @hidden */
  84195. _unpackFlipY(value: boolean): void;
  84196. /** @hidden */
  84197. _getUnpackAlignement(): number;
  84198. /**
  84199. * Creates a dynamic texture
  84200. * @param width defines the width of the texture
  84201. * @param height defines the height of the texture
  84202. * @param generateMipMaps defines if the engine should generate the mip levels
  84203. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84204. * @returns the dynamic texture inside an InternalTexture
  84205. */
  84206. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84207. /**
  84208. * Update the sampling mode of a given texture
  84209. * @param samplingMode defines the required sampling mode
  84210. * @param texture defines the texture to update
  84211. */
  84212. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84213. /**
  84214. * Update the content of a dynamic texture
  84215. * @param texture defines the texture to update
  84216. * @param canvas defines the canvas containing the source
  84217. * @param invertY defines if data must be stored with Y axis inverted
  84218. * @param premulAlpha defines if alpha is stored as premultiplied
  84219. * @param format defines the format of the data
  84220. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84221. */
  84222. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84223. /**
  84224. * Update a video texture
  84225. * @param texture defines the texture to update
  84226. * @param video defines the video element to use
  84227. * @param invertY defines if data must be stored with Y axis inverted
  84228. */
  84229. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84230. /**
  84231. * Updates a depth texture Comparison Mode and Function.
  84232. * If the comparison Function is equal to 0, the mode will be set to none.
  84233. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84234. * @param texture The texture to set the comparison function for
  84235. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84236. */
  84237. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84238. private _setupDepthStencilTexture;
  84239. /**
  84240. * Creates a depth stencil texture.
  84241. * This is only available in WebGL 2 or with the depth texture extension available.
  84242. * @param size The size of face edge in the texture.
  84243. * @param options The options defining the texture.
  84244. * @returns The texture
  84245. */
  84246. createDepthStencilTexture(size: number | {
  84247. width: number;
  84248. height: number;
  84249. }, options: DepthTextureCreationOptions): InternalTexture;
  84250. /**
  84251. * Creates a depth stencil texture.
  84252. * This is only available in WebGL 2 or with the depth texture extension available.
  84253. * @param size The size of face edge in the texture.
  84254. * @param options The options defining the texture.
  84255. * @returns The texture
  84256. */
  84257. private _createDepthStencilTexture;
  84258. /**
  84259. * Creates a depth stencil cube texture.
  84260. * This is only available in WebGL 2.
  84261. * @param size The size of face edge in the cube texture.
  84262. * @param options The options defining the cube texture.
  84263. * @returns The cube texture
  84264. */
  84265. private _createDepthStencilCubeTexture;
  84266. /**
  84267. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84268. * @param renderTarget The render target to set the frame buffer for
  84269. */
  84270. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84271. /**
  84272. * Creates a new render target texture
  84273. * @param size defines the size of the texture
  84274. * @param options defines the options used to create the texture
  84275. * @returns a new render target texture stored in an InternalTexture
  84276. */
  84277. createRenderTargetTexture(size: number | {
  84278. width: number;
  84279. height: number;
  84280. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84281. /**
  84282. * Create a multi render target texture
  84283. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84284. * @param size defines the size of the texture
  84285. * @param options defines the creation options
  84286. * @returns the cube texture as an InternalTexture
  84287. */
  84288. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84289. private _setupFramebufferDepthAttachments;
  84290. /**
  84291. * Updates the sample count of a render target texture
  84292. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84293. * @param texture defines the texture to update
  84294. * @param samples defines the sample count to set
  84295. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84296. */
  84297. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84298. /**
  84299. * Update the sample count for a given multiple render target texture
  84300. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84301. * @param textures defines the textures to update
  84302. * @param samples defines the sample count to set
  84303. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84304. */
  84305. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84306. /** @hidden */
  84307. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84308. /** @hidden */
  84309. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84310. /** @hidden */
  84311. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84312. /** @hidden */
  84313. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84314. /**
  84315. * Creates a new render target cube texture
  84316. * @param size defines the size of the texture
  84317. * @param options defines the options used to create the texture
  84318. * @returns a new render target cube texture stored in an InternalTexture
  84319. */
  84320. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84321. /**
  84322. * Creates a cube texture
  84323. * @param rootUrl defines the url where the files to load is located
  84324. * @param scene defines the current scene
  84325. * @param files defines the list of files to load (1 per face)
  84326. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84327. * @param onLoad defines an optional callback raised when the texture is loaded
  84328. * @param onError defines an optional callback raised if there is an issue to load the texture
  84329. * @param format defines the format of the data
  84330. * @param forcedExtension defines the extension to use to pick the right loader
  84331. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84332. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84333. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84334. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84335. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84336. * @returns the cube texture as an InternalTexture
  84337. */
  84338. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  84339. /**
  84340. * @hidden
  84341. */
  84342. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84343. /**
  84344. * Update a raw cube texture
  84345. * @param texture defines the texture to udpdate
  84346. * @param data defines the data to store
  84347. * @param format defines the data format
  84348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84349. * @param invertY defines if data must be stored with Y axis inverted
  84350. * @param compression defines the compression used (null by default)
  84351. * @param level defines which level of the texture to update
  84352. */
  84353. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84354. /**
  84355. * Creates a new raw cube texture
  84356. * @param data defines the array of data to use to create each face
  84357. * @param size defines the size of the textures
  84358. * @param format defines the format of the data
  84359. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84360. * @param generateMipMaps defines if the engine should generate the mip levels
  84361. * @param invertY defines if data must be stored with Y axis inverted
  84362. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84363. * @param compression defines the compression used (null by default)
  84364. * @returns the cube texture as an InternalTexture
  84365. */
  84366. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84367. /**
  84368. * Creates a new raw cube texture from a specified url
  84369. * @param url defines the url where the data is located
  84370. * @param scene defines the current scene
  84371. * @param size defines the size of the textures
  84372. * @param format defines the format of the data
  84373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84374. * @param noMipmap defines if the engine should avoid generating the mip levels
  84375. * @param callback defines a callback used to extract texture data from loaded data
  84376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84377. * @param onLoad defines a callback called when texture is loaded
  84378. * @param onError defines a callback called if there is an error
  84379. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84380. * @param invertY defines if data must be stored with Y axis inverted
  84381. * @returns the cube texture as an InternalTexture
  84382. */
  84383. 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;
  84384. /**
  84385. * Update a raw 3D texture
  84386. * @param texture defines the texture to update
  84387. * @param data defines the data to store
  84388. * @param format defines the data format
  84389. * @param invertY defines if data must be stored with Y axis inverted
  84390. * @param compression defines the used compression (can be null)
  84391. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84392. */
  84393. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84394. /**
  84395. * Creates a new raw 3D texture
  84396. * @param data defines the data used to create the texture
  84397. * @param width defines the width of the texture
  84398. * @param height defines the height of the texture
  84399. * @param depth defines the depth of the texture
  84400. * @param format defines the format of the texture
  84401. * @param generateMipMaps defines if the engine must generate mip levels
  84402. * @param invertY defines if data must be stored with Y axis inverted
  84403. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84404. * @param compression defines the compressed used (can be null)
  84405. * @param textureType defines the compressed used (can be null)
  84406. * @returns a new raw 3D texture (stored in an InternalTexture)
  84407. */
  84408. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84409. private _prepareWebGLTextureContinuation;
  84410. private _prepareWebGLTexture;
  84411. private _convertRGBtoRGBATextureData;
  84412. /** @hidden */
  84413. _releaseFramebufferObjects(texture: InternalTexture): void;
  84414. /** @hidden */
  84415. _releaseTexture(texture: InternalTexture): void;
  84416. private setProgram;
  84417. private _boundUniforms;
  84418. /**
  84419. * Binds an effect to the webGL context
  84420. * @param effect defines the effect to bind
  84421. */
  84422. bindSamplers(effect: Effect): void;
  84423. private _moveBoundTextureOnTop;
  84424. private _getCorrectTextureChannel;
  84425. private _linkTrackers;
  84426. private _removeDesignatedSlot;
  84427. private _activateCurrentTexture;
  84428. /** @hidden */
  84429. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84430. /** @hidden */
  84431. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84432. /**
  84433. * Sets a texture to the webGL context from a postprocess
  84434. * @param channel defines the channel to use
  84435. * @param postProcess defines the source postprocess
  84436. */
  84437. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84438. /**
  84439. * Binds the output of the passed in post process to the texture channel specified
  84440. * @param channel The channel the texture should be bound to
  84441. * @param postProcess The post process which's output should be bound
  84442. */
  84443. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84444. /**
  84445. * Unbind all textures from the webGL context
  84446. */
  84447. unbindAllTextures(): void;
  84448. /**
  84449. * Sets a texture to the according uniform.
  84450. * @param channel The texture channel
  84451. * @param uniform The uniform to set
  84452. * @param texture The texture to apply
  84453. */
  84454. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84455. /**
  84456. * Sets a depth stencil texture from a render target to the according uniform.
  84457. * @param channel The texture channel
  84458. * @param uniform The uniform to set
  84459. * @param texture The render target texture containing the depth stencil texture to apply
  84460. */
  84461. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84462. private _bindSamplerUniformToChannel;
  84463. private _getTextureWrapMode;
  84464. private _setTexture;
  84465. /**
  84466. * Sets an array of texture to the webGL context
  84467. * @param channel defines the channel where the texture array must be set
  84468. * @param uniform defines the associated uniform location
  84469. * @param textures defines the array of textures to bind
  84470. */
  84471. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84472. /** @hidden */
  84473. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84474. private _setTextureParameterFloat;
  84475. private _setTextureParameterInteger;
  84476. /**
  84477. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84478. * @param x defines the x coordinate of the rectangle where pixels must be read
  84479. * @param y defines the y coordinate of the rectangle where pixels must be read
  84480. * @param width defines the width of the rectangle where pixels must be read
  84481. * @param height defines the height of the rectangle where pixels must be read
  84482. * @returns a Uint8Array containing RGBA colors
  84483. */
  84484. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84485. /**
  84486. * Add an externaly attached data from its key.
  84487. * This method call will fail and return false, if such key already exists.
  84488. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84489. * @param key the unique key that identifies the data
  84490. * @param data the data object to associate to the key for this Engine instance
  84491. * @return true if no such key were already present and the data was added successfully, false otherwise
  84492. */
  84493. addExternalData<T>(key: string, data: T): boolean;
  84494. /**
  84495. * Get an externaly attached data from its key
  84496. * @param key the unique key that identifies the data
  84497. * @return the associated data, if present (can be null), or undefined if not present
  84498. */
  84499. getExternalData<T>(key: string): T;
  84500. /**
  84501. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84502. * @param key the unique key that identifies the data
  84503. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84504. * @return the associated data, can be null if the factory returned null.
  84505. */
  84506. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84507. /**
  84508. * Remove an externaly attached data from the Engine instance
  84509. * @param key the unique key that identifies the data
  84510. * @return true if the data was successfully removed, false if it doesn't exist
  84511. */
  84512. removeExternalData(key: string): boolean;
  84513. /**
  84514. * Unbind all vertex attributes from the webGL context
  84515. */
  84516. unbindAllAttributes(): void;
  84517. /**
  84518. * 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
  84519. */
  84520. releaseEffects(): void;
  84521. /**
  84522. * Dispose and release all associated resources
  84523. */
  84524. dispose(): void;
  84525. /**
  84526. * Display the loading screen
  84527. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84528. */
  84529. displayLoadingUI(): void;
  84530. /**
  84531. * Hide the loading screen
  84532. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84533. */
  84534. hideLoadingUI(): void;
  84535. /**
  84536. * Gets the current loading screen object
  84537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84538. */
  84539. /**
  84540. * Sets the current loading screen object
  84541. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84542. */
  84543. loadingScreen: ILoadingScreen;
  84544. /**
  84545. * Sets the current loading screen text
  84546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84547. */
  84548. loadingUIText: string;
  84549. /**
  84550. * Sets the current loading screen background color
  84551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84552. */
  84553. loadingUIBackgroundColor: string;
  84554. /**
  84555. * Attach a new callback raised when context lost event is fired
  84556. * @param callback defines the callback to call
  84557. */
  84558. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84559. /**
  84560. * Attach a new callback raised when context restored event is fired
  84561. * @param callback defines the callback to call
  84562. */
  84563. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84564. /**
  84565. * Gets the source code of the vertex shader associated with a specific webGL program
  84566. * @param program defines the program to use
  84567. * @returns a string containing the source code of the vertex shader associated with the program
  84568. */
  84569. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84570. /**
  84571. * Gets the source code of the fragment shader associated with a specific webGL program
  84572. * @param program defines the program to use
  84573. * @returns a string containing the source code of the fragment shader associated with the program
  84574. */
  84575. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84576. /**
  84577. * Get the current error code of the webGL context
  84578. * @returns the error code
  84579. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84580. */
  84581. getError(): number;
  84582. /**
  84583. * Gets the current framerate
  84584. * @returns a number representing the framerate
  84585. */
  84586. getFps(): number;
  84587. /**
  84588. * Gets the time spent between current and previous frame
  84589. * @returns a number representing the delta time in ms
  84590. */
  84591. getDeltaTime(): number;
  84592. private _measureFps;
  84593. /** @hidden */
  84594. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84595. private _canRenderToFloatFramebuffer;
  84596. private _canRenderToHalfFloatFramebuffer;
  84597. private _canRenderToFramebuffer;
  84598. /** @hidden */
  84599. _getWebGLTextureType(type: number): number;
  84600. private _getInternalFormat;
  84601. /** @hidden */
  84602. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84603. /** @hidden */
  84604. _getRGBAMultiSampleBufferFormat(type: number): number;
  84605. /** @hidden */
  84606. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  84607. /** @hidden */
  84608. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84609. private _partialLoadFile;
  84610. private _cascadeLoadFiles;
  84611. /**
  84612. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84613. * @returns true if the engine can be created
  84614. * @ignorenaming
  84615. */
  84616. static isSupported(): boolean;
  84617. }
  84618. }
  84619. declare module BABYLON {
  84620. /**
  84621. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84622. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84623. */
  84624. export class EffectFallbacks {
  84625. private _defines;
  84626. private _currentRank;
  84627. private _maxRank;
  84628. private _mesh;
  84629. /**
  84630. * Removes the fallback from the bound mesh.
  84631. */
  84632. unBindMesh(): void;
  84633. /**
  84634. * Adds a fallback on the specified property.
  84635. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84636. * @param define The name of the define in the shader
  84637. */
  84638. addFallback(rank: number, define: string): void;
  84639. /**
  84640. * Sets the mesh to use CPU skinning when needing to fallback.
  84641. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84642. * @param mesh The mesh to use the fallbacks.
  84643. */
  84644. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84645. /**
  84646. * Checks to see if more fallbacks are still availible.
  84647. */
  84648. readonly isMoreFallbacks: boolean;
  84649. /**
  84650. * Removes the defines that shoould be removed when falling back.
  84651. * @param currentDefines defines the current define statements for the shader.
  84652. * @param effect defines the current effect we try to compile
  84653. * @returns The resulting defines with defines of the current rank removed.
  84654. */
  84655. reduce(currentDefines: string, effect: Effect): string;
  84656. }
  84657. /**
  84658. * Options to be used when creating an effect.
  84659. */
  84660. export class EffectCreationOptions {
  84661. /**
  84662. * Atrributes that will be used in the shader.
  84663. */
  84664. attributes: string[];
  84665. /**
  84666. * Uniform varible names that will be set in the shader.
  84667. */
  84668. uniformsNames: string[];
  84669. /**
  84670. * Uniform buffer varible names that will be set in the shader.
  84671. */
  84672. uniformBuffersNames: string[];
  84673. /**
  84674. * Sampler texture variable names that will be set in the shader.
  84675. */
  84676. samplers: string[];
  84677. /**
  84678. * Define statements that will be set in the shader.
  84679. */
  84680. defines: any;
  84681. /**
  84682. * Possible fallbacks for this effect to improve performance when needed.
  84683. */
  84684. fallbacks: Nullable<EffectFallbacks>;
  84685. /**
  84686. * Callback that will be called when the shader is compiled.
  84687. */
  84688. onCompiled: Nullable<(effect: Effect) => void>;
  84689. /**
  84690. * Callback that will be called if an error occurs during shader compilation.
  84691. */
  84692. onError: Nullable<(effect: Effect, errors: string) => void>;
  84693. /**
  84694. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84695. */
  84696. indexParameters: any;
  84697. /**
  84698. * Max number of lights that can be used in the shader.
  84699. */
  84700. maxSimultaneousLights: number;
  84701. /**
  84702. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84703. */
  84704. transformFeedbackVaryings: Nullable<string[]>;
  84705. }
  84706. /**
  84707. * Effect containing vertex and fragment shader that can be executed on an object.
  84708. */
  84709. export class Effect {
  84710. /**
  84711. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84712. */
  84713. static ShadersRepository: string;
  84714. /**
  84715. * Name of the effect.
  84716. */
  84717. name: any;
  84718. /**
  84719. * String container all the define statements that should be set on the shader.
  84720. */
  84721. defines: string;
  84722. /**
  84723. * Callback that will be called when the shader is compiled.
  84724. */
  84725. onCompiled: Nullable<(effect: Effect) => void>;
  84726. /**
  84727. * Callback that will be called if an error occurs during shader compilation.
  84728. */
  84729. onError: Nullable<(effect: Effect, errors: string) => void>;
  84730. /**
  84731. * Callback that will be called when effect is bound.
  84732. */
  84733. onBind: Nullable<(effect: Effect) => void>;
  84734. /**
  84735. * Unique ID of the effect.
  84736. */
  84737. uniqueId: number;
  84738. /**
  84739. * Observable that will be called when the shader is compiled.
  84740. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  84741. */
  84742. onCompileObservable: Observable<Effect>;
  84743. /**
  84744. * Observable that will be called if an error occurs during shader compilation.
  84745. */
  84746. onErrorObservable: Observable<Effect>;
  84747. /** @hidden */
  84748. _onBindObservable: Nullable<Observable<Effect>>;
  84749. /**
  84750. * Observable that will be called when effect is bound.
  84751. */
  84752. readonly onBindObservable: Observable<Effect>;
  84753. /** @hidden */
  84754. _bonesComputationForcedToCPU: boolean;
  84755. private static _uniqueIdSeed;
  84756. private _engine;
  84757. private _uniformBuffersNames;
  84758. private _uniformsNames;
  84759. private _samplers;
  84760. private _isReady;
  84761. private _compilationError;
  84762. private _attributesNames;
  84763. private _attributes;
  84764. private _uniforms;
  84765. /**
  84766. * Key for the effect.
  84767. * @hidden
  84768. */
  84769. _key: string;
  84770. private _indexParameters;
  84771. private _fallbacks;
  84772. private _vertexSourceCode;
  84773. private _fragmentSourceCode;
  84774. private _vertexSourceCodeOverride;
  84775. private _fragmentSourceCodeOverride;
  84776. private _transformFeedbackVaryings;
  84777. /**
  84778. * Compiled shader to webGL program.
  84779. * @hidden
  84780. */
  84781. _program: WebGLProgram;
  84782. private _valueCache;
  84783. private static _baseCache;
  84784. /**
  84785. * Instantiates an effect.
  84786. * An effect can be used to create/manage/execute vertex and fragment shaders.
  84787. * @param baseName Name of the effect.
  84788. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  84789. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  84790. * @param samplers List of sampler variables that will be passed to the shader.
  84791. * @param engine Engine to be used to render the effect
  84792. * @param defines Define statements to be added to the shader.
  84793. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  84794. * @param onCompiled Callback that will be called when the shader is compiled.
  84795. * @param onError Callback that will be called if an error occurs during shader compilation.
  84796. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84797. */
  84798. 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);
  84799. /**
  84800. * Unique key for this effect
  84801. */
  84802. readonly key: string;
  84803. /**
  84804. * If the effect has been compiled and prepared.
  84805. * @returns if the effect is compiled and prepared.
  84806. */
  84807. isReady(): boolean;
  84808. /**
  84809. * The engine the effect was initialized with.
  84810. * @returns the engine.
  84811. */
  84812. getEngine(): Engine;
  84813. /**
  84814. * The compiled webGL program for the effect
  84815. * @returns the webGL program.
  84816. */
  84817. getProgram(): WebGLProgram;
  84818. /**
  84819. * The set of names of attribute variables for the shader.
  84820. * @returns An array of attribute names.
  84821. */
  84822. getAttributesNames(): string[];
  84823. /**
  84824. * Returns the attribute at the given index.
  84825. * @param index The index of the attribute.
  84826. * @returns The location of the attribute.
  84827. */
  84828. getAttributeLocation(index: number): number;
  84829. /**
  84830. * Returns the attribute based on the name of the variable.
  84831. * @param name of the attribute to look up.
  84832. * @returns the attribute location.
  84833. */
  84834. getAttributeLocationByName(name: string): number;
  84835. /**
  84836. * The number of attributes.
  84837. * @returns the numnber of attributes.
  84838. */
  84839. getAttributesCount(): number;
  84840. /**
  84841. * Gets the index of a uniform variable.
  84842. * @param uniformName of the uniform to look up.
  84843. * @returns the index.
  84844. */
  84845. getUniformIndex(uniformName: string): number;
  84846. /**
  84847. * Returns the attribute based on the name of the variable.
  84848. * @param uniformName of the uniform to look up.
  84849. * @returns the location of the uniform.
  84850. */
  84851. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  84852. /**
  84853. * Returns an array of sampler variable names
  84854. * @returns The array of sampler variable neames.
  84855. */
  84856. getSamplers(): string[];
  84857. /**
  84858. * The error from the last compilation.
  84859. * @returns the error string.
  84860. */
  84861. getCompilationError(): string;
  84862. /**
  84863. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  84864. * @param func The callback to be used.
  84865. */
  84866. executeWhenCompiled(func: (effect: Effect) => void): void;
  84867. private _checkIsReady;
  84868. /** @hidden */
  84869. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  84870. /** @hidden */
  84871. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  84872. /** @hidden */
  84873. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  84874. private _processShaderConversion;
  84875. private _processIncludes;
  84876. private _processPrecision;
  84877. /**
  84878. * Recompiles the webGL program
  84879. * @param vertexSourceCode The source code for the vertex shader.
  84880. * @param fragmentSourceCode The source code for the fragment shader.
  84881. * @param onCompiled Callback called when completed.
  84882. * @param onError Callback called on error.
  84883. * @hidden
  84884. */
  84885. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  84886. /**
  84887. * Gets the uniform locations of the the specified variable names
  84888. * @param names THe names of the variables to lookup.
  84889. * @returns Array of locations in the same order as variable names.
  84890. */
  84891. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  84892. /**
  84893. * Prepares the effect
  84894. * @hidden
  84895. */
  84896. _prepareEffect(): void;
  84897. /**
  84898. * Checks if the effect is supported. (Must be called after compilation)
  84899. */
  84900. readonly isSupported: boolean;
  84901. /**
  84902. * Binds a texture to the engine to be used as output of the shader.
  84903. * @param channel Name of the output variable.
  84904. * @param texture Texture to bind.
  84905. * @hidden
  84906. */
  84907. _bindTexture(channel: string, texture: InternalTexture): void;
  84908. /**
  84909. * Sets a texture on the engine to be used in the shader.
  84910. * @param channel Name of the sampler variable.
  84911. * @param texture Texture to set.
  84912. */
  84913. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  84914. /**
  84915. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  84916. * @param channel Name of the sampler variable.
  84917. * @param texture Texture to set.
  84918. */
  84919. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  84920. /**
  84921. * Sets an array of textures on the engine to be used in the shader.
  84922. * @param channel Name of the variable.
  84923. * @param textures Textures to set.
  84924. */
  84925. setTextureArray(channel: string, textures: BaseTexture[]): void;
  84926. /**
  84927. * 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)
  84928. * @param channel Name of the sampler variable.
  84929. * @param postProcess Post process to get the input texture from.
  84930. */
  84931. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  84932. /**
  84933. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  84934. * 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)
  84935. * @param channel Name of the sampler variable.
  84936. * @param postProcess Post process to get the output texture from.
  84937. */
  84938. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  84939. /** @hidden */
  84940. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  84941. /** @hidden */
  84942. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  84943. /** @hidden */
  84944. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  84945. /** @hidden */
  84946. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  84947. /**
  84948. * Binds a buffer to a uniform.
  84949. * @param buffer Buffer to bind.
  84950. * @param name Name of the uniform variable to bind to.
  84951. */
  84952. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  84953. /**
  84954. * Binds block to a uniform.
  84955. * @param blockName Name of the block to bind.
  84956. * @param index Index to bind.
  84957. */
  84958. bindUniformBlock(blockName: string, index: number): void;
  84959. /**
  84960. * Sets an interger value on a uniform variable.
  84961. * @param uniformName Name of the variable.
  84962. * @param value Value to be set.
  84963. * @returns this effect.
  84964. */
  84965. setInt(uniformName: string, value: number): Effect;
  84966. /**
  84967. * Sets an int array on a uniform variable.
  84968. * @param uniformName Name of the variable.
  84969. * @param array array to be set.
  84970. * @returns this effect.
  84971. */
  84972. setIntArray(uniformName: string, array: Int32Array): Effect;
  84973. /**
  84974. * 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)
  84975. * @param uniformName Name of the variable.
  84976. * @param array array to be set.
  84977. * @returns this effect.
  84978. */
  84979. setIntArray2(uniformName: string, array: Int32Array): Effect;
  84980. /**
  84981. * 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)
  84982. * @param uniformName Name of the variable.
  84983. * @param array array to be set.
  84984. * @returns this effect.
  84985. */
  84986. setIntArray3(uniformName: string, array: Int32Array): Effect;
  84987. /**
  84988. * 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)
  84989. * @param uniformName Name of the variable.
  84990. * @param array array to be set.
  84991. * @returns this effect.
  84992. */
  84993. setIntArray4(uniformName: string, array: Int32Array): Effect;
  84994. /**
  84995. * Sets an float array on a uniform variable.
  84996. * @param uniformName Name of the variable.
  84997. * @param array array to be set.
  84998. * @returns this effect.
  84999. */
  85000. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85001. /**
  85002. * 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)
  85003. * @param uniformName Name of the variable.
  85004. * @param array array to be set.
  85005. * @returns this effect.
  85006. */
  85007. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85008. /**
  85009. * 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)
  85010. * @param uniformName Name of the variable.
  85011. * @param array array to be set.
  85012. * @returns this effect.
  85013. */
  85014. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85015. /**
  85016. * 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)
  85017. * @param uniformName Name of the variable.
  85018. * @param array array to be set.
  85019. * @returns this effect.
  85020. */
  85021. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85022. /**
  85023. * Sets an array on a uniform variable.
  85024. * @param uniformName Name of the variable.
  85025. * @param array array to be set.
  85026. * @returns this effect.
  85027. */
  85028. setArray(uniformName: string, array: number[]): Effect;
  85029. /**
  85030. * 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)
  85031. * @param uniformName Name of the variable.
  85032. * @param array array to be set.
  85033. * @returns this effect.
  85034. */
  85035. setArray2(uniformName: string, array: number[]): Effect;
  85036. /**
  85037. * 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)
  85038. * @param uniformName Name of the variable.
  85039. * @param array array to be set.
  85040. * @returns this effect.
  85041. */
  85042. setArray3(uniformName: string, array: number[]): Effect;
  85043. /**
  85044. * 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)
  85045. * @param uniformName Name of the variable.
  85046. * @param array array to be set.
  85047. * @returns this effect.
  85048. */
  85049. setArray4(uniformName: string, array: number[]): Effect;
  85050. /**
  85051. * Sets matrices on a uniform variable.
  85052. * @param uniformName Name of the variable.
  85053. * @param matrices matrices to be set.
  85054. * @returns this effect.
  85055. */
  85056. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85057. /**
  85058. * Sets matrix on a uniform variable.
  85059. * @param uniformName Name of the variable.
  85060. * @param matrix matrix to be set.
  85061. * @returns this effect.
  85062. */
  85063. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85064. /**
  85065. * 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)
  85066. * @param uniformName Name of the variable.
  85067. * @param matrix matrix to be set.
  85068. * @returns this effect.
  85069. */
  85070. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85071. /**
  85072. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85073. * @param uniformName Name of the variable.
  85074. * @param matrix matrix to be set.
  85075. * @returns this effect.
  85076. */
  85077. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85078. /**
  85079. * Sets a float on a uniform variable.
  85080. * @param uniformName Name of the variable.
  85081. * @param value value to be set.
  85082. * @returns this effect.
  85083. */
  85084. setFloat(uniformName: string, value: number): Effect;
  85085. /**
  85086. * Sets a boolean on a uniform variable.
  85087. * @param uniformName Name of the variable.
  85088. * @param bool value to be set.
  85089. * @returns this effect.
  85090. */
  85091. setBool(uniformName: string, bool: boolean): Effect;
  85092. /**
  85093. * Sets a Vector2 on a uniform variable.
  85094. * @param uniformName Name of the variable.
  85095. * @param vector2 vector2 to be set.
  85096. * @returns this effect.
  85097. */
  85098. setVector2(uniformName: string, vector2: Vector2): Effect;
  85099. /**
  85100. * Sets a float2 on a uniform variable.
  85101. * @param uniformName Name of the variable.
  85102. * @param x First float in float2.
  85103. * @param y Second float in float2.
  85104. * @returns this effect.
  85105. */
  85106. setFloat2(uniformName: string, x: number, y: number): Effect;
  85107. /**
  85108. * Sets a Vector3 on a uniform variable.
  85109. * @param uniformName Name of the variable.
  85110. * @param vector3 Value to be set.
  85111. * @returns this effect.
  85112. */
  85113. setVector3(uniformName: string, vector3: Vector3): Effect;
  85114. /**
  85115. * Sets a float3 on a uniform variable.
  85116. * @param uniformName Name of the variable.
  85117. * @param x First float in float3.
  85118. * @param y Second float in float3.
  85119. * @param z Third float in float3.
  85120. * @returns this effect.
  85121. */
  85122. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85123. /**
  85124. * Sets a Vector4 on a uniform variable.
  85125. * @param uniformName Name of the variable.
  85126. * @param vector4 Value to be set.
  85127. * @returns this effect.
  85128. */
  85129. setVector4(uniformName: string, vector4: Vector4): Effect;
  85130. /**
  85131. * Sets a float4 on a uniform variable.
  85132. * @param uniformName Name of the variable.
  85133. * @param x First float in float4.
  85134. * @param y Second float in float4.
  85135. * @param z Third float in float4.
  85136. * @param w Fourth float in float4.
  85137. * @returns this effect.
  85138. */
  85139. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85140. /**
  85141. * Sets a Color3 on a uniform variable.
  85142. * @param uniformName Name of the variable.
  85143. * @param color3 Value to be set.
  85144. * @returns this effect.
  85145. */
  85146. setColor3(uniformName: string, color3: Color3): Effect;
  85147. /**
  85148. * Sets a Color4 on a uniform variable.
  85149. * @param uniformName Name of the variable.
  85150. * @param color3 Value to be set.
  85151. * @param alpha Alpha value to be set.
  85152. * @returns this effect.
  85153. */
  85154. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85155. /**
  85156. * Sets a Color4 on a uniform variable
  85157. * @param uniformName defines the name of the variable
  85158. * @param color4 defines the value to be set
  85159. * @returns this effect.
  85160. */
  85161. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85162. /**
  85163. * This function will add a new shader to the shader store
  85164. * @param name the name of the shader
  85165. * @param pixelShader optional pixel shader content
  85166. * @param vertexShader optional vertex shader content
  85167. */
  85168. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85169. /**
  85170. * Store of each shader (The can be looked up using effect.key)
  85171. */
  85172. static ShadersStore: {
  85173. [key: string]: string;
  85174. };
  85175. /**
  85176. * Store of each included file for a shader (The can be looked up using effect.key)
  85177. */
  85178. static IncludesShadersStore: {
  85179. [key: string]: string;
  85180. };
  85181. /**
  85182. * Resets the cache of effects.
  85183. */
  85184. static ResetCache(): void;
  85185. }
  85186. }
  85187. declare module BABYLON {
  85188. /**
  85189. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85190. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85191. * 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;
  85192. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85193. */
  85194. export class ColorCurves {
  85195. private _dirty;
  85196. private _tempColor;
  85197. private _globalCurve;
  85198. private _highlightsCurve;
  85199. private _midtonesCurve;
  85200. private _shadowsCurve;
  85201. private _positiveCurve;
  85202. private _negativeCurve;
  85203. private _globalHue;
  85204. private _globalDensity;
  85205. private _globalSaturation;
  85206. private _globalExposure;
  85207. /**
  85208. * Gets the global Hue value.
  85209. * 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).
  85210. */
  85211. /**
  85212. * Sets the global Hue value.
  85213. * 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).
  85214. */
  85215. globalHue: number;
  85216. /**
  85217. * Gets the global Density value.
  85218. * 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.
  85219. * Values less than zero provide a filter of opposite hue.
  85220. */
  85221. /**
  85222. * Sets the global Density value.
  85223. * 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.
  85224. * Values less than zero provide a filter of opposite hue.
  85225. */
  85226. globalDensity: number;
  85227. /**
  85228. * Gets the global Saturation value.
  85229. * 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.
  85230. */
  85231. /**
  85232. * Sets the global Saturation value.
  85233. * 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.
  85234. */
  85235. globalSaturation: number;
  85236. /**
  85237. * Gets the global Exposure value.
  85238. * 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.
  85239. */
  85240. /**
  85241. * Sets the global Exposure value.
  85242. * 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.
  85243. */
  85244. globalExposure: number;
  85245. private _highlightsHue;
  85246. private _highlightsDensity;
  85247. private _highlightsSaturation;
  85248. private _highlightsExposure;
  85249. /**
  85250. * Gets the highlights Hue value.
  85251. * 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).
  85252. */
  85253. /**
  85254. * Sets the highlights Hue value.
  85255. * 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).
  85256. */
  85257. highlightsHue: number;
  85258. /**
  85259. * Gets the highlights Density value.
  85260. * 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.
  85261. * Values less than zero provide a filter of opposite hue.
  85262. */
  85263. /**
  85264. * Sets the highlights Density value.
  85265. * 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.
  85266. * Values less than zero provide a filter of opposite hue.
  85267. */
  85268. highlightsDensity: number;
  85269. /**
  85270. * Gets the highlights Saturation value.
  85271. * 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.
  85272. */
  85273. /**
  85274. * Sets the highlights Saturation value.
  85275. * 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.
  85276. */
  85277. highlightsSaturation: number;
  85278. /**
  85279. * Gets the highlights Exposure value.
  85280. * 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.
  85281. */
  85282. /**
  85283. * Sets the highlights Exposure value.
  85284. * 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.
  85285. */
  85286. highlightsExposure: number;
  85287. private _midtonesHue;
  85288. private _midtonesDensity;
  85289. private _midtonesSaturation;
  85290. private _midtonesExposure;
  85291. /**
  85292. * Gets the midtones Hue value.
  85293. * 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).
  85294. */
  85295. /**
  85296. * Sets the midtones Hue value.
  85297. * 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).
  85298. */
  85299. midtonesHue: number;
  85300. /**
  85301. * Gets the midtones Density value.
  85302. * 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.
  85303. * Values less than zero provide a filter of opposite hue.
  85304. */
  85305. /**
  85306. * Sets the midtones Density value.
  85307. * 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.
  85308. * Values less than zero provide a filter of opposite hue.
  85309. */
  85310. midtonesDensity: number;
  85311. /**
  85312. * Gets the midtones Saturation value.
  85313. * 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.
  85314. */
  85315. /**
  85316. * Sets the midtones Saturation value.
  85317. * 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.
  85318. */
  85319. midtonesSaturation: number;
  85320. /**
  85321. * Gets the midtones Exposure value.
  85322. * 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.
  85323. */
  85324. /**
  85325. * Sets the midtones Exposure value.
  85326. * 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.
  85327. */
  85328. midtonesExposure: number;
  85329. private _shadowsHue;
  85330. private _shadowsDensity;
  85331. private _shadowsSaturation;
  85332. private _shadowsExposure;
  85333. /**
  85334. * Gets the shadows Hue value.
  85335. * 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).
  85336. */
  85337. /**
  85338. * Sets the shadows Hue value.
  85339. * 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).
  85340. */
  85341. shadowsHue: number;
  85342. /**
  85343. * Gets the shadows Density value.
  85344. * 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.
  85345. * Values less than zero provide a filter of opposite hue.
  85346. */
  85347. /**
  85348. * Sets the shadows Density value.
  85349. * 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.
  85350. * Values less than zero provide a filter of opposite hue.
  85351. */
  85352. shadowsDensity: number;
  85353. /**
  85354. * Gets the shadows Saturation value.
  85355. * 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.
  85356. */
  85357. /**
  85358. * Sets the shadows Saturation value.
  85359. * 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.
  85360. */
  85361. shadowsSaturation: number;
  85362. /**
  85363. * Gets the shadows Exposure value.
  85364. * 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.
  85365. */
  85366. /**
  85367. * Sets the shadows Exposure value.
  85368. * 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.
  85369. */
  85370. shadowsExposure: number;
  85371. /**
  85372. * Returns the class name
  85373. * @returns The class name
  85374. */
  85375. getClassName(): string;
  85376. /**
  85377. * Binds the color curves to the shader.
  85378. * @param colorCurves The color curve to bind
  85379. * @param effect The effect to bind to
  85380. * @param positiveUniform The positive uniform shader parameter
  85381. * @param neutralUniform The neutral uniform shader parameter
  85382. * @param negativeUniform The negative uniform shader parameter
  85383. */
  85384. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85385. /**
  85386. * Prepare the list of uniforms associated with the ColorCurves effects.
  85387. * @param uniformsList The list of uniforms used in the effect
  85388. */
  85389. static PrepareUniforms(uniformsList: string[]): void;
  85390. /**
  85391. * Returns color grading data based on a hue, density, saturation and exposure value.
  85392. * @param filterHue The hue of the color filter.
  85393. * @param filterDensity The density of the color filter.
  85394. * @param saturation The saturation.
  85395. * @param exposure The exposure.
  85396. * @param result The result data container.
  85397. */
  85398. private getColorGradingDataToRef;
  85399. /**
  85400. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85401. * @param value The input slider value in range [-100,100].
  85402. * @returns Adjusted value.
  85403. */
  85404. private static applyColorGradingSliderNonlinear;
  85405. /**
  85406. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85407. * @param hue The hue (H) input.
  85408. * @param saturation The saturation (S) input.
  85409. * @param brightness The brightness (B) input.
  85410. * @result An RGBA color represented as Vector4.
  85411. */
  85412. private static fromHSBToRef;
  85413. /**
  85414. * Returns a value clamped between min and max
  85415. * @param value The value to clamp
  85416. * @param min The minimum of value
  85417. * @param max The maximum of value
  85418. * @returns The clamped value.
  85419. */
  85420. private static clamp;
  85421. /**
  85422. * Clones the current color curve instance.
  85423. * @return The cloned curves
  85424. */
  85425. clone(): ColorCurves;
  85426. /**
  85427. * Serializes the current color curve instance to a json representation.
  85428. * @return a JSON representation
  85429. */
  85430. serialize(): any;
  85431. /**
  85432. * Parses the color curve from a json representation.
  85433. * @param source the JSON source to parse
  85434. * @return The parsed curves
  85435. */
  85436. static Parse(source: any): ColorCurves;
  85437. }
  85438. }
  85439. declare module BABYLON {
  85440. /**
  85441. * Interface to follow in your material defines to integrate easily the
  85442. * Image proccessing functions.
  85443. * @hidden
  85444. */
  85445. export interface IImageProcessingConfigurationDefines {
  85446. IMAGEPROCESSING: boolean;
  85447. VIGNETTE: boolean;
  85448. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85449. VIGNETTEBLENDMODEOPAQUE: boolean;
  85450. TONEMAPPING: boolean;
  85451. TONEMAPPING_ACES: boolean;
  85452. CONTRAST: boolean;
  85453. EXPOSURE: boolean;
  85454. COLORCURVES: boolean;
  85455. COLORGRADING: boolean;
  85456. COLORGRADING3D: boolean;
  85457. SAMPLER3DGREENDEPTH: boolean;
  85458. SAMPLER3DBGRMAP: boolean;
  85459. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85460. }
  85461. /**
  85462. * @hidden
  85463. */
  85464. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85465. IMAGEPROCESSING: boolean;
  85466. VIGNETTE: boolean;
  85467. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85468. VIGNETTEBLENDMODEOPAQUE: boolean;
  85469. TONEMAPPING: boolean;
  85470. TONEMAPPING_ACES: boolean;
  85471. CONTRAST: boolean;
  85472. COLORCURVES: boolean;
  85473. COLORGRADING: boolean;
  85474. COLORGRADING3D: boolean;
  85475. SAMPLER3DGREENDEPTH: boolean;
  85476. SAMPLER3DBGRMAP: boolean;
  85477. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85478. EXPOSURE: boolean;
  85479. constructor();
  85480. }
  85481. /**
  85482. * This groups together the common properties used for image processing either in direct forward pass
  85483. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85484. * or not.
  85485. */
  85486. export class ImageProcessingConfiguration {
  85487. /**
  85488. * Default tone mapping applied in BabylonJS.
  85489. */
  85490. static readonly TONEMAPPING_STANDARD: number;
  85491. /**
  85492. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85493. * to other engines rendering to increase portability.
  85494. */
  85495. static readonly TONEMAPPING_ACES: number;
  85496. /**
  85497. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85498. */
  85499. colorCurves: Nullable<ColorCurves>;
  85500. private _colorCurvesEnabled;
  85501. /**
  85502. * Gets wether the color curves effect is enabled.
  85503. */
  85504. /**
  85505. * Sets wether the color curves effect is enabled.
  85506. */
  85507. colorCurvesEnabled: boolean;
  85508. private _colorGradingTexture;
  85509. /**
  85510. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85511. */
  85512. /**
  85513. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85514. */
  85515. colorGradingTexture: Nullable<BaseTexture>;
  85516. private _colorGradingEnabled;
  85517. /**
  85518. * Gets wether the color grading effect is enabled.
  85519. */
  85520. /**
  85521. * Sets wether the color grading effect is enabled.
  85522. */
  85523. colorGradingEnabled: boolean;
  85524. private _colorGradingWithGreenDepth;
  85525. /**
  85526. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85527. */
  85528. /**
  85529. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85530. */
  85531. colorGradingWithGreenDepth: boolean;
  85532. private _colorGradingBGR;
  85533. /**
  85534. * Gets wether the color grading texture contains BGR values.
  85535. */
  85536. /**
  85537. * Sets wether the color grading texture contains BGR values.
  85538. */
  85539. colorGradingBGR: boolean;
  85540. /** @hidden */
  85541. _exposure: number;
  85542. /**
  85543. * Gets the Exposure used in the effect.
  85544. */
  85545. /**
  85546. * Sets the Exposure used in the effect.
  85547. */
  85548. exposure: number;
  85549. private _toneMappingEnabled;
  85550. /**
  85551. * Gets wether the tone mapping effect is enabled.
  85552. */
  85553. /**
  85554. * Sets wether the tone mapping effect is enabled.
  85555. */
  85556. toneMappingEnabled: boolean;
  85557. private _toneMappingType;
  85558. /**
  85559. * Gets the type of tone mapping effect.
  85560. */
  85561. /**
  85562. * Sets the type of tone mapping effect used in BabylonJS.
  85563. */
  85564. toneMappingType: number;
  85565. protected _contrast: number;
  85566. /**
  85567. * Gets the contrast used in the effect.
  85568. */
  85569. /**
  85570. * Sets the contrast used in the effect.
  85571. */
  85572. contrast: number;
  85573. /**
  85574. * Vignette stretch size.
  85575. */
  85576. vignetteStretch: number;
  85577. /**
  85578. * Vignette centre X Offset.
  85579. */
  85580. vignetteCentreX: number;
  85581. /**
  85582. * Vignette centre Y Offset.
  85583. */
  85584. vignetteCentreY: number;
  85585. /**
  85586. * Vignette weight or intensity of the vignette effect.
  85587. */
  85588. vignetteWeight: number;
  85589. /**
  85590. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85591. * if vignetteEnabled is set to true.
  85592. */
  85593. vignetteColor: Color4;
  85594. /**
  85595. * Camera field of view used by the Vignette effect.
  85596. */
  85597. vignetteCameraFov: number;
  85598. private _vignetteBlendMode;
  85599. /**
  85600. * Gets the vignette blend mode allowing different kind of effect.
  85601. */
  85602. /**
  85603. * Sets the vignette blend mode allowing different kind of effect.
  85604. */
  85605. vignetteBlendMode: number;
  85606. private _vignetteEnabled;
  85607. /**
  85608. * Gets wether the vignette effect is enabled.
  85609. */
  85610. /**
  85611. * Sets wether the vignette effect is enabled.
  85612. */
  85613. vignetteEnabled: boolean;
  85614. private _applyByPostProcess;
  85615. /**
  85616. * Gets wether the image processing is applied through a post process or not.
  85617. */
  85618. /**
  85619. * Sets wether the image processing is applied through a post process or not.
  85620. */
  85621. applyByPostProcess: boolean;
  85622. private _isEnabled;
  85623. /**
  85624. * Gets wether the image processing is enabled or not.
  85625. */
  85626. /**
  85627. * Sets wether the image processing is enabled or not.
  85628. */
  85629. isEnabled: boolean;
  85630. /**
  85631. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85632. */
  85633. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85634. /**
  85635. * Method called each time the image processing information changes requires to recompile the effect.
  85636. */
  85637. protected _updateParameters(): void;
  85638. /**
  85639. * Gets the current class name.
  85640. * @return "ImageProcessingConfiguration"
  85641. */
  85642. getClassName(): string;
  85643. /**
  85644. * Prepare the list of uniforms associated with the Image Processing effects.
  85645. * @param uniforms The list of uniforms used in the effect
  85646. * @param defines the list of defines currently in use
  85647. */
  85648. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85649. /**
  85650. * Prepare the list of samplers associated with the Image Processing effects.
  85651. * @param samplersList The list of uniforms used in the effect
  85652. * @param defines the list of defines currently in use
  85653. */
  85654. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85655. /**
  85656. * Prepare the list of defines associated to the shader.
  85657. * @param defines the list of defines to complete
  85658. * @param forPostProcess Define if we are currently in post process mode or not
  85659. */
  85660. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85661. /**
  85662. * Returns true if all the image processing information are ready.
  85663. * @returns True if ready, otherwise, false
  85664. */
  85665. isReady(): boolean;
  85666. /**
  85667. * Binds the image processing to the shader.
  85668. * @param effect The effect to bind to
  85669. * @param aspectRatio Define the current aspect ratio of the effect
  85670. */
  85671. bind(effect: Effect, aspectRatio?: number): void;
  85672. /**
  85673. * Clones the current image processing instance.
  85674. * @return The cloned image processing
  85675. */
  85676. clone(): ImageProcessingConfiguration;
  85677. /**
  85678. * Serializes the current image processing instance to a json representation.
  85679. * @return a JSON representation
  85680. */
  85681. serialize(): any;
  85682. /**
  85683. * Parses the image processing from a json representation.
  85684. * @param source the JSON source to parse
  85685. * @return The parsed image processing
  85686. */
  85687. static Parse(source: any): ImageProcessingConfiguration;
  85688. private static _VIGNETTEMODE_MULTIPLY;
  85689. private static _VIGNETTEMODE_OPAQUE;
  85690. /**
  85691. * Used to apply the vignette as a mix with the pixel color.
  85692. */
  85693. static readonly VIGNETTEMODE_MULTIPLY: number;
  85694. /**
  85695. * Used to apply the vignette as a replacement of the pixel color.
  85696. */
  85697. static readonly VIGNETTEMODE_OPAQUE: number;
  85698. }
  85699. }
  85700. declare module BABYLON {
  85701. /**
  85702. * This represents all the required information to add a fresnel effect on a material:
  85703. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85704. */
  85705. export class FresnelParameters {
  85706. private _isEnabled;
  85707. /**
  85708. * Define if the fresnel effect is enable or not.
  85709. */
  85710. isEnabled: boolean;
  85711. /**
  85712. * Define the color used on edges (grazing angle)
  85713. */
  85714. leftColor: Color3;
  85715. /**
  85716. * Define the color used on center
  85717. */
  85718. rightColor: Color3;
  85719. /**
  85720. * Define bias applied to computed fresnel term
  85721. */
  85722. bias: number;
  85723. /**
  85724. * Defined the power exponent applied to fresnel term
  85725. */
  85726. power: number;
  85727. /**
  85728. * Clones the current fresnel and its valuues
  85729. * @returns a clone fresnel configuration
  85730. */
  85731. clone(): FresnelParameters;
  85732. /**
  85733. * Serializes the current fresnel parameters to a JSON representation.
  85734. * @return the JSON serialization
  85735. */
  85736. serialize(): any;
  85737. /**
  85738. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  85739. * @param parsedFresnelParameters Define the JSON representation
  85740. * @returns the parsed parameters
  85741. */
  85742. static Parse(parsedFresnelParameters: any): FresnelParameters;
  85743. }
  85744. }
  85745. declare module BABYLON {
  85746. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  85747. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85748. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85749. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85750. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85751. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85752. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85753. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85754. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85755. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85756. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85757. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85758. /**
  85759. * Decorator used to define property that can be serialized as reference to a camera
  85760. * @param sourceName defines the name of the property to decorate
  85761. */
  85762. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85763. /**
  85764. * Class used to help serialization objects
  85765. */
  85766. export class SerializationHelper {
  85767. /** hidden */
  85768. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  85769. /** hidden */
  85770. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  85771. /** hidden */
  85772. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  85773. /** hidden */
  85774. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  85775. /**
  85776. * Appends the serialized animations from the source animations
  85777. * @param source Source containing the animations
  85778. * @param destination Target to store the animations
  85779. */
  85780. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85781. /**
  85782. * Static function used to serialized a specific entity
  85783. * @param entity defines the entity to serialize
  85784. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  85785. * @returns a JSON compatible object representing the serialization of the entity
  85786. */
  85787. static Serialize<T>(entity: T, serializationObject?: any): any;
  85788. /**
  85789. * Creates a new entity from a serialization data object
  85790. * @param creationFunction defines a function used to instanciated the new entity
  85791. * @param source defines the source serialization data
  85792. * @param scene defines the hosting scene
  85793. * @param rootUrl defines the root url for resources
  85794. * @returns a new entity
  85795. */
  85796. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  85797. /**
  85798. * Clones an object
  85799. * @param creationFunction defines the function used to instanciate the new object
  85800. * @param source defines the source object
  85801. * @returns the cloned object
  85802. */
  85803. static Clone<T>(creationFunction: () => T, source: T): T;
  85804. /**
  85805. * Instanciates a new object based on a source one (some data will be shared between both object)
  85806. * @param creationFunction defines the function used to instanciate the new object
  85807. * @param source defines the source object
  85808. * @returns the new object
  85809. */
  85810. static Instanciate<T>(creationFunction: () => T, source: T): T;
  85811. }
  85812. }
  85813. declare module BABYLON {
  85814. /**
  85815. * This is the base class of all the camera used in the application.
  85816. * @see http://doc.babylonjs.com/features/cameras
  85817. */
  85818. export class Camera extends Node {
  85819. /** @hidden */
  85820. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  85821. /**
  85822. * This is the default projection mode used by the cameras.
  85823. * It helps recreating a feeling of perspective and better appreciate depth.
  85824. * This is the best way to simulate real life cameras.
  85825. */
  85826. static readonly PERSPECTIVE_CAMERA: number;
  85827. /**
  85828. * This helps creating camera with an orthographic mode.
  85829. * 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.
  85830. */
  85831. static readonly ORTHOGRAPHIC_CAMERA: number;
  85832. /**
  85833. * This is the default FOV mode for perspective cameras.
  85834. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  85835. */
  85836. static readonly FOVMODE_VERTICAL_FIXED: number;
  85837. /**
  85838. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  85839. */
  85840. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  85841. /**
  85842. * This specifies ther is no need for a camera rig.
  85843. * Basically only one eye is rendered corresponding to the camera.
  85844. */
  85845. static readonly RIG_MODE_NONE: number;
  85846. /**
  85847. * Simulates a camera Rig with one blue eye and one red eye.
  85848. * This can be use with 3d blue and red glasses.
  85849. */
  85850. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  85851. /**
  85852. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  85853. */
  85854. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  85855. /**
  85856. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  85857. */
  85858. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  85859. /**
  85860. * Defines that both eyes of the camera will be rendered over under each other.
  85861. */
  85862. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  85863. /**
  85864. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  85865. */
  85866. static readonly RIG_MODE_VR: number;
  85867. /**
  85868. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  85869. */
  85870. static readonly RIG_MODE_WEBVR: number;
  85871. /**
  85872. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  85873. */
  85874. static readonly RIG_MODE_CUSTOM: number;
  85875. /**
  85876. * Defines if by default attaching controls should prevent the default javascript event to continue.
  85877. */
  85878. static ForceAttachControlToAlwaysPreventDefault: boolean;
  85879. /**
  85880. * @hidden
  85881. * Might be removed once multiview will be a thing
  85882. */
  85883. static UseAlternateWebVRRendering: boolean;
  85884. /**
  85885. * Define the input manager associated with the camera.
  85886. */
  85887. inputs: CameraInputsManager<Camera>;
  85888. /**
  85889. * Define the current local position of the camera in the scene
  85890. */
  85891. position: Vector3;
  85892. /**
  85893. * The vector the camera should consider as up.
  85894. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  85895. */
  85896. upVector: Vector3;
  85897. /**
  85898. * Define the current limit on the left side for an orthographic camera
  85899. * In scene unit
  85900. */
  85901. orthoLeft: Nullable<number>;
  85902. /**
  85903. * Define the current limit on the right side for an orthographic camera
  85904. * In scene unit
  85905. */
  85906. orthoRight: Nullable<number>;
  85907. /**
  85908. * Define the current limit on the bottom side for an orthographic camera
  85909. * In scene unit
  85910. */
  85911. orthoBottom: Nullable<number>;
  85912. /**
  85913. * Define the current limit on the top side for an orthographic camera
  85914. * In scene unit
  85915. */
  85916. orthoTop: Nullable<number>;
  85917. /**
  85918. * Field Of View is set in Radians. (default is 0.8)
  85919. */
  85920. fov: number;
  85921. /**
  85922. * Define the minimum distance the camera can see from.
  85923. * This is important to note that the depth buffer are not infinite and the closer it starts
  85924. * the more your scene might encounter depth fighting issue.
  85925. */
  85926. minZ: number;
  85927. /**
  85928. * Define the maximum distance the camera can see to.
  85929. * This is important to note that the depth buffer are not infinite and the further it end
  85930. * the more your scene might encounter depth fighting issue.
  85931. */
  85932. maxZ: number;
  85933. /**
  85934. * Define the default inertia of the camera.
  85935. * This helps giving a smooth feeling to the camera movement.
  85936. */
  85937. inertia: number;
  85938. /**
  85939. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  85940. */
  85941. mode: number;
  85942. /**
  85943. * Define wether the camera is intermediate.
  85944. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  85945. */
  85946. isIntermediate: boolean;
  85947. /**
  85948. * Define the viewport of the camera.
  85949. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  85950. */
  85951. viewport: Viewport;
  85952. /**
  85953. * Restricts the camera to viewing objects with the same layerMask.
  85954. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  85955. */
  85956. layerMask: number;
  85957. /**
  85958. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  85959. */
  85960. fovMode: number;
  85961. /**
  85962. * Rig mode of the camera.
  85963. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  85964. * This is normally controlled byt the camera themselves as internal use.
  85965. */
  85966. cameraRigMode: number;
  85967. /**
  85968. * Defines the distance between both "eyes" in case of a RIG
  85969. */
  85970. interaxialDistance: number;
  85971. /**
  85972. * Defines if stereoscopic rendering is done side by side or over under.
  85973. */
  85974. isStereoscopicSideBySide: boolean;
  85975. /**
  85976. * 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
  85977. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  85978. * else in the scene.
  85979. */
  85980. customRenderTargets: RenderTargetTexture[];
  85981. /**
  85982. * When set, the camera will render to this render target instead of the default canvas
  85983. */
  85984. outputRenderTarget: Nullable<RenderTargetTexture>;
  85985. /**
  85986. * Observable triggered when the camera view matrix has changed.
  85987. */
  85988. onViewMatrixChangedObservable: Observable<Camera>;
  85989. /**
  85990. * Observable triggered when the camera Projection matrix has changed.
  85991. */
  85992. onProjectionMatrixChangedObservable: Observable<Camera>;
  85993. /**
  85994. * Observable triggered when the inputs have been processed.
  85995. */
  85996. onAfterCheckInputsObservable: Observable<Camera>;
  85997. /**
  85998. * Observable triggered when reset has been called and applied to the camera.
  85999. */
  86000. onRestoreStateObservable: Observable<Camera>;
  86001. /** @hidden */
  86002. _cameraRigParams: any;
  86003. /** @hidden */
  86004. _rigCameras: Camera[];
  86005. /** @hidden */
  86006. _rigPostProcess: Nullable<PostProcess>;
  86007. protected _webvrViewMatrix: Matrix;
  86008. /** @hidden */
  86009. _skipRendering: boolean;
  86010. /** @hidden */
  86011. _alternateCamera: Camera;
  86012. /** @hidden */
  86013. _projectionMatrix: Matrix;
  86014. /** @hidden */
  86015. _postProcesses: Nullable<PostProcess>[];
  86016. /** @hidden */
  86017. _activeMeshes: SmartArray<AbstractMesh>;
  86018. protected _globalPosition: Vector3;
  86019. /** hidden */
  86020. _computedViewMatrix: Matrix;
  86021. private _doNotComputeProjectionMatrix;
  86022. private _transformMatrix;
  86023. private _frustumPlanes;
  86024. private _refreshFrustumPlanes;
  86025. private _storedFov;
  86026. private _stateStored;
  86027. /**
  86028. * Instantiates a new camera object.
  86029. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86030. * @see http://doc.babylonjs.com/features/cameras
  86031. * @param name Defines the name of the camera in the scene
  86032. * @param position Defines the position of the camera
  86033. * @param scene Defines the scene the camera belongs too
  86034. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86035. */
  86036. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86037. /**
  86038. * Store current camera state (fov, position, etc..)
  86039. * @returns the camera
  86040. */
  86041. storeState(): Camera;
  86042. /**
  86043. * Restores the camera state values if it has been stored. You must call storeState() first
  86044. */
  86045. protected _restoreStateValues(): boolean;
  86046. /**
  86047. * Restored camera state. You must call storeState() first.
  86048. * @returns true if restored and false otherwise
  86049. */
  86050. restoreState(): boolean;
  86051. /**
  86052. * Gets the class name of the camera.
  86053. * @returns the class name
  86054. */
  86055. getClassName(): string;
  86056. /** @hidden */
  86057. readonly _isCamera: boolean;
  86058. /**
  86059. * Gets a string representation of the camera useful for debug purpose.
  86060. * @param fullDetails Defines that a more verboe level of logging is required
  86061. * @returns the string representation
  86062. */
  86063. toString(fullDetails?: boolean): string;
  86064. /**
  86065. * Gets the current world space position of the camera.
  86066. */
  86067. readonly globalPosition: Vector3;
  86068. /**
  86069. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86070. * @returns the active meshe list
  86071. */
  86072. getActiveMeshes(): SmartArray<AbstractMesh>;
  86073. /**
  86074. * Check wether a mesh is part of the current active mesh list of the camera
  86075. * @param mesh Defines the mesh to check
  86076. * @returns true if active, false otherwise
  86077. */
  86078. isActiveMesh(mesh: Mesh): boolean;
  86079. /**
  86080. * Is this camera ready to be used/rendered
  86081. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86082. * @return true if the camera is ready
  86083. */
  86084. isReady(completeCheck?: boolean): boolean;
  86085. /** @hidden */
  86086. _initCache(): void;
  86087. /** @hidden */
  86088. _updateCache(ignoreParentClass?: boolean): void;
  86089. /** @hidden */
  86090. _isSynchronized(): boolean;
  86091. /** @hidden */
  86092. _isSynchronizedViewMatrix(): boolean;
  86093. /** @hidden */
  86094. _isSynchronizedProjectionMatrix(): boolean;
  86095. /**
  86096. * Attach the input controls to a specific dom element to get the input from.
  86097. * @param element Defines the element the controls should be listened from
  86098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86099. */
  86100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86101. /**
  86102. * Detach the current controls from the specified dom element.
  86103. * @param element Defines the element to stop listening the inputs from
  86104. */
  86105. detachControl(element: HTMLElement): void;
  86106. /**
  86107. * Update the camera state according to the different inputs gathered during the frame.
  86108. */
  86109. update(): void;
  86110. /** @hidden */
  86111. _checkInputs(): void;
  86112. /** @hidden */
  86113. readonly rigCameras: Camera[];
  86114. /**
  86115. * Gets the post process used by the rig cameras
  86116. */
  86117. readonly rigPostProcess: Nullable<PostProcess>;
  86118. /**
  86119. * Internal, gets the first post proces.
  86120. * @returns the first post process to be run on this camera.
  86121. */
  86122. _getFirstPostProcess(): Nullable<PostProcess>;
  86123. private _cascadePostProcessesToRigCams;
  86124. /**
  86125. * Attach a post process to the camera.
  86126. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86127. * @param postProcess The post process to attach to the camera
  86128. * @param insertAt The position of the post process in case several of them are in use in the scene
  86129. * @returns the position the post process has been inserted at
  86130. */
  86131. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86132. /**
  86133. * Detach a post process to the camera.
  86134. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86135. * @param postProcess The post process to detach from the camera
  86136. */
  86137. detachPostProcess(postProcess: PostProcess): void;
  86138. /**
  86139. * Gets the current world matrix of the camera
  86140. */
  86141. getWorldMatrix(): Matrix;
  86142. /** @hidden */
  86143. _getViewMatrix(): Matrix;
  86144. /**
  86145. * Gets the current view matrix of the camera.
  86146. * @param force forces the camera to recompute the matrix without looking at the cached state
  86147. * @returns the view matrix
  86148. */
  86149. getViewMatrix(force?: boolean): Matrix;
  86150. /**
  86151. * Freeze the projection matrix.
  86152. * It will prevent the cache check of the camera projection compute and can speed up perf
  86153. * if no parameter of the camera are meant to change
  86154. * @param projection Defines manually a projection if necessary
  86155. */
  86156. freezeProjectionMatrix(projection?: Matrix): void;
  86157. /**
  86158. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86159. */
  86160. unfreezeProjectionMatrix(): void;
  86161. /**
  86162. * Gets the current projection matrix of the camera.
  86163. * @param force forces the camera to recompute the matrix without looking at the cached state
  86164. * @returns the projection matrix
  86165. */
  86166. getProjectionMatrix(force?: boolean): Matrix;
  86167. /**
  86168. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86169. * @returns a Matrix
  86170. */
  86171. getTransformationMatrix(): Matrix;
  86172. private _updateFrustumPlanes;
  86173. /**
  86174. * Checks if a cullable object (mesh...) is in the camera frustum
  86175. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86176. * @param target The object to check
  86177. * @returns true if the object is in frustum otherwise false
  86178. */
  86179. isInFrustum(target: ICullable): boolean;
  86180. /**
  86181. * Checks if a cullable object (mesh...) is in the camera frustum
  86182. * Unlike isInFrustum this cheks the full bounding box
  86183. * @param target The object to check
  86184. * @returns true if the object is in frustum otherwise false
  86185. */
  86186. isCompletelyInFrustum(target: ICullable): boolean;
  86187. /**
  86188. * Gets a ray in the forward direction from the camera.
  86189. * @param length Defines the length of the ray to create
  86190. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86191. * @param origin Defines the start point of the ray which defaults to the camera position
  86192. * @returns the forward ray
  86193. */
  86194. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86195. /**
  86196. * Releases resources associated with this node.
  86197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86199. */
  86200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86201. /**
  86202. * Gets the left camera of a rig setup in case of Rigged Camera
  86203. */
  86204. readonly leftCamera: Nullable<FreeCamera>;
  86205. /**
  86206. * Gets the right camera of a rig setup in case of Rigged Camera
  86207. */
  86208. readonly rightCamera: Nullable<FreeCamera>;
  86209. /**
  86210. * Gets the left camera target of a rig setup in case of Rigged Camera
  86211. * @returns the target position
  86212. */
  86213. getLeftTarget(): Nullable<Vector3>;
  86214. /**
  86215. * Gets the right camera target of a rig setup in case of Rigged Camera
  86216. * @returns the target position
  86217. */
  86218. getRightTarget(): Nullable<Vector3>;
  86219. /**
  86220. * @hidden
  86221. */
  86222. setCameraRigMode(mode: number, rigParams: any): void;
  86223. /** @hidden */
  86224. static _setStereoscopicRigMode(camera: Camera): void;
  86225. /** @hidden */
  86226. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86227. /** @hidden */
  86228. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86229. /** @hidden */
  86230. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86231. /** @hidden */
  86232. _getVRProjectionMatrix(): Matrix;
  86233. protected _updateCameraRotationMatrix(): void;
  86234. protected _updateWebVRCameraRotationMatrix(): void;
  86235. /**
  86236. * This function MUST be overwritten by the different WebVR cameras available.
  86237. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86238. * @hidden
  86239. */
  86240. _getWebVRProjectionMatrix(): Matrix;
  86241. /**
  86242. * This function MUST be overwritten by the different WebVR cameras available.
  86243. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86244. * @hidden
  86245. */
  86246. _getWebVRViewMatrix(): Matrix;
  86247. /** @hidden */
  86248. setCameraRigParameter(name: string, value: any): void;
  86249. /**
  86250. * needs to be overridden by children so sub has required properties to be copied
  86251. * @hidden
  86252. */
  86253. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86254. /**
  86255. * May need to be overridden by children
  86256. * @hidden
  86257. */
  86258. _updateRigCameras(): void;
  86259. /** @hidden */
  86260. _setupInputs(): void;
  86261. /**
  86262. * Serialiaze the camera setup to a json represention
  86263. * @returns the JSON representation
  86264. */
  86265. serialize(): any;
  86266. /**
  86267. * Clones the current camera.
  86268. * @param name The cloned camera name
  86269. * @returns the cloned camera
  86270. */
  86271. clone(name: string): Camera;
  86272. /**
  86273. * Gets the direction of the camera relative to a given local axis.
  86274. * @param localAxis Defines the reference axis to provide a relative direction.
  86275. * @return the direction
  86276. */
  86277. getDirection(localAxis: Vector3): Vector3;
  86278. /**
  86279. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86280. * @param localAxis Defines the reference axis to provide a relative direction.
  86281. * @param result Defines the vector to store the result in
  86282. */
  86283. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86284. /**
  86285. * Gets a camera constructor for a given camera type
  86286. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86287. * @param name The name of the camera the result will be able to instantiate
  86288. * @param scene The scene the result will construct the camera in
  86289. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86290. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86291. * @returns a factory method to construc the camera
  86292. */
  86293. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86294. /**
  86295. * Compute the world matrix of the camera.
  86296. * @returns the camera workd matrix
  86297. */
  86298. computeWorldMatrix(): Matrix;
  86299. /**
  86300. * Parse a JSON and creates the camera from the parsed information
  86301. * @param parsedCamera The JSON to parse
  86302. * @param scene The scene to instantiate the camera in
  86303. * @returns the newly constructed camera
  86304. */
  86305. static Parse(parsedCamera: any, scene: Scene): Camera;
  86306. }
  86307. }
  86308. declare module BABYLON {
  86309. /**
  86310. * Interface for any object that can request an animation frame
  86311. */
  86312. export interface ICustomAnimationFrameRequester {
  86313. /**
  86314. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86315. */
  86316. renderFunction?: Function;
  86317. /**
  86318. * Called to request the next frame to render to
  86319. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86320. */
  86321. requestAnimationFrame: Function;
  86322. /**
  86323. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86324. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86325. */
  86326. requestID?: number;
  86327. }
  86328. /**
  86329. * Interface containing an array of animations
  86330. */
  86331. export interface IAnimatable {
  86332. /**
  86333. * Array of animations
  86334. */
  86335. animations: Array<Animation>;
  86336. }
  86337. /** Interface used by value gradients (color, factor, ...) */
  86338. export interface IValueGradient {
  86339. /**
  86340. * Gets or sets the gradient value (between 0 and 1)
  86341. */
  86342. gradient: number;
  86343. }
  86344. /** Class used to store color4 gradient */
  86345. export class ColorGradient implements IValueGradient {
  86346. /**
  86347. * Gets or sets the gradient value (between 0 and 1)
  86348. */
  86349. gradient: number;
  86350. /**
  86351. * Gets or sets first associated color
  86352. */
  86353. color1: Color4;
  86354. /**
  86355. * Gets or sets second associated color
  86356. */
  86357. color2?: Color4;
  86358. /**
  86359. * Will get a color picked randomly between color1 and color2.
  86360. * If color2 is undefined then color1 will be used
  86361. * @param result defines the target Color4 to store the result in
  86362. */
  86363. getColorToRef(result: Color4): void;
  86364. }
  86365. /** Class used to store color 3 gradient */
  86366. export class Color3Gradient implements IValueGradient {
  86367. /**
  86368. * Gets or sets the gradient value (between 0 and 1)
  86369. */
  86370. gradient: number;
  86371. /**
  86372. * Gets or sets the associated color
  86373. */
  86374. color: Color3;
  86375. }
  86376. /** Class used to store factor gradient */
  86377. export class FactorGradient implements IValueGradient {
  86378. /**
  86379. * Gets or sets the gradient value (between 0 and 1)
  86380. */
  86381. gradient: number;
  86382. /**
  86383. * Gets or sets first associated factor
  86384. */
  86385. factor1: number;
  86386. /**
  86387. * Gets or sets second associated factor
  86388. */
  86389. factor2?: number;
  86390. /**
  86391. * Will get a number picked randomly between factor1 and factor2.
  86392. * If factor2 is undefined then factor1 will be used
  86393. * @returns the picked number
  86394. */
  86395. getFactor(): number;
  86396. }
  86397. /**
  86398. * @ignore
  86399. * Application error to support additional information when loading a file
  86400. */
  86401. export class LoadFileError extends Error {
  86402. /** defines the optional XHR request */
  86403. request?: XMLHttpRequest | undefined;
  86404. private static _setPrototypeOf;
  86405. /**
  86406. * Creates a new LoadFileError
  86407. * @param message defines the message of the error
  86408. * @param request defines the optional XHR request
  86409. */
  86410. constructor(message: string,
  86411. /** defines the optional XHR request */
  86412. request?: XMLHttpRequest | undefined);
  86413. }
  86414. /**
  86415. * Class used to define a retry strategy when error happens while loading assets
  86416. */
  86417. export class RetryStrategy {
  86418. /**
  86419. * Function used to defines an exponential back off strategy
  86420. * @param maxRetries defines the maximum number of retries (3 by default)
  86421. * @param baseInterval defines the interval between retries
  86422. * @returns the strategy function to use
  86423. */
  86424. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86425. }
  86426. /**
  86427. * File request interface
  86428. */
  86429. export interface IFileRequest {
  86430. /**
  86431. * Raised when the request is complete (success or error).
  86432. */
  86433. onCompleteObservable: Observable<IFileRequest>;
  86434. /**
  86435. * Aborts the request for a file.
  86436. */
  86437. abort: () => void;
  86438. }
  86439. /**
  86440. * Class containing a set of static utilities functions
  86441. */
  86442. export class Tools {
  86443. /**
  86444. * Gets or sets the base URL to use to load assets
  86445. */
  86446. static BaseUrl: string;
  86447. /**
  86448. * Enable/Disable Custom HTTP Request Headers globally.
  86449. * default = false
  86450. * @see CustomRequestHeaders
  86451. */
  86452. static UseCustomRequestHeaders: boolean;
  86453. /**
  86454. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86455. * i.e. when loading files, where the server/service expects an Authorization header.
  86456. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86457. */
  86458. static CustomRequestHeaders: {
  86459. [key: string]: string;
  86460. };
  86461. /**
  86462. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86463. */
  86464. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86465. /**
  86466. * Default behaviour for cors in the application.
  86467. * It can be a string if the expected behavior is identical in the entire app.
  86468. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86469. */
  86470. static CorsBehavior: string | ((url: string | string[]) => string);
  86471. /**
  86472. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86473. * @ignorenaming
  86474. */
  86475. static UseFallbackTexture: boolean;
  86476. /**
  86477. * Use this object to register external classes like custom textures or material
  86478. * to allow the laoders to instantiate them
  86479. */
  86480. static RegisteredExternalClasses: {
  86481. [key: string]: Object;
  86482. };
  86483. /**
  86484. * Texture content used if a texture cannot loaded
  86485. * @ignorenaming
  86486. */
  86487. static fallbackTexture: string;
  86488. /**
  86489. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86490. * @param u defines the coordinate on X axis
  86491. * @param v defines the coordinate on Y axis
  86492. * @param width defines the width of the source data
  86493. * @param height defines the height of the source data
  86494. * @param pixels defines the source byte array
  86495. * @param color defines the output color
  86496. */
  86497. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86498. /**
  86499. * Interpolates between a and b via alpha
  86500. * @param a The lower value (returned when alpha = 0)
  86501. * @param b The upper value (returned when alpha = 1)
  86502. * @param alpha The interpolation-factor
  86503. * @return The mixed value
  86504. */
  86505. static Mix(a: number, b: number, alpha: number): number;
  86506. /**
  86507. * Tries to instantiate a new object from a given class name
  86508. * @param className defines the class name to instantiate
  86509. * @returns the new object or null if the system was not able to do the instantiation
  86510. */
  86511. static Instantiate(className: string): any;
  86512. /**
  86513. * Provides a slice function that will work even on IE
  86514. * @param data defines the array to slice
  86515. * @param start defines the start of the data (optional)
  86516. * @param end defines the end of the data (optional)
  86517. * @returns the new sliced array
  86518. */
  86519. static Slice<T>(data: T, start?: number, end?: number): T;
  86520. /**
  86521. * Polyfill for setImmediate
  86522. * @param action defines the action to execute after the current execution block
  86523. */
  86524. static SetImmediate(action: () => void): void;
  86525. /**
  86526. * Function indicating if a number is an exponent of 2
  86527. * @param value defines the value to test
  86528. * @returns true if the value is an exponent of 2
  86529. */
  86530. static IsExponentOfTwo(value: number): boolean;
  86531. private static _tmpFloatArray;
  86532. /**
  86533. * Returns the nearest 32-bit single precision float representation of a Number
  86534. * @param value A Number. If the parameter is of a different type, it will get converted
  86535. * to a number or to NaN if it cannot be converted
  86536. * @returns number
  86537. */
  86538. static FloatRound(value: number): number;
  86539. /**
  86540. * Find the next highest power of two.
  86541. * @param x Number to start search from.
  86542. * @return Next highest power of two.
  86543. */
  86544. static CeilingPOT(x: number): number;
  86545. /**
  86546. * Find the next lowest power of two.
  86547. * @param x Number to start search from.
  86548. * @return Next lowest power of two.
  86549. */
  86550. static FloorPOT(x: number): number;
  86551. /**
  86552. * Find the nearest power of two.
  86553. * @param x Number to start search from.
  86554. * @return Next nearest power of two.
  86555. */
  86556. static NearestPOT(x: number): number;
  86557. /**
  86558. * Get the closest exponent of two
  86559. * @param value defines the value to approximate
  86560. * @param max defines the maximum value to return
  86561. * @param mode defines how to define the closest value
  86562. * @returns closest exponent of two of the given value
  86563. */
  86564. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86565. /**
  86566. * Extracts the filename from a path
  86567. * @param path defines the path to use
  86568. * @returns the filename
  86569. */
  86570. static GetFilename(path: string): string;
  86571. /**
  86572. * Extracts the "folder" part of a path (everything before the filename).
  86573. * @param uri The URI to extract the info from
  86574. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86575. * @returns The "folder" part of the path
  86576. */
  86577. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86578. /**
  86579. * Extracts text content from a DOM element hierarchy
  86580. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86581. */
  86582. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86583. /**
  86584. * Convert an angle in radians to degrees
  86585. * @param angle defines the angle to convert
  86586. * @returns the angle in degrees
  86587. */
  86588. static ToDegrees(angle: number): number;
  86589. /**
  86590. * Convert an angle in degrees to radians
  86591. * @param angle defines the angle to convert
  86592. * @returns the angle in radians
  86593. */
  86594. static ToRadians(angle: number): number;
  86595. /**
  86596. * Encode a buffer to a base64 string
  86597. * @param buffer defines the buffer to encode
  86598. * @returns the encoded string
  86599. */
  86600. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86601. /**
  86602. * Extracts minimum and maximum values from a list of indexed positions
  86603. * @param positions defines the positions to use
  86604. * @param indices defines the indices to the positions
  86605. * @param indexStart defines the start index
  86606. * @param indexCount defines the end index
  86607. * @param bias defines bias value to add to the result
  86608. * @return minimum and maximum values
  86609. */
  86610. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86611. minimum: Vector3;
  86612. maximum: Vector3;
  86613. };
  86614. /**
  86615. * Extracts minimum and maximum values from a list of positions
  86616. * @param positions defines the positions to use
  86617. * @param start defines the start index in the positions array
  86618. * @param count defines the number of positions to handle
  86619. * @param bias defines bias value to add to the result
  86620. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86621. * @return minimum and maximum values
  86622. */
  86623. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86624. minimum: Vector3;
  86625. maximum: Vector3;
  86626. };
  86627. /**
  86628. * Returns an array if obj is not an array
  86629. * @param obj defines the object to evaluate as an array
  86630. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86631. * @returns either obj directly if obj is an array or a new array containing obj
  86632. */
  86633. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86634. /**
  86635. * Gets the pointer prefix to use
  86636. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86637. */
  86638. static GetPointerPrefix(): string;
  86639. /**
  86640. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86641. * @param func - the function to be called
  86642. * @param requester - the object that will request the next frame. Falls back to window.
  86643. * @returns frame number
  86644. */
  86645. static QueueNewFrame(func: () => void, requester?: any): number;
  86646. /**
  86647. * Ask the browser to promote the current element to fullscreen rendering mode
  86648. * @param element defines the DOM element to promote
  86649. */
  86650. static RequestFullscreen(element: HTMLElement): void;
  86651. /**
  86652. * Asks the browser to exit fullscreen mode
  86653. */
  86654. static ExitFullscreen(): void;
  86655. /**
  86656. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86657. * @param url define the url we are trying
  86658. * @param element define the dom element where to configure the cors policy
  86659. */
  86660. static SetCorsBehavior(url: string | string[], element: {
  86661. crossOrigin: string | null;
  86662. }): void;
  86663. /**
  86664. * Removes unwanted characters from an url
  86665. * @param url defines the url to clean
  86666. * @returns the cleaned url
  86667. */
  86668. static CleanUrl(url: string): string;
  86669. /**
  86670. * Gets or sets a function used to pre-process url before using them to load assets
  86671. */
  86672. static PreprocessUrl: (url: string) => string;
  86673. /**
  86674. * Loads an image as an HTMLImageElement.
  86675. * @param input url string, ArrayBuffer, or Blob to load
  86676. * @param onLoad callback called when the image successfully loads
  86677. * @param onError callback called when the image fails to load
  86678. * @param offlineProvider offline provider for caching
  86679. * @returns the HTMLImageElement of the loaded image
  86680. */
  86681. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86682. /**
  86683. * Loads a file
  86684. * @param url url string, ArrayBuffer, or Blob to load
  86685. * @param onSuccess callback called when the file successfully loads
  86686. * @param onProgress callback called while file is loading (if the server supports this mode)
  86687. * @param offlineProvider defines the offline provider for caching
  86688. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86689. * @param onError callback called when the file fails to load
  86690. * @returns a file request object
  86691. */
  86692. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  86693. /**
  86694. * Load a script (identified by an url). When the url returns, the
  86695. * content of this file is added into a new script element, attached to the DOM (body element)
  86696. * @param scriptUrl defines the url of the script to laod
  86697. * @param onSuccess defines the callback called when the script is loaded
  86698. * @param onError defines the callback to call if an error occurs
  86699. */
  86700. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86701. /**
  86702. * Loads a file from a blob
  86703. * @param fileToLoad defines the blob to use
  86704. * @param callback defines the callback to call when data is loaded
  86705. * @param progressCallback defines the callback to call during loading process
  86706. * @returns a file request object
  86707. */
  86708. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86709. /**
  86710. * Loads a file
  86711. * @param fileToLoad defines the file to load
  86712. * @param callback defines the callback to call when data is loaded
  86713. * @param progressCallBack defines the callback to call during loading process
  86714. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86715. * @returns a file request object
  86716. */
  86717. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  86718. /**
  86719. * Creates a data url from a given string content
  86720. * @param content defines the content to convert
  86721. * @returns the new data url link
  86722. */
  86723. static FileAsURL(content: string): string;
  86724. /**
  86725. * Format the given number to a specific decimal format
  86726. * @param value defines the number to format
  86727. * @param decimals defines the number of decimals to use
  86728. * @returns the formatted string
  86729. */
  86730. static Format(value: number, decimals?: number): string;
  86731. /**
  86732. * Checks if a given vector is inside a specific range
  86733. * @param v defines the vector to test
  86734. * @param min defines the minimum range
  86735. * @param max defines the maximum range
  86736. */
  86737. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  86738. /**
  86739. * Tries to copy an object by duplicating every property
  86740. * @param source defines the source object
  86741. * @param destination defines the target object
  86742. * @param doNotCopyList defines a list of properties to avoid
  86743. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  86744. */
  86745. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  86746. /**
  86747. * Gets a boolean indicating if the given object has no own property
  86748. * @param obj defines the object to test
  86749. * @returns true if object has no own property
  86750. */
  86751. static IsEmpty(obj: any): boolean;
  86752. /**
  86753. * Function used to register events at window level
  86754. * @param events defines the events to register
  86755. */
  86756. static RegisterTopRootEvents(events: {
  86757. name: string;
  86758. handler: Nullable<(e: FocusEvent) => any>;
  86759. }[]): void;
  86760. /**
  86761. * Function used to unregister events from window level
  86762. * @param events defines the events to unregister
  86763. */
  86764. static UnregisterTopRootEvents(events: {
  86765. name: string;
  86766. handler: Nullable<(e: FocusEvent) => any>;
  86767. }[]): void;
  86768. /**
  86769. * Dumps the current bound framebuffer
  86770. * @param width defines the rendering width
  86771. * @param height defines the rendering height
  86772. * @param engine defines the hosting engine
  86773. * @param successCallback defines the callback triggered once the data are available
  86774. * @param mimeType defines the mime type of the result
  86775. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  86776. */
  86777. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86778. /**
  86779. * Converts the canvas data to blob.
  86780. * This acts as a polyfill for browsers not supporting the to blob function.
  86781. * @param canvas Defines the canvas to extract the data from
  86782. * @param successCallback Defines the callback triggered once the data are available
  86783. * @param mimeType Defines the mime type of the result
  86784. */
  86785. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  86786. /**
  86787. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  86788. * @param successCallback defines the callback triggered once the data are available
  86789. * @param mimeType defines the mime type of the result
  86790. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  86791. */
  86792. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86793. /**
  86794. * Downloads a blob in the browser
  86795. * @param blob defines the blob to download
  86796. * @param fileName defines the name of the downloaded file
  86797. */
  86798. static Download(blob: Blob, fileName: string): void;
  86799. /**
  86800. * Captures a screenshot of the current rendering
  86801. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86802. * @param engine defines the rendering engine
  86803. * @param camera defines the source camera
  86804. * @param size This parameter can be set to a single number or to an object with the
  86805. * following (optional) properties: precision, width, height. If a single number is passed,
  86806. * it will be used for both width and height. If an object is passed, the screenshot size
  86807. * will be derived from the parameters. The precision property is a multiplier allowing
  86808. * rendering at a higher or lower resolution
  86809. * @param successCallback defines the callback receives a single parameter which contains the
  86810. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86811. * src parameter of an <img> to display it
  86812. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  86813. * Check your browser for supported MIME types
  86814. */
  86815. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  86816. /**
  86817. * Generates an image screenshot from the specified camera.
  86818. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86819. * @param engine The engine to use for rendering
  86820. * @param camera The camera to use for rendering
  86821. * @param size This parameter can be set to a single number or to an object with the
  86822. * following (optional) properties: precision, width, height. If a single number is passed,
  86823. * it will be used for both width and height. If an object is passed, the screenshot size
  86824. * will be derived from the parameters. The precision property is a multiplier allowing
  86825. * rendering at a higher or lower resolution
  86826. * @param successCallback The callback receives a single parameter which contains the
  86827. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86828. * src parameter of an <img> to display it
  86829. * @param mimeType The MIME type of the screenshot image (default: image/png).
  86830. * Check your browser for supported MIME types
  86831. * @param samples Texture samples (default: 1)
  86832. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  86833. * @param fileName A name for for the downloaded file.
  86834. */
  86835. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  86836. /**
  86837. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86838. * Be aware Math.random() could cause collisions, but:
  86839. * "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"
  86840. * @returns a pseudo random id
  86841. */
  86842. static RandomId(): string;
  86843. /**
  86844. * Test if the given uri is a base64 string
  86845. * @param uri The uri to test
  86846. * @return True if the uri is a base64 string or false otherwise
  86847. */
  86848. static IsBase64(uri: string): boolean;
  86849. /**
  86850. * Decode the given base64 uri.
  86851. * @param uri The uri to decode
  86852. * @return The decoded base64 data.
  86853. */
  86854. static DecodeBase64(uri: string): ArrayBuffer;
  86855. /**
  86856. * No log
  86857. */
  86858. static readonly NoneLogLevel: number;
  86859. /**
  86860. * Only message logs
  86861. */
  86862. static readonly MessageLogLevel: number;
  86863. /**
  86864. * Only warning logs
  86865. */
  86866. static readonly WarningLogLevel: number;
  86867. /**
  86868. * Only error logs
  86869. */
  86870. static readonly ErrorLogLevel: number;
  86871. /**
  86872. * All logs
  86873. */
  86874. static readonly AllLogLevel: number;
  86875. /**
  86876. * Gets a value indicating the number of loading errors
  86877. * @ignorenaming
  86878. */
  86879. static readonly errorsCount: number;
  86880. /**
  86881. * Callback called when a new log is added
  86882. */
  86883. static OnNewCacheEntry: (entry: string) => void;
  86884. /**
  86885. * Log a message to the console
  86886. * @param message defines the message to log
  86887. */
  86888. static Log(message: string): void;
  86889. /**
  86890. * Write a warning message to the console
  86891. * @param message defines the message to log
  86892. */
  86893. static Warn(message: string): void;
  86894. /**
  86895. * Write an error message to the console
  86896. * @param message defines the message to log
  86897. */
  86898. static Error(message: string): void;
  86899. /**
  86900. * Gets current log cache (list of logs)
  86901. */
  86902. static readonly LogCache: string;
  86903. /**
  86904. * Clears the log cache
  86905. */
  86906. static ClearLogCache(): void;
  86907. /**
  86908. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  86909. */
  86910. static LogLevels: number;
  86911. /**
  86912. * Checks if the loaded document was accessed via `file:`-Protocol.
  86913. * @returns boolean
  86914. */
  86915. static IsFileURL(): boolean;
  86916. /**
  86917. * Checks if the window object exists
  86918. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  86919. */
  86920. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  86921. /**
  86922. * No performance log
  86923. */
  86924. static readonly PerformanceNoneLogLevel: number;
  86925. /**
  86926. * Use user marks to log performance
  86927. */
  86928. static readonly PerformanceUserMarkLogLevel: number;
  86929. /**
  86930. * Log performance to the console
  86931. */
  86932. static readonly PerformanceConsoleLogLevel: number;
  86933. private static _performance;
  86934. /**
  86935. * Sets the current performance log level
  86936. */
  86937. static PerformanceLogLevel: number;
  86938. private static _StartPerformanceCounterDisabled;
  86939. private static _EndPerformanceCounterDisabled;
  86940. private static _StartUserMark;
  86941. private static _EndUserMark;
  86942. private static _StartPerformanceConsole;
  86943. private static _EndPerformanceConsole;
  86944. /**
  86945. * Injects the @see CustomRequestHeaders into the given request
  86946. * @param request the request that should be used for injection
  86947. */
  86948. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  86949. /**
  86950. * Starts a performance counter
  86951. */
  86952. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86953. /**
  86954. * Ends a specific performance coutner
  86955. */
  86956. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86957. /**
  86958. * Gets either window.performance.now() if supported or Date.now() else
  86959. */
  86960. static readonly Now: number;
  86961. /**
  86962. * This method will return the name of the class used to create the instance of the given object.
  86963. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  86964. * @param object the object to get the class name from
  86965. * @param isType defines if the object is actually a type
  86966. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  86967. */
  86968. static GetClassName(object: any, isType?: boolean): string;
  86969. /**
  86970. * Gets the first element of an array satisfying a given predicate
  86971. * @param array defines the array to browse
  86972. * @param predicate defines the predicate to use
  86973. * @returns null if not found or the element
  86974. */
  86975. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  86976. /**
  86977. * This method will return the name of the full name of the class, including its owning module (if any).
  86978. * 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).
  86979. * @param object the object to get the class name from
  86980. * @param isType defines if the object is actually a type
  86981. * @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.
  86982. * @ignorenaming
  86983. */
  86984. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  86985. /**
  86986. * Returns a promise that resolves after the given amount of time.
  86987. * @param delay Number of milliseconds to delay
  86988. * @returns Promise that resolves after the given amount of time
  86989. */
  86990. static DelayAsync(delay: number): Promise<void>;
  86991. /**
  86992. * Gets the current gradient from an array of IValueGradient
  86993. * @param ratio defines the current ratio to get
  86994. * @param gradients defines the array of IValueGradient
  86995. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86996. */
  86997. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86998. }
  86999. /**
  87000. * This class is used to track a performance counter which is number based.
  87001. * The user has access to many properties which give statistics of different nature.
  87002. *
  87003. * The implementer can track two kinds of Performance Counter: time and count.
  87004. * 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.
  87005. * 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.
  87006. */
  87007. export class PerfCounter {
  87008. /**
  87009. * Gets or sets a global boolean to turn on and off all the counters
  87010. */
  87011. static Enabled: boolean;
  87012. /**
  87013. * Returns the smallest value ever
  87014. */
  87015. readonly min: number;
  87016. /**
  87017. * Returns the biggest value ever
  87018. */
  87019. readonly max: number;
  87020. /**
  87021. * Returns the average value since the performance counter is running
  87022. */
  87023. readonly average: number;
  87024. /**
  87025. * Returns the average value of the last second the counter was monitored
  87026. */
  87027. readonly lastSecAverage: number;
  87028. /**
  87029. * Returns the current value
  87030. */
  87031. readonly current: number;
  87032. /**
  87033. * Gets the accumulated total
  87034. */
  87035. readonly total: number;
  87036. /**
  87037. * Gets the total value count
  87038. */
  87039. readonly count: number;
  87040. /**
  87041. * Creates a new counter
  87042. */
  87043. constructor();
  87044. /**
  87045. * Call this method to start monitoring a new frame.
  87046. * 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.
  87047. */
  87048. fetchNewFrame(): void;
  87049. /**
  87050. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87051. * @param newCount the count value to add to the monitored count
  87052. * @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.
  87053. */
  87054. addCount(newCount: number, fetchResult: boolean): void;
  87055. /**
  87056. * Start monitoring this performance counter
  87057. */
  87058. beginMonitoring(): void;
  87059. /**
  87060. * Compute the time lapsed since the previous beginMonitoring() call.
  87061. * @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
  87062. */
  87063. endMonitoring(newFrame?: boolean): void;
  87064. private _fetchResult;
  87065. private _startMonitoringTime;
  87066. private _min;
  87067. private _max;
  87068. private _average;
  87069. private _current;
  87070. private _totalValueCount;
  87071. private _totalAccumulated;
  87072. private _lastSecAverage;
  87073. private _lastSecAccumulated;
  87074. private _lastSecTime;
  87075. private _lastSecValueCount;
  87076. }
  87077. /**
  87078. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87079. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87080. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87081. * @param name The name of the class, case should be preserved
  87082. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87083. */
  87084. export function className(name: string, module?: string): (target: Object) => void;
  87085. /**
  87086. * An implementation of a loop for asynchronous functions.
  87087. */
  87088. export class AsyncLoop {
  87089. /**
  87090. * Defines the number of iterations for the loop
  87091. */
  87092. iterations: number;
  87093. /**
  87094. * Defines the current index of the loop.
  87095. */
  87096. index: number;
  87097. private _done;
  87098. private _fn;
  87099. private _successCallback;
  87100. /**
  87101. * Constructor.
  87102. * @param iterations the number of iterations.
  87103. * @param func the function to run each iteration
  87104. * @param successCallback the callback that will be called upon succesful execution
  87105. * @param offset starting offset.
  87106. */
  87107. constructor(
  87108. /**
  87109. * Defines the number of iterations for the loop
  87110. */
  87111. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87112. /**
  87113. * Execute the next iteration. Must be called after the last iteration was finished.
  87114. */
  87115. executeNext(): void;
  87116. /**
  87117. * Break the loop and run the success callback.
  87118. */
  87119. breakLoop(): void;
  87120. /**
  87121. * Create and run an async loop.
  87122. * @param iterations the number of iterations.
  87123. * @param fn the function to run each iteration
  87124. * @param successCallback the callback that will be called upon succesful execution
  87125. * @param offset starting offset.
  87126. * @returns the created async loop object
  87127. */
  87128. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87129. /**
  87130. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87131. * @param iterations total number of iterations
  87132. * @param syncedIterations number of synchronous iterations in each async iteration.
  87133. * @param fn the function to call each iteration.
  87134. * @param callback a success call back that will be called when iterating stops.
  87135. * @param breakFunction a break condition (optional)
  87136. * @param timeout timeout settings for the setTimeout function. default - 0.
  87137. * @returns the created async loop object
  87138. */
  87139. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87140. }
  87141. }
  87142. declare module BABYLON {
  87143. /** @hidden */
  87144. export interface ICollisionCoordinator {
  87145. createCollider(): Collider;
  87146. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87147. init(scene: Scene): void;
  87148. }
  87149. /** @hidden */
  87150. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87151. private _scene;
  87152. private _scaledPosition;
  87153. private _scaledVelocity;
  87154. private _finalPosition;
  87155. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87156. createCollider(): Collider;
  87157. init(scene: Scene): void;
  87158. private _collideWithWorld;
  87159. }
  87160. }
  87161. declare module BABYLON {
  87162. /**
  87163. * This class defines the direct association between an animation and a target
  87164. */
  87165. export class TargetedAnimation {
  87166. /**
  87167. * Animation to perform
  87168. */
  87169. animation: Animation;
  87170. /**
  87171. * Target to animate
  87172. */
  87173. target: any;
  87174. }
  87175. /**
  87176. * Use this class to create coordinated animations on multiple targets
  87177. */
  87178. export class AnimationGroup implements IDisposable {
  87179. /** The name of the animation group */
  87180. name: string;
  87181. private _scene;
  87182. private _targetedAnimations;
  87183. private _animatables;
  87184. private _from;
  87185. private _to;
  87186. private _isStarted;
  87187. private _isPaused;
  87188. private _speedRatio;
  87189. /**
  87190. * Gets or sets the unique id of the node
  87191. */
  87192. uniqueId: number;
  87193. /**
  87194. * This observable will notify when one animation have ended
  87195. */
  87196. onAnimationEndObservable: Observable<TargetedAnimation>;
  87197. /**
  87198. * Observer raised when one animation loops
  87199. */
  87200. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87201. /**
  87202. * This observable will notify when all animations have ended.
  87203. */
  87204. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87205. /**
  87206. * This observable will notify when all animations have paused.
  87207. */
  87208. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87209. /**
  87210. * This observable will notify when all animations are playing.
  87211. */
  87212. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87213. /**
  87214. * Gets the first frame
  87215. */
  87216. readonly from: number;
  87217. /**
  87218. * Gets the last frame
  87219. */
  87220. readonly to: number;
  87221. /**
  87222. * Define if the animations are started
  87223. */
  87224. readonly isStarted: boolean;
  87225. /**
  87226. * Gets a value indicating that the current group is playing
  87227. */
  87228. readonly isPlaying: boolean;
  87229. /**
  87230. * Gets or sets the speed ratio to use for all animations
  87231. */
  87232. /**
  87233. * Gets or sets the speed ratio to use for all animations
  87234. */
  87235. speedRatio: number;
  87236. /**
  87237. * Gets the targeted animations for this animation group
  87238. */
  87239. readonly targetedAnimations: Array<TargetedAnimation>;
  87240. /**
  87241. * returning the list of animatables controlled by this animation group.
  87242. */
  87243. readonly animatables: Array<Animatable>;
  87244. /**
  87245. * Instantiates a new Animation Group.
  87246. * This helps managing several animations at once.
  87247. * @see http://doc.babylonjs.com/how_to/group
  87248. * @param name Defines the name of the group
  87249. * @param scene Defines the scene the group belongs to
  87250. */
  87251. constructor(
  87252. /** The name of the animation group */
  87253. name: string, scene?: Nullable<Scene>);
  87254. /**
  87255. * Add an animation (with its target) in the group
  87256. * @param animation defines the animation we want to add
  87257. * @param target defines the target of the animation
  87258. * @returns the TargetedAnimation object
  87259. */
  87260. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87261. /**
  87262. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87263. * It can add constant keys at begin or end
  87264. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87265. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87266. * @returns the animation group
  87267. */
  87268. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87269. /**
  87270. * Start all animations on given targets
  87271. * @param loop defines if animations must loop
  87272. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87273. * @param from defines the from key (optional)
  87274. * @param to defines the to key (optional)
  87275. * @returns the current animation group
  87276. */
  87277. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87278. /**
  87279. * Pause all animations
  87280. * @returns the animation group
  87281. */
  87282. pause(): AnimationGroup;
  87283. /**
  87284. * Play all animations to initial state
  87285. * This function will start() the animations if they were not started or will restart() them if they were paused
  87286. * @param loop defines if animations must loop
  87287. * @returns the animation group
  87288. */
  87289. play(loop?: boolean): AnimationGroup;
  87290. /**
  87291. * Reset all animations to initial state
  87292. * @returns the animation group
  87293. */
  87294. reset(): AnimationGroup;
  87295. /**
  87296. * Restart animations from key 0
  87297. * @returns the animation group
  87298. */
  87299. restart(): AnimationGroup;
  87300. /**
  87301. * Stop all animations
  87302. * @returns the animation group
  87303. */
  87304. stop(): AnimationGroup;
  87305. /**
  87306. * Set animation weight for all animatables
  87307. * @param weight defines the weight to use
  87308. * @return the animationGroup
  87309. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87310. */
  87311. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87312. /**
  87313. * Synchronize and normalize all animatables with a source animatable
  87314. * @param root defines the root animatable to synchronize with
  87315. * @return the animationGroup
  87316. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87317. */
  87318. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87319. /**
  87320. * Goes to a specific frame in this animation group
  87321. * @param frame the frame number to go to
  87322. * @return the animationGroup
  87323. */
  87324. goToFrame(frame: number): AnimationGroup;
  87325. /**
  87326. * Dispose all associated resources
  87327. */
  87328. dispose(): void;
  87329. private _checkAnimationGroupEnded;
  87330. /**
  87331. * Clone the current animation group and returns a copy
  87332. * @param newName defines the name of the new group
  87333. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  87334. * @returns the new aniamtion group
  87335. */
  87336. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  87337. /**
  87338. * Returns a new AnimationGroup object parsed from the source provided.
  87339. * @param parsedAnimationGroup defines the source
  87340. * @param scene defines the scene that will receive the animationGroup
  87341. * @returns a new AnimationGroup
  87342. */
  87343. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87344. /**
  87345. * Returns the string "AnimationGroup"
  87346. * @returns "AnimationGroup"
  87347. */
  87348. getClassName(): string;
  87349. /**
  87350. * Creates a detailled string about the object
  87351. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87352. * @returns a string representing the object
  87353. */
  87354. toString(fullDetails?: boolean): string;
  87355. }
  87356. }
  87357. declare module BABYLON {
  87358. /**
  87359. * Define an interface for all classes that will hold resources
  87360. */
  87361. export interface IDisposable {
  87362. /**
  87363. * Releases all held resources
  87364. */
  87365. dispose(): void;
  87366. }
  87367. /** Interface defining initialization parameters for Scene class */
  87368. export interface SceneOptions {
  87369. /**
  87370. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87371. * It will improve performance when the number of geometries becomes important.
  87372. */
  87373. useGeometryUniqueIdsMap?: boolean;
  87374. /**
  87375. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87376. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87377. */
  87378. useMaterialMeshMap?: boolean;
  87379. /**
  87380. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87381. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87382. */
  87383. useClonedMeshhMap?: boolean;
  87384. }
  87385. /**
  87386. * Represents a scene to be rendered by the engine.
  87387. * @see http://doc.babylonjs.com/features/scene
  87388. */
  87389. export class Scene extends AbstractScene implements IAnimatable {
  87390. private static _uniqueIdCounter;
  87391. /** The fog is deactivated */
  87392. static readonly FOGMODE_NONE: number;
  87393. /** The fog density is following an exponential function */
  87394. static readonly FOGMODE_EXP: number;
  87395. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87396. static readonly FOGMODE_EXP2: number;
  87397. /** The fog density is following a linear function. */
  87398. static readonly FOGMODE_LINEAR: number;
  87399. /**
  87400. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87402. */
  87403. static MinDeltaTime: number;
  87404. /**
  87405. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87407. */
  87408. static MaxDeltaTime: number;
  87409. /**
  87410. * Factory used to create the default material.
  87411. * @param name The name of the material to create
  87412. * @param scene The scene to create the material for
  87413. * @returns The default material
  87414. */
  87415. static DefaultMaterialFactory(scene: Scene): Material;
  87416. /**
  87417. * Factory used to create the a collision coordinator.
  87418. * @returns The collision coordinator
  87419. */
  87420. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87421. /** @hidden */
  87422. readonly _isScene: boolean;
  87423. /**
  87424. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87425. */
  87426. autoClear: boolean;
  87427. /**
  87428. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87429. */
  87430. autoClearDepthAndStencil: boolean;
  87431. /**
  87432. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87433. */
  87434. clearColor: Color4;
  87435. /**
  87436. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87437. */
  87438. ambientColor: Color3;
  87439. /** @hidden */
  87440. _environmentBRDFTexture: BaseTexture;
  87441. /** @hidden */
  87442. protected _environmentTexture: Nullable<BaseTexture>;
  87443. /**
  87444. * Texture used in all pbr material as the reflection texture.
  87445. * As in the majority of the scene they are the same (exception for multi room and so on),
  87446. * this is easier to reference from here than from all the materials.
  87447. */
  87448. /**
  87449. * Texture used in all pbr material as the reflection texture.
  87450. * As in the majority of the scene they are the same (exception for multi room and so on),
  87451. * this is easier to set here than in all the materials.
  87452. */
  87453. environmentTexture: Nullable<BaseTexture>;
  87454. /** @hidden */
  87455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87456. /**
  87457. * Default image processing configuration used either in the rendering
  87458. * Forward main pass or through the imageProcessingPostProcess if present.
  87459. * As in the majority of the scene they are the same (exception for multi camera),
  87460. * this is easier to reference from here than from all the materials and post process.
  87461. *
  87462. * No setter as we it is a shared configuration, you can set the values instead.
  87463. */
  87464. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87465. private _forceWireframe;
  87466. /**
  87467. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87468. */
  87469. forceWireframe: boolean;
  87470. private _forcePointsCloud;
  87471. /**
  87472. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87473. */
  87474. forcePointsCloud: boolean;
  87475. /**
  87476. * Gets or sets the active clipplane 1
  87477. */
  87478. clipPlane: Nullable<Plane>;
  87479. /**
  87480. * Gets or sets the active clipplane 2
  87481. */
  87482. clipPlane2: Nullable<Plane>;
  87483. /**
  87484. * Gets or sets the active clipplane 3
  87485. */
  87486. clipPlane3: Nullable<Plane>;
  87487. /**
  87488. * Gets or sets the active clipplane 4
  87489. */
  87490. clipPlane4: Nullable<Plane>;
  87491. /**
  87492. * Gets or sets a boolean indicating if animations are enabled
  87493. */
  87494. animationsEnabled: boolean;
  87495. private _animationPropertiesOverride;
  87496. /**
  87497. * Gets or sets the animation properties override
  87498. */
  87499. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87500. /**
  87501. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87502. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87503. */
  87504. useConstantAnimationDeltaTime: boolean;
  87505. /**
  87506. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87507. * Please note that it requires to run a ray cast through the scene on every frame
  87508. */
  87509. constantlyUpdateMeshUnderPointer: boolean;
  87510. /**
  87511. * Defines the HTML cursor to use when hovering over interactive elements
  87512. */
  87513. hoverCursor: string;
  87514. /**
  87515. * Defines the HTML default cursor to use (empty by default)
  87516. */
  87517. defaultCursor: string;
  87518. /**
  87519. * This is used to call preventDefault() on pointer down
  87520. * in order to block unwanted artifacts like system double clicks
  87521. */
  87522. preventDefaultOnPointerDown: boolean;
  87523. /**
  87524. * This is used to call preventDefault() on pointer up
  87525. * in order to block unwanted artifacts like system double clicks
  87526. */
  87527. preventDefaultOnPointerUp: boolean;
  87528. /**
  87529. * Gets or sets user defined metadata
  87530. */
  87531. metadata: any;
  87532. /**
  87533. * For internal use only. Please do not use.
  87534. */
  87535. reservedDataStore: any;
  87536. /**
  87537. * Gets the name of the plugin used to load this scene (null by default)
  87538. */
  87539. loadingPluginName: string;
  87540. /**
  87541. * Use this array to add regular expressions used to disable offline support for specific urls
  87542. */
  87543. disableOfflineSupportExceptionRules: RegExp[];
  87544. /**
  87545. * An event triggered when the scene is disposed.
  87546. */
  87547. onDisposeObservable: Observable<Scene>;
  87548. private _onDisposeObserver;
  87549. /** Sets a function to be executed when this scene is disposed. */
  87550. onDispose: () => void;
  87551. /**
  87552. * An event triggered before rendering the scene (right after animations and physics)
  87553. */
  87554. onBeforeRenderObservable: Observable<Scene>;
  87555. private _onBeforeRenderObserver;
  87556. /** Sets a function to be executed before rendering this scene */
  87557. beforeRender: Nullable<() => void>;
  87558. /**
  87559. * An event triggered after rendering the scene
  87560. */
  87561. onAfterRenderObservable: Observable<Scene>;
  87562. private _onAfterRenderObserver;
  87563. /** Sets a function to be executed after rendering this scene */
  87564. afterRender: Nullable<() => void>;
  87565. /**
  87566. * An event triggered before animating the scene
  87567. */
  87568. onBeforeAnimationsObservable: Observable<Scene>;
  87569. /**
  87570. * An event triggered after animations processing
  87571. */
  87572. onAfterAnimationsObservable: Observable<Scene>;
  87573. /**
  87574. * An event triggered before draw calls are ready to be sent
  87575. */
  87576. onBeforeDrawPhaseObservable: Observable<Scene>;
  87577. /**
  87578. * An event triggered after draw calls have been sent
  87579. */
  87580. onAfterDrawPhaseObservable: Observable<Scene>;
  87581. /**
  87582. * An event triggered when the scene is ready
  87583. */
  87584. onReadyObservable: Observable<Scene>;
  87585. /**
  87586. * An event triggered before rendering a camera
  87587. */
  87588. onBeforeCameraRenderObservable: Observable<Camera>;
  87589. private _onBeforeCameraRenderObserver;
  87590. /** Sets a function to be executed before rendering a camera*/
  87591. beforeCameraRender: () => void;
  87592. /**
  87593. * An event triggered after rendering a camera
  87594. */
  87595. onAfterCameraRenderObservable: Observable<Camera>;
  87596. private _onAfterCameraRenderObserver;
  87597. /** Sets a function to be executed after rendering a camera*/
  87598. afterCameraRender: () => void;
  87599. /**
  87600. * An event triggered when active meshes evaluation is about to start
  87601. */
  87602. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87603. /**
  87604. * An event triggered when active meshes evaluation is done
  87605. */
  87606. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87607. /**
  87608. * An event triggered when particles rendering is about to start
  87609. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87610. */
  87611. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87612. /**
  87613. * An event triggered when particles rendering is done
  87614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87615. */
  87616. onAfterParticlesRenderingObservable: Observable<Scene>;
  87617. /**
  87618. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87619. */
  87620. onDataLoadedObservable: Observable<Scene>;
  87621. /**
  87622. * An event triggered when a camera is created
  87623. */
  87624. onNewCameraAddedObservable: Observable<Camera>;
  87625. /**
  87626. * An event triggered when a camera is removed
  87627. */
  87628. onCameraRemovedObservable: Observable<Camera>;
  87629. /**
  87630. * An event triggered when a light is created
  87631. */
  87632. onNewLightAddedObservable: Observable<Light>;
  87633. /**
  87634. * An event triggered when a light is removed
  87635. */
  87636. onLightRemovedObservable: Observable<Light>;
  87637. /**
  87638. * An event triggered when a geometry is created
  87639. */
  87640. onNewGeometryAddedObservable: Observable<Geometry>;
  87641. /**
  87642. * An event triggered when a geometry is removed
  87643. */
  87644. onGeometryRemovedObservable: Observable<Geometry>;
  87645. /**
  87646. * An event triggered when a transform node is created
  87647. */
  87648. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87649. /**
  87650. * An event triggered when a transform node is removed
  87651. */
  87652. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87653. /**
  87654. * An event triggered when a mesh is created
  87655. */
  87656. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87657. /**
  87658. * An event triggered when a mesh is removed
  87659. */
  87660. onMeshRemovedObservable: Observable<AbstractMesh>;
  87661. /**
  87662. * An event triggered when a material is created
  87663. */
  87664. onNewMaterialAddedObservable: Observable<Material>;
  87665. /**
  87666. * An event triggered when a material is removed
  87667. */
  87668. onMaterialRemovedObservable: Observable<Material>;
  87669. /**
  87670. * An event triggered when a texture is created
  87671. */
  87672. onNewTextureAddedObservable: Observable<BaseTexture>;
  87673. /**
  87674. * An event triggered when a texture is removed
  87675. */
  87676. onTextureRemovedObservable: Observable<BaseTexture>;
  87677. /**
  87678. * An event triggered when render targets are about to be rendered
  87679. * Can happen multiple times per frame.
  87680. */
  87681. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87682. /**
  87683. * An event triggered when render targets were rendered.
  87684. * Can happen multiple times per frame.
  87685. */
  87686. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87687. /**
  87688. * An event triggered before calculating deterministic simulation step
  87689. */
  87690. onBeforeStepObservable: Observable<Scene>;
  87691. /**
  87692. * An event triggered after calculating deterministic simulation step
  87693. */
  87694. onAfterStepObservable: Observable<Scene>;
  87695. /**
  87696. * An event triggered when the activeCamera property is updated
  87697. */
  87698. onActiveCameraChanged: Observable<Scene>;
  87699. /**
  87700. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87701. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87702. * 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)
  87703. */
  87704. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87705. /**
  87706. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87707. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87708. * 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)
  87709. */
  87710. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87711. /**
  87712. * This Observable will when a mesh has been imported into the scene.
  87713. */
  87714. onMeshImportedObservable: Observable<AbstractMesh>;
  87715. /** @hidden */
  87716. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  87717. /**
  87718. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  87719. */
  87720. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  87721. /**
  87722. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  87723. */
  87724. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  87725. /**
  87726. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  87727. */
  87728. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  87729. private _onPointerMove;
  87730. private _onPointerDown;
  87731. private _onPointerUp;
  87732. /** Callback called when a pointer move is detected */
  87733. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87734. /** Callback called when a pointer down is detected */
  87735. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87736. /** Callback called when a pointer up is detected */
  87737. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  87738. /** Callback called when a pointer pick is detected */
  87739. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  87740. /**
  87741. * 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).
  87742. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  87743. */
  87744. onPrePointerObservable: Observable<PointerInfoPre>;
  87745. /**
  87746. * Observable event triggered each time an input event is received from the rendering canvas
  87747. */
  87748. onPointerObservable: Observable<PointerInfo>;
  87749. /**
  87750. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  87751. */
  87752. readonly unTranslatedPointer: Vector2;
  87753. /** The distance in pixel that you have to move to prevent some events */
  87754. static DragMovementThreshold: number;
  87755. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  87756. static LongPressDelay: number;
  87757. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  87758. static DoubleClickDelay: number;
  87759. /** If you need to check double click without raising a single click at first click, enable this flag */
  87760. static ExclusiveDoubleClickMode: boolean;
  87761. private _initClickEvent;
  87762. private _initActionManager;
  87763. private _delayedSimpleClick;
  87764. private _delayedSimpleClickTimeout;
  87765. private _previousDelayedSimpleClickTimeout;
  87766. private _meshPickProceed;
  87767. private _previousButtonPressed;
  87768. private _currentPickResult;
  87769. private _previousPickResult;
  87770. private _totalPointersPressed;
  87771. private _doubleClickOccured;
  87772. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  87773. cameraToUseForPointers: Nullable<Camera>;
  87774. private _pointerX;
  87775. private _pointerY;
  87776. private _unTranslatedPointerX;
  87777. private _unTranslatedPointerY;
  87778. private _startingPointerPosition;
  87779. private _previousStartingPointerPosition;
  87780. private _startingPointerTime;
  87781. private _previousStartingPointerTime;
  87782. private _pointerCaptures;
  87783. private _timeAccumulator;
  87784. private _currentStepId;
  87785. private _currentInternalStep;
  87786. /** @hidden */
  87787. _mirroredCameraPosition: Nullable<Vector3>;
  87788. /**
  87789. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  87790. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  87791. */
  87792. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  87793. /**
  87794. * Observable event triggered each time an keyboard event is received from the hosting window
  87795. */
  87796. onKeyboardObservable: Observable<KeyboardInfo>;
  87797. private _onKeyDown;
  87798. private _onKeyUp;
  87799. private _onCanvasFocusObserver;
  87800. private _onCanvasBlurObserver;
  87801. private _useRightHandedSystem;
  87802. /**
  87803. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  87804. */
  87805. useRightHandedSystem: boolean;
  87806. /**
  87807. * Sets the step Id used by deterministic lock step
  87808. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87809. * @param newStepId defines the step Id
  87810. */
  87811. setStepId(newStepId: number): void;
  87812. /**
  87813. * Gets the step Id used by deterministic lock step
  87814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87815. * @returns the step Id
  87816. */
  87817. getStepId(): number;
  87818. /**
  87819. * Gets the internal step used by deterministic lock step
  87820. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87821. * @returns the internal step
  87822. */
  87823. getInternalStep(): number;
  87824. private _fogEnabled;
  87825. /**
  87826. * Gets or sets a boolean indicating if fog is enabled on this scene
  87827. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87828. * (Default is true)
  87829. */
  87830. fogEnabled: boolean;
  87831. private _fogMode;
  87832. /**
  87833. * Gets or sets the fog mode to use
  87834. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87835. * | mode | value |
  87836. * | --- | --- |
  87837. * | FOGMODE_NONE | 0 |
  87838. * | FOGMODE_EXP | 1 |
  87839. * | FOGMODE_EXP2 | 2 |
  87840. * | FOGMODE_LINEAR | 3 |
  87841. */
  87842. fogMode: number;
  87843. /**
  87844. * Gets or sets the fog color to use
  87845. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87846. * (Default is Color3(0.2, 0.2, 0.3))
  87847. */
  87848. fogColor: Color3;
  87849. /**
  87850. * Gets or sets the fog density to use
  87851. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87852. * (Default is 0.1)
  87853. */
  87854. fogDensity: number;
  87855. /**
  87856. * Gets or sets the fog start distance to use
  87857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87858. * (Default is 0)
  87859. */
  87860. fogStart: number;
  87861. /**
  87862. * Gets or sets the fog end distance to use
  87863. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87864. * (Default is 1000)
  87865. */
  87866. fogEnd: number;
  87867. private _shadowsEnabled;
  87868. /**
  87869. * Gets or sets a boolean indicating if shadows are enabled on this scene
  87870. */
  87871. shadowsEnabled: boolean;
  87872. private _lightsEnabled;
  87873. /**
  87874. * Gets or sets a boolean indicating if lights are enabled on this scene
  87875. */
  87876. lightsEnabled: boolean;
  87877. /** All of the active cameras added to this scene. */
  87878. activeCameras: Camera[];
  87879. private _activeCamera;
  87880. /** Gets or sets the current active camera */
  87881. activeCamera: Nullable<Camera>;
  87882. private _defaultMaterial;
  87883. /** The default material used on meshes when no material is affected */
  87884. /** The default material used on meshes when no material is affected */
  87885. defaultMaterial: Material;
  87886. private _texturesEnabled;
  87887. /**
  87888. * Gets or sets a boolean indicating if textures are enabled on this scene
  87889. */
  87890. texturesEnabled: boolean;
  87891. /**
  87892. * Gets or sets a boolean indicating if particles are enabled on this scene
  87893. */
  87894. particlesEnabled: boolean;
  87895. /**
  87896. * Gets or sets a boolean indicating if sprites are enabled on this scene
  87897. */
  87898. spritesEnabled: boolean;
  87899. private _skeletonsEnabled;
  87900. /**
  87901. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  87902. */
  87903. skeletonsEnabled: boolean;
  87904. /**
  87905. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  87906. */
  87907. lensFlaresEnabled: boolean;
  87908. /**
  87909. * Gets or sets a boolean indicating if collisions are enabled on this scene
  87910. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87911. */
  87912. collisionsEnabled: boolean;
  87913. private _collisionCoordinator;
  87914. /** @hidden */
  87915. readonly collisionCoordinator: ICollisionCoordinator;
  87916. /**
  87917. * Defines the gravity applied to this scene (used only for collisions)
  87918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87919. */
  87920. gravity: Vector3;
  87921. /**
  87922. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  87923. */
  87924. postProcessesEnabled: boolean;
  87925. /**
  87926. * The list of postprocesses added to the scene
  87927. */
  87928. postProcesses: PostProcess[];
  87929. /**
  87930. * Gets the current postprocess manager
  87931. */
  87932. postProcessManager: PostProcessManager;
  87933. /**
  87934. * Gets or sets a boolean indicating if render targets are enabled on this scene
  87935. */
  87936. renderTargetsEnabled: boolean;
  87937. /**
  87938. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  87939. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  87940. */
  87941. dumpNextRenderTargets: boolean;
  87942. /**
  87943. * The list of user defined render targets added to the scene
  87944. */
  87945. customRenderTargets: RenderTargetTexture[];
  87946. /**
  87947. * Defines if texture loading must be delayed
  87948. * If true, textures will only be loaded when they need to be rendered
  87949. */
  87950. useDelayedTextureLoading: boolean;
  87951. /**
  87952. * Gets the list of meshes imported to the scene through SceneLoader
  87953. */
  87954. importedMeshesFiles: String[];
  87955. /**
  87956. * Gets or sets a boolean indicating if probes are enabled on this scene
  87957. */
  87958. probesEnabled: boolean;
  87959. /**
  87960. * Gets or sets the current offline provider to use to store scene data
  87961. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87962. */
  87963. offlineProvider: IOfflineProvider;
  87964. /**
  87965. * Gets or sets the action manager associated with the scene
  87966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87967. */
  87968. actionManager: AbstractActionManager;
  87969. private _meshesForIntersections;
  87970. /**
  87971. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  87972. */
  87973. proceduralTexturesEnabled: boolean;
  87974. private _engine;
  87975. private _totalVertices;
  87976. /** @hidden */
  87977. _activeIndices: PerfCounter;
  87978. /** @hidden */
  87979. _activeParticles: PerfCounter;
  87980. /** @hidden */
  87981. _activeBones: PerfCounter;
  87982. private _animationRatio;
  87983. /** @hidden */
  87984. _animationTimeLast: number;
  87985. /** @hidden */
  87986. _animationTime: number;
  87987. /**
  87988. * Gets or sets a general scale for animation speed
  87989. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  87990. */
  87991. animationTimeScale: number;
  87992. /** @hidden */
  87993. _cachedMaterial: Nullable<Material>;
  87994. /** @hidden */
  87995. _cachedEffect: Nullable<Effect>;
  87996. /** @hidden */
  87997. _cachedVisibility: Nullable<number>;
  87998. private _renderId;
  87999. private _frameId;
  88000. private _executeWhenReadyTimeoutId;
  88001. private _intermediateRendering;
  88002. private _viewUpdateFlag;
  88003. private _projectionUpdateFlag;
  88004. private _alternateViewUpdateFlag;
  88005. private _alternateProjectionUpdateFlag;
  88006. /** @hidden */
  88007. _toBeDisposed: Nullable<IDisposable>[];
  88008. private _activeRequests;
  88009. /** @hidden */
  88010. _pendingData: any[];
  88011. private _isDisposed;
  88012. /**
  88013. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  88014. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  88015. */
  88016. dispatchAllSubMeshesOfActiveMeshes: boolean;
  88017. private _activeMeshes;
  88018. private _processedMaterials;
  88019. private _renderTargets;
  88020. /** @hidden */
  88021. _activeParticleSystems: SmartArray<IParticleSystem>;
  88022. private _activeSkeletons;
  88023. private _softwareSkinnedMeshes;
  88024. private _renderingManager;
  88025. /** @hidden */
  88026. _activeAnimatables: Animatable[];
  88027. private _transformMatrix;
  88028. private _sceneUbo;
  88029. private _alternateSceneUbo;
  88030. private _viewMatrix;
  88031. private _projectionMatrix;
  88032. private _alternateViewMatrix;
  88033. private _alternateProjectionMatrix;
  88034. private _alternateTransformMatrix;
  88035. private _useAlternateCameraConfiguration;
  88036. private _alternateRendering;
  88037. private _wheelEventName;
  88038. /** @hidden */
  88039. _forcedViewPosition: Nullable<Vector3>;
  88040. /** @hidden */
  88041. readonly _isAlternateRenderingEnabled: boolean;
  88042. private _frustumPlanes;
  88043. /**
  88044. * Gets the list of frustum planes (built from the active camera)
  88045. */
  88046. readonly frustumPlanes: Plane[];
  88047. /**
  88048. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88049. * This is useful if there are more lights that the maximum simulteanous authorized
  88050. */
  88051. requireLightSorting: boolean;
  88052. /** @hidden */
  88053. readonly useMaterialMeshMap: boolean;
  88054. /** @hidden */
  88055. readonly useClonedMeshhMap: boolean;
  88056. private _pointerOverMesh;
  88057. private _pickedDownMesh;
  88058. private _pickedUpMesh;
  88059. private _externalData;
  88060. private _uid;
  88061. /**
  88062. * @hidden
  88063. * Backing store of defined scene components.
  88064. */
  88065. _components: ISceneComponent[];
  88066. /**
  88067. * @hidden
  88068. * Backing store of defined scene components.
  88069. */
  88070. _serializableComponents: ISceneSerializableComponent[];
  88071. /**
  88072. * List of components to register on the next registration step.
  88073. */
  88074. private _transientComponents;
  88075. /**
  88076. * Registers the transient components if needed.
  88077. */
  88078. private _registerTransientComponents;
  88079. /**
  88080. * @hidden
  88081. * Add a component to the scene.
  88082. * Note that the ccomponent could be registered on th next frame if this is called after
  88083. * the register component stage.
  88084. * @param component Defines the component to add to the scene
  88085. */
  88086. _addComponent(component: ISceneComponent): void;
  88087. /**
  88088. * @hidden
  88089. * Gets a component from the scene.
  88090. * @param name defines the name of the component to retrieve
  88091. * @returns the component or null if not present
  88092. */
  88093. _getComponent(name: string): Nullable<ISceneComponent>;
  88094. /**
  88095. * @hidden
  88096. * Defines the actions happening before camera updates.
  88097. */
  88098. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88099. /**
  88100. * @hidden
  88101. * Defines the actions happening before clear the canvas.
  88102. */
  88103. _beforeClearStage: Stage<SimpleStageAction>;
  88104. /**
  88105. * @hidden
  88106. * Defines the actions when collecting render targets for the frame.
  88107. */
  88108. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88109. /**
  88110. * @hidden
  88111. * Defines the actions happening for one camera in the frame.
  88112. */
  88113. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88114. /**
  88115. * @hidden
  88116. * Defines the actions happening during the per mesh ready checks.
  88117. */
  88118. _isReadyForMeshStage: Stage<MeshStageAction>;
  88119. /**
  88120. * @hidden
  88121. * Defines the actions happening before evaluate active mesh checks.
  88122. */
  88123. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88124. /**
  88125. * @hidden
  88126. * Defines the actions happening during the evaluate sub mesh checks.
  88127. */
  88128. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88129. /**
  88130. * @hidden
  88131. * Defines the actions happening during the active mesh stage.
  88132. */
  88133. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88134. /**
  88135. * @hidden
  88136. * Defines the actions happening during the per camera render target step.
  88137. */
  88138. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88139. /**
  88140. * @hidden
  88141. * Defines the actions happening just before the active camera is drawing.
  88142. */
  88143. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88144. /**
  88145. * @hidden
  88146. * Defines the actions happening just before a render target is drawing.
  88147. */
  88148. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88149. /**
  88150. * @hidden
  88151. * Defines the actions happening just before a rendering group is drawing.
  88152. */
  88153. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88154. /**
  88155. * @hidden
  88156. * Defines the actions happening just before a mesh is drawing.
  88157. */
  88158. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88159. /**
  88160. * @hidden
  88161. * Defines the actions happening just after a mesh has been drawn.
  88162. */
  88163. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88164. /**
  88165. * @hidden
  88166. * Defines the actions happening just after a rendering group has been drawn.
  88167. */
  88168. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88169. /**
  88170. * @hidden
  88171. * Defines the actions happening just after the active camera has been drawn.
  88172. */
  88173. _afterCameraDrawStage: Stage<CameraStageAction>;
  88174. /**
  88175. * @hidden
  88176. * Defines the actions happening just after a render target has been drawn.
  88177. */
  88178. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88179. /**
  88180. * @hidden
  88181. * Defines the actions happening just after rendering all cameras and computing intersections.
  88182. */
  88183. _afterRenderStage: Stage<SimpleStageAction>;
  88184. /**
  88185. * @hidden
  88186. * Defines the actions happening when a pointer move event happens.
  88187. */
  88188. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88189. /**
  88190. * @hidden
  88191. * Defines the actions happening when a pointer down event happens.
  88192. */
  88193. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88194. /**
  88195. * @hidden
  88196. * Defines the actions happening when a pointer up event happens.
  88197. */
  88198. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88199. /**
  88200. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88201. */
  88202. private geometriesByUniqueId;
  88203. /**
  88204. * Creates a new Scene
  88205. * @param engine defines the engine to use to render this scene
  88206. * @param options defines the scene options
  88207. */
  88208. constructor(engine: Engine, options?: SceneOptions);
  88209. private _defaultMeshCandidates;
  88210. /**
  88211. * @hidden
  88212. */
  88213. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88214. private _defaultSubMeshCandidates;
  88215. /**
  88216. * @hidden
  88217. */
  88218. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88219. /**
  88220. * Sets the default candidate providers for the scene.
  88221. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88222. * and getCollidingSubMeshCandidates to their default function
  88223. */
  88224. setDefaultCandidateProviders(): void;
  88225. /**
  88226. * Gets the mesh that is currently under the pointer
  88227. */
  88228. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88229. /**
  88230. * Gets or sets the current on-screen X position of the pointer
  88231. */
  88232. pointerX: number;
  88233. /**
  88234. * Gets or sets the current on-screen Y position of the pointer
  88235. */
  88236. pointerY: number;
  88237. /**
  88238. * Gets the cached material (ie. the latest rendered one)
  88239. * @returns the cached material
  88240. */
  88241. getCachedMaterial(): Nullable<Material>;
  88242. /**
  88243. * Gets the cached effect (ie. the latest rendered one)
  88244. * @returns the cached effect
  88245. */
  88246. getCachedEffect(): Nullable<Effect>;
  88247. /**
  88248. * Gets the cached visibility state (ie. the latest rendered one)
  88249. * @returns the cached visibility state
  88250. */
  88251. getCachedVisibility(): Nullable<number>;
  88252. /**
  88253. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88254. * @param material defines the current material
  88255. * @param effect defines the current effect
  88256. * @param visibility defines the current visibility state
  88257. * @returns true if one parameter is not cached
  88258. */
  88259. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88260. /**
  88261. * Gets the engine associated with the scene
  88262. * @returns an Engine
  88263. */
  88264. getEngine(): Engine;
  88265. /**
  88266. * Gets the total number of vertices rendered per frame
  88267. * @returns the total number of vertices rendered per frame
  88268. */
  88269. getTotalVertices(): number;
  88270. /**
  88271. * Gets the performance counter for total vertices
  88272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88273. */
  88274. readonly totalVerticesPerfCounter: PerfCounter;
  88275. /**
  88276. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88277. * @returns the total number of active indices rendered per frame
  88278. */
  88279. getActiveIndices(): number;
  88280. /**
  88281. * Gets the performance counter for active indices
  88282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88283. */
  88284. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88285. /**
  88286. * Gets the total number of active particles rendered per frame
  88287. * @returns the total number of active particles rendered per frame
  88288. */
  88289. getActiveParticles(): number;
  88290. /**
  88291. * Gets the performance counter for active particles
  88292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88293. */
  88294. readonly activeParticlesPerfCounter: PerfCounter;
  88295. /**
  88296. * Gets the total number of active bones rendered per frame
  88297. * @returns the total number of active bones rendered per frame
  88298. */
  88299. getActiveBones(): number;
  88300. /**
  88301. * Gets the performance counter for active bones
  88302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88303. */
  88304. readonly activeBonesPerfCounter: PerfCounter;
  88305. /**
  88306. * Gets the array of active meshes
  88307. * @returns an array of AbstractMesh
  88308. */
  88309. getActiveMeshes(): SmartArray<AbstractMesh>;
  88310. /**
  88311. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88312. * @returns a number
  88313. */
  88314. getAnimationRatio(): number;
  88315. /**
  88316. * Gets an unique Id for the current render phase
  88317. * @returns a number
  88318. */
  88319. getRenderId(): number;
  88320. /**
  88321. * Gets an unique Id for the current frame
  88322. * @returns a number
  88323. */
  88324. getFrameId(): number;
  88325. /** Call this function if you want to manually increment the render Id*/
  88326. incrementRenderId(): void;
  88327. private _updatePointerPosition;
  88328. private _createUbo;
  88329. private _createAlternateUbo;
  88330. private _setRayOnPointerInfo;
  88331. /**
  88332. * Use this method to simulate a pointer move on a mesh
  88333. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88334. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88335. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88336. * @returns the current scene
  88337. */
  88338. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88339. private _processPointerMove;
  88340. private _checkPrePointerObservable;
  88341. /**
  88342. * Use this method to simulate a pointer down on a mesh
  88343. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88344. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88345. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88346. * @returns the current scene
  88347. */
  88348. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88349. private _processPointerDown;
  88350. /**
  88351. * Use this method to simulate a pointer up on a mesh
  88352. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88353. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88354. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88355. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88356. * @returns the current scene
  88357. */
  88358. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88359. private _processPointerUp;
  88360. /**
  88361. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88362. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88363. * @returns true if the pointer was captured
  88364. */
  88365. isPointerCaptured(pointerId?: number): boolean;
  88366. /** @hidden */
  88367. _isPointerSwiping(): boolean;
  88368. /**
  88369. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88370. * @param attachUp defines if you want to attach events to pointerup
  88371. * @param attachDown defines if you want to attach events to pointerdown
  88372. * @param attachMove defines if you want to attach events to pointermove
  88373. */
  88374. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88375. /** Detaches all event handlers*/
  88376. detachControl(): void;
  88377. /**
  88378. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88379. * Delay loaded resources are not taking in account
  88380. * @return true if all required resources are ready
  88381. */
  88382. isReady(): boolean;
  88383. /** Resets all cached information relative to material (including effect and visibility) */
  88384. resetCachedMaterial(): void;
  88385. /**
  88386. * Registers a function to be called before every frame render
  88387. * @param func defines the function to register
  88388. */
  88389. registerBeforeRender(func: () => void): void;
  88390. /**
  88391. * Unregisters a function called before every frame render
  88392. * @param func defines the function to unregister
  88393. */
  88394. unregisterBeforeRender(func: () => void): void;
  88395. /**
  88396. * Registers a function to be called after every frame render
  88397. * @param func defines the function to register
  88398. */
  88399. registerAfterRender(func: () => void): void;
  88400. /**
  88401. * Unregisters a function called after every frame render
  88402. * @param func defines the function to unregister
  88403. */
  88404. unregisterAfterRender(func: () => void): void;
  88405. private _executeOnceBeforeRender;
  88406. /**
  88407. * The provided function will run before render once and will be disposed afterwards.
  88408. * A timeout delay can be provided so that the function will be executed in N ms.
  88409. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88410. * @param func The function to be executed.
  88411. * @param timeout optional delay in ms
  88412. */
  88413. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88414. /** @hidden */
  88415. _addPendingData(data: any): void;
  88416. /** @hidden */
  88417. _removePendingData(data: any): void;
  88418. /**
  88419. * Returns the number of items waiting to be loaded
  88420. * @returns the number of items waiting to be loaded
  88421. */
  88422. getWaitingItemsCount(): number;
  88423. /**
  88424. * Returns a boolean indicating if the scene is still loading data
  88425. */
  88426. readonly isLoading: boolean;
  88427. /**
  88428. * Registers a function to be executed when the scene is ready
  88429. * @param {Function} func - the function to be executed
  88430. */
  88431. executeWhenReady(func: () => void): void;
  88432. /**
  88433. * Returns a promise that resolves when the scene is ready
  88434. * @returns A promise that resolves when the scene is ready
  88435. */
  88436. whenReadyAsync(): Promise<void>;
  88437. /** @hidden */
  88438. _checkIsReady(): void;
  88439. /**
  88440. * Gets all animatable attached to the scene
  88441. */
  88442. readonly animatables: Animatable[];
  88443. /**
  88444. * Resets the last animation time frame.
  88445. * Useful to override when animations start running when loading a scene for the first time.
  88446. */
  88447. resetLastAnimationTimeFrame(): void;
  88448. /** @hidden */
  88449. _switchToAlternateCameraConfiguration(active: boolean): void;
  88450. /**
  88451. * Gets the current view matrix
  88452. * @returns a Matrix
  88453. */
  88454. getViewMatrix(): Matrix;
  88455. /**
  88456. * Gets the current projection matrix
  88457. * @returns a Matrix
  88458. */
  88459. getProjectionMatrix(): Matrix;
  88460. /**
  88461. * Gets the current transform matrix
  88462. * @returns a Matrix made of View * Projection
  88463. */
  88464. getTransformMatrix(): Matrix;
  88465. /**
  88466. * Sets the current transform matrix
  88467. * @param view defines the View matrix to use
  88468. * @param projection defines the Projection matrix to use
  88469. */
  88470. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88471. /** @hidden */
  88472. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88473. /**
  88474. * Gets the uniform buffer used to store scene data
  88475. * @returns a UniformBuffer
  88476. */
  88477. getSceneUniformBuffer(): UniformBuffer;
  88478. /**
  88479. * Gets an unique (relatively to the current scene) Id
  88480. * @returns an unique number for the scene
  88481. */
  88482. getUniqueId(): number;
  88483. /**
  88484. * Add a mesh to the list of scene's meshes
  88485. * @param newMesh defines the mesh to add
  88486. * @param recursive if all child meshes should also be added to the scene
  88487. */
  88488. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88489. /**
  88490. * Remove a mesh for the list of scene's meshes
  88491. * @param toRemove defines the mesh to remove
  88492. * @param recursive if all child meshes should also be removed from the scene
  88493. * @returns the index where the mesh was in the mesh list
  88494. */
  88495. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88496. /**
  88497. * Add a transform node to the list of scene's transform nodes
  88498. * @param newTransformNode defines the transform node to add
  88499. */
  88500. addTransformNode(newTransformNode: TransformNode): void;
  88501. /**
  88502. * Remove a transform node for the list of scene's transform nodes
  88503. * @param toRemove defines the transform node to remove
  88504. * @returns the index where the transform node was in the transform node list
  88505. */
  88506. removeTransformNode(toRemove: TransformNode): number;
  88507. /**
  88508. * Remove a skeleton for the list of scene's skeletons
  88509. * @param toRemove defines the skeleton to remove
  88510. * @returns the index where the skeleton was in the skeleton list
  88511. */
  88512. removeSkeleton(toRemove: Skeleton): number;
  88513. /**
  88514. * Remove a morph target for the list of scene's morph targets
  88515. * @param toRemove defines the morph target to remove
  88516. * @returns the index where the morph target was in the morph target list
  88517. */
  88518. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88519. /**
  88520. * Remove a light for the list of scene's lights
  88521. * @param toRemove defines the light to remove
  88522. * @returns the index where the light was in the light list
  88523. */
  88524. removeLight(toRemove: Light): number;
  88525. /**
  88526. * Remove a camera for the list of scene's cameras
  88527. * @param toRemove defines the camera to remove
  88528. * @returns the index where the camera was in the camera list
  88529. */
  88530. removeCamera(toRemove: Camera): number;
  88531. /**
  88532. * Remove a particle system for the list of scene's particle systems
  88533. * @param toRemove defines the particle system to remove
  88534. * @returns the index where the particle system was in the particle system list
  88535. */
  88536. removeParticleSystem(toRemove: IParticleSystem): number;
  88537. /**
  88538. * Remove a animation for the list of scene's animations
  88539. * @param toRemove defines the animation to remove
  88540. * @returns the index where the animation was in the animation list
  88541. */
  88542. removeAnimation(toRemove: Animation): number;
  88543. /**
  88544. * Removes the given animation group from this scene.
  88545. * @param toRemove The animation group to remove
  88546. * @returns The index of the removed animation group
  88547. */
  88548. removeAnimationGroup(toRemove: AnimationGroup): number;
  88549. /**
  88550. * Removes the given multi-material from this scene.
  88551. * @param toRemove The multi-material to remove
  88552. * @returns The index of the removed multi-material
  88553. */
  88554. removeMultiMaterial(toRemove: MultiMaterial): number;
  88555. /**
  88556. * Removes the given material from this scene.
  88557. * @param toRemove The material to remove
  88558. * @returns The index of the removed material
  88559. */
  88560. removeMaterial(toRemove: Material): number;
  88561. /**
  88562. * Removes the given action manager from this scene.
  88563. * @param toRemove The action manager to remove
  88564. * @returns The index of the removed action manager
  88565. */
  88566. removeActionManager(toRemove: AbstractActionManager): number;
  88567. /**
  88568. * Removes the given texture from this scene.
  88569. * @param toRemove The texture to remove
  88570. * @returns The index of the removed texture
  88571. */
  88572. removeTexture(toRemove: BaseTexture): number;
  88573. /**
  88574. * Adds the given light to this scene
  88575. * @param newLight The light to add
  88576. */
  88577. addLight(newLight: Light): void;
  88578. /**
  88579. * Sorts the list list based on light priorities
  88580. */
  88581. sortLightsByPriority(): void;
  88582. /**
  88583. * Adds the given camera to this scene
  88584. * @param newCamera The camera to add
  88585. */
  88586. addCamera(newCamera: Camera): void;
  88587. /**
  88588. * Adds the given skeleton to this scene
  88589. * @param newSkeleton The skeleton to add
  88590. */
  88591. addSkeleton(newSkeleton: Skeleton): void;
  88592. /**
  88593. * Adds the given particle system to this scene
  88594. * @param newParticleSystem The particle system to add
  88595. */
  88596. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88597. /**
  88598. * Adds the given animation to this scene
  88599. * @param newAnimation The animation to add
  88600. */
  88601. addAnimation(newAnimation: Animation): void;
  88602. /**
  88603. * Adds the given animation group to this scene.
  88604. * @param newAnimationGroup The animation group to add
  88605. */
  88606. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88607. /**
  88608. * Adds the given multi-material to this scene
  88609. * @param newMultiMaterial The multi-material to add
  88610. */
  88611. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88612. /**
  88613. * Adds the given material to this scene
  88614. * @param newMaterial The material to add
  88615. */
  88616. addMaterial(newMaterial: Material): void;
  88617. /**
  88618. * Adds the given morph target to this scene
  88619. * @param newMorphTargetManager The morph target to add
  88620. */
  88621. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88622. /**
  88623. * Adds the given geometry to this scene
  88624. * @param newGeometry The geometry to add
  88625. */
  88626. addGeometry(newGeometry: Geometry): void;
  88627. /**
  88628. * Adds the given action manager to this scene
  88629. * @param newActionManager The action manager to add
  88630. */
  88631. addActionManager(newActionManager: AbstractActionManager): void;
  88632. /**
  88633. * Adds the given texture to this scene.
  88634. * @param newTexture The texture to add
  88635. */
  88636. addTexture(newTexture: BaseTexture): void;
  88637. /**
  88638. * Switch active camera
  88639. * @param newCamera defines the new active camera
  88640. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88641. */
  88642. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88643. /**
  88644. * sets the active camera of the scene using its ID
  88645. * @param id defines the camera's ID
  88646. * @return the new active camera or null if none found.
  88647. */
  88648. setActiveCameraByID(id: string): Nullable<Camera>;
  88649. /**
  88650. * sets the active camera of the scene using its name
  88651. * @param name defines the camera's name
  88652. * @returns the new active camera or null if none found.
  88653. */
  88654. setActiveCameraByName(name: string): Nullable<Camera>;
  88655. /**
  88656. * get an animation group using its name
  88657. * @param name defines the material's name
  88658. * @return the animation group or null if none found.
  88659. */
  88660. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88661. /**
  88662. * get a material using its id
  88663. * @param id defines the material's ID
  88664. * @return the material or null if none found.
  88665. */
  88666. getMaterialByID(id: string): Nullable<Material>;
  88667. /**
  88668. * Gets a material using its name
  88669. * @param name defines the material's name
  88670. * @return the material or null if none found.
  88671. */
  88672. getMaterialByName(name: string): Nullable<Material>;
  88673. /**
  88674. * Gets a camera using its id
  88675. * @param id defines the id to look for
  88676. * @returns the camera or null if not found
  88677. */
  88678. getCameraByID(id: string): Nullable<Camera>;
  88679. /**
  88680. * Gets a camera using its unique id
  88681. * @param uniqueId defines the unique id to look for
  88682. * @returns the camera or null if not found
  88683. */
  88684. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88685. /**
  88686. * Gets a camera using its name
  88687. * @param name defines the camera's name
  88688. * @return the camera or null if none found.
  88689. */
  88690. getCameraByName(name: string): Nullable<Camera>;
  88691. /**
  88692. * Gets a bone using its id
  88693. * @param id defines the bone's id
  88694. * @return the bone or null if not found
  88695. */
  88696. getBoneByID(id: string): Nullable<Bone>;
  88697. /**
  88698. * Gets a bone using its id
  88699. * @param name defines the bone's name
  88700. * @return the bone or null if not found
  88701. */
  88702. getBoneByName(name: string): Nullable<Bone>;
  88703. /**
  88704. * Gets a light node using its name
  88705. * @param name defines the the light's name
  88706. * @return the light or null if none found.
  88707. */
  88708. getLightByName(name: string): Nullable<Light>;
  88709. /**
  88710. * Gets a light node using its id
  88711. * @param id defines the light's id
  88712. * @return the light or null if none found.
  88713. */
  88714. getLightByID(id: string): Nullable<Light>;
  88715. /**
  88716. * Gets a light node using its scene-generated unique ID
  88717. * @param uniqueId defines the light's unique id
  88718. * @return the light or null if none found.
  88719. */
  88720. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  88721. /**
  88722. * Gets a particle system by id
  88723. * @param id defines the particle system id
  88724. * @return the corresponding system or null if none found
  88725. */
  88726. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  88727. /**
  88728. * Gets a geometry using its ID
  88729. * @param id defines the geometry's id
  88730. * @return the geometry or null if none found.
  88731. */
  88732. getGeometryByID(id: string): Nullable<Geometry>;
  88733. private _getGeometryByUniqueID;
  88734. /**
  88735. * Add a new geometry to this scene
  88736. * @param geometry defines the geometry to be added to the scene.
  88737. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  88738. * @return a boolean defining if the geometry was added or not
  88739. */
  88740. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  88741. /**
  88742. * Removes an existing geometry
  88743. * @param geometry defines the geometry to be removed from the scene
  88744. * @return a boolean defining if the geometry was removed or not
  88745. */
  88746. removeGeometry(geometry: Geometry): boolean;
  88747. /**
  88748. * Gets the list of geometries attached to the scene
  88749. * @returns an array of Geometry
  88750. */
  88751. getGeometries(): Geometry[];
  88752. /**
  88753. * Gets the first added mesh found of a given ID
  88754. * @param id defines the id to search for
  88755. * @return the mesh found or null if not found at all
  88756. */
  88757. getMeshByID(id: string): Nullable<AbstractMesh>;
  88758. /**
  88759. * Gets a list of meshes using their id
  88760. * @param id defines the id to search for
  88761. * @returns a list of meshes
  88762. */
  88763. getMeshesByID(id: string): Array<AbstractMesh>;
  88764. /**
  88765. * Gets the first added transform node found of a given ID
  88766. * @param id defines the id to search for
  88767. * @return the found transform node or null if not found at all.
  88768. */
  88769. getTransformNodeByID(id: string): Nullable<TransformNode>;
  88770. /**
  88771. * Gets a list of transform nodes using their id
  88772. * @param id defines the id to search for
  88773. * @returns a list of transform nodes
  88774. */
  88775. getTransformNodesByID(id: string): Array<TransformNode>;
  88776. /**
  88777. * Gets a mesh with its auto-generated unique id
  88778. * @param uniqueId defines the unique id to search for
  88779. * @return the found mesh or null if not found at all.
  88780. */
  88781. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  88782. /**
  88783. * Gets a the last added mesh using a given id
  88784. * @param id defines the id to search for
  88785. * @return the found mesh or null if not found at all.
  88786. */
  88787. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  88788. /**
  88789. * Gets a the last added node (Mesh, Camera, Light) using a given id
  88790. * @param id defines the id to search for
  88791. * @return the found node or null if not found at all
  88792. */
  88793. getLastEntryByID(id: string): Nullable<Node>;
  88794. /**
  88795. * Gets a node (Mesh, Camera, Light) using a given id
  88796. * @param id defines the id to search for
  88797. * @return the found node or null if not found at all
  88798. */
  88799. getNodeByID(id: string): Nullable<Node>;
  88800. /**
  88801. * Gets a node (Mesh, Camera, Light) using a given name
  88802. * @param name defines the name to search for
  88803. * @return the found node or null if not found at all.
  88804. */
  88805. getNodeByName(name: string): Nullable<Node>;
  88806. /**
  88807. * Gets a mesh using a given name
  88808. * @param name defines the name to search for
  88809. * @return the found mesh or null if not found at all.
  88810. */
  88811. getMeshByName(name: string): Nullable<AbstractMesh>;
  88812. /**
  88813. * Gets a transform node using a given name
  88814. * @param name defines the name to search for
  88815. * @return the found transform node or null if not found at all.
  88816. */
  88817. getTransformNodeByName(name: string): Nullable<TransformNode>;
  88818. /**
  88819. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  88820. * @param id defines the id to search for
  88821. * @return the found skeleton or null if not found at all.
  88822. */
  88823. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  88824. /**
  88825. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  88826. * @param id defines the id to search for
  88827. * @return the found skeleton or null if not found at all.
  88828. */
  88829. getSkeletonById(id: string): Nullable<Skeleton>;
  88830. /**
  88831. * Gets a skeleton using a given name
  88832. * @param name defines the name to search for
  88833. * @return the found skeleton or null if not found at all.
  88834. */
  88835. getSkeletonByName(name: string): Nullable<Skeleton>;
  88836. /**
  88837. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  88838. * @param id defines the id to search for
  88839. * @return the found morph target manager or null if not found at all.
  88840. */
  88841. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  88842. /**
  88843. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  88844. * @param id defines the id to search for
  88845. * @return the found morph target or null if not found at all.
  88846. */
  88847. getMorphTargetById(id: string): Nullable<MorphTarget>;
  88848. /**
  88849. * Gets a boolean indicating if the given mesh is active
  88850. * @param mesh defines the mesh to look for
  88851. * @returns true if the mesh is in the active list
  88852. */
  88853. isActiveMesh(mesh: AbstractMesh): boolean;
  88854. /**
  88855. * Return a unique id as a string which can serve as an identifier for the scene
  88856. */
  88857. readonly uid: string;
  88858. /**
  88859. * Add an externaly attached data from its key.
  88860. * This method call will fail and return false, if such key already exists.
  88861. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88862. * @param key the unique key that identifies the data
  88863. * @param data the data object to associate to the key for this Engine instance
  88864. * @return true if no such key were already present and the data was added successfully, false otherwise
  88865. */
  88866. addExternalData<T>(key: string, data: T): boolean;
  88867. /**
  88868. * Get an externaly attached data from its key
  88869. * @param key the unique key that identifies the data
  88870. * @return the associated data, if present (can be null), or undefined if not present
  88871. */
  88872. getExternalData<T>(key: string): Nullable<T>;
  88873. /**
  88874. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88875. * @param key the unique key that identifies the data
  88876. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88877. * @return the associated data, can be null if the factory returned null.
  88878. */
  88879. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88880. /**
  88881. * Remove an externaly attached data from the Engine instance
  88882. * @param key the unique key that identifies the data
  88883. * @return true if the data was successfully removed, false if it doesn't exist
  88884. */
  88885. removeExternalData(key: string): boolean;
  88886. private _evaluateSubMesh;
  88887. /**
  88888. * Clear the processed materials smart array preventing retention point in material dispose.
  88889. */
  88890. freeProcessedMaterials(): void;
  88891. private _preventFreeActiveMeshesAndRenderingGroups;
  88892. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  88893. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  88894. * when disposing several meshes in a row or a hierarchy of meshes.
  88895. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  88896. */
  88897. blockfreeActiveMeshesAndRenderingGroups: boolean;
  88898. /**
  88899. * Clear the active meshes smart array preventing retention point in mesh dispose.
  88900. */
  88901. freeActiveMeshes(): void;
  88902. /**
  88903. * Clear the info related to rendering groups preventing retention points during dispose.
  88904. */
  88905. freeRenderingGroups(): void;
  88906. /** @hidden */
  88907. _isInIntermediateRendering(): boolean;
  88908. /**
  88909. * Lambda returning the list of potentially active meshes.
  88910. */
  88911. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  88912. /**
  88913. * Lambda returning the list of potentially active sub meshes.
  88914. */
  88915. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  88916. /**
  88917. * Lambda returning the list of potentially intersecting sub meshes.
  88918. */
  88919. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  88920. /**
  88921. * Lambda returning the list of potentially colliding sub meshes.
  88922. */
  88923. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  88924. private _activeMeshesFrozen;
  88925. /**
  88926. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  88927. * @returns the current scene
  88928. */
  88929. freezeActiveMeshes(): Scene;
  88930. /**
  88931. * Use this function to restart evaluating active meshes on every frame
  88932. * @returns the current scene
  88933. */
  88934. unfreezeActiveMeshes(): Scene;
  88935. private _evaluateActiveMeshes;
  88936. private _activeMesh;
  88937. /**
  88938. * Update the transform matrix to update from the current active camera
  88939. * @param force defines a boolean used to force the update even if cache is up to date
  88940. */
  88941. updateTransformMatrix(force?: boolean): void;
  88942. /**
  88943. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  88944. * @param alternateCamera defines the camera to use
  88945. */
  88946. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  88947. /** @hidden */
  88948. _allowPostProcessClearColor: boolean;
  88949. private _renderForCamera;
  88950. private _processSubCameras;
  88951. private _checkIntersections;
  88952. /** @hidden */
  88953. _advancePhysicsEngineStep(step: number): void;
  88954. /**
  88955. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  88956. */
  88957. getDeterministicFrameTime: () => number;
  88958. /** @hidden */
  88959. _animate(): void;
  88960. /**
  88961. * Render the scene
  88962. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  88963. */
  88964. render(updateCameras?: boolean): void;
  88965. /**
  88966. * Freeze all materials
  88967. * A frozen material will not be updatable but should be faster to render
  88968. */
  88969. freezeMaterials(): void;
  88970. /**
  88971. * Unfreeze all materials
  88972. * A frozen material will not be updatable but should be faster to render
  88973. */
  88974. unfreezeMaterials(): void;
  88975. /**
  88976. * Releases all held ressources
  88977. */
  88978. dispose(): void;
  88979. /**
  88980. * Gets if the scene is already disposed
  88981. */
  88982. readonly isDisposed: boolean;
  88983. /**
  88984. * Call this function to reduce memory footprint of the scene.
  88985. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  88986. */
  88987. clearCachedVertexData(): void;
  88988. /**
  88989. * This function will remove the local cached buffer data from texture.
  88990. * It will save memory but will prevent the texture from being rebuilt
  88991. */
  88992. cleanCachedTextureBuffer(): void;
  88993. /**
  88994. * Get the world extend vectors with an optional filter
  88995. *
  88996. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  88997. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  88998. */
  88999. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89000. min: Vector3;
  89001. max: Vector3;
  89002. };
  89003. /**
  89004. * Creates a ray that can be used to pick in the scene
  89005. * @param x defines the x coordinate of the origin (on-screen)
  89006. * @param y defines the y coordinate of the origin (on-screen)
  89007. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89008. * @param camera defines the camera to use for the picking
  89009. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89010. * @returns a Ray
  89011. */
  89012. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89013. /**
  89014. * Creates a ray that can be used to pick in the scene
  89015. * @param x defines the x coordinate of the origin (on-screen)
  89016. * @param y defines the y coordinate of the origin (on-screen)
  89017. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89018. * @param result defines the ray where to store the picking ray
  89019. * @param camera defines the camera to use for the picking
  89020. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89021. * @returns the current scene
  89022. */
  89023. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  89024. /**
  89025. * Creates a ray that can be used to pick in the scene
  89026. * @param x defines the x coordinate of the origin (on-screen)
  89027. * @param y defines the y coordinate of the origin (on-screen)
  89028. * @param camera defines the camera to use for the picking
  89029. * @returns a Ray
  89030. */
  89031. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  89032. /**
  89033. * Creates a ray that can be used to pick in the scene
  89034. * @param x defines the x coordinate of the origin (on-screen)
  89035. * @param y defines the y coordinate of the origin (on-screen)
  89036. * @param result defines the ray where to store the picking ray
  89037. * @param camera defines the camera to use for the picking
  89038. * @returns the current scene
  89039. */
  89040. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89041. /** Launch a ray to try to pick a mesh in the scene
  89042. * @param x position on screen
  89043. * @param y position on screen
  89044. * @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
  89045. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89046. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89047. * @returns a PickingInfo
  89048. */
  89049. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89050. /** Use the given ray to pick a mesh in the scene
  89051. * @param ray The ray to use to pick meshes
  89052. * @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
  89053. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89054. * @returns a PickingInfo
  89055. */
  89056. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89057. /**
  89058. * Launch a ray to try to pick a mesh in the scene
  89059. * @param x X position on screen
  89060. * @param y Y position on screen
  89061. * @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
  89062. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89063. * @returns an array of PickingInfo
  89064. */
  89065. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89066. /**
  89067. * Launch a ray to try to pick a mesh in the scene
  89068. * @param ray Ray to use
  89069. * @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
  89070. * @returns an array of PickingInfo
  89071. */
  89072. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89073. /**
  89074. * Force the value of meshUnderPointer
  89075. * @param mesh defines the mesh to use
  89076. */
  89077. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89078. /**
  89079. * Gets the mesh under the pointer
  89080. * @returns a Mesh or null if no mesh is under the pointer
  89081. */
  89082. getPointerOverMesh(): Nullable<AbstractMesh>;
  89083. /** @hidden */
  89084. _rebuildGeometries(): void;
  89085. /** @hidden */
  89086. _rebuildTextures(): void;
  89087. private _getByTags;
  89088. /**
  89089. * Get a list of meshes by tags
  89090. * @param tagsQuery defines the tags query to use
  89091. * @param forEach defines a predicate used to filter results
  89092. * @returns an array of Mesh
  89093. */
  89094. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89095. /**
  89096. * Get a list of cameras by tags
  89097. * @param tagsQuery defines the tags query to use
  89098. * @param forEach defines a predicate used to filter results
  89099. * @returns an array of Camera
  89100. */
  89101. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89102. /**
  89103. * Get a list of lights by tags
  89104. * @param tagsQuery defines the tags query to use
  89105. * @param forEach defines a predicate used to filter results
  89106. * @returns an array of Light
  89107. */
  89108. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89109. /**
  89110. * Get a list of materials by tags
  89111. * @param tagsQuery defines the tags query to use
  89112. * @param forEach defines a predicate used to filter results
  89113. * @returns an array of Material
  89114. */
  89115. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89116. /**
  89117. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89118. * This allowed control for front to back rendering or reversly depending of the special needs.
  89119. *
  89120. * @param renderingGroupId The rendering group id corresponding to its index
  89121. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89122. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89123. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89124. */
  89125. 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;
  89126. /**
  89127. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89128. *
  89129. * @param renderingGroupId The rendering group id corresponding to its index
  89130. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89131. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89132. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89133. */
  89134. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89135. /**
  89136. * Gets the current auto clear configuration for one rendering group of the rendering
  89137. * manager.
  89138. * @param index the rendering group index to get the information for
  89139. * @returns The auto clear setup for the requested rendering group
  89140. */
  89141. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89142. private _blockMaterialDirtyMechanism;
  89143. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89144. blockMaterialDirtyMechanism: boolean;
  89145. /**
  89146. * Will flag all materials as dirty to trigger new shader compilation
  89147. * @param flag defines the flag used to specify which material part must be marked as dirty
  89148. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89149. */
  89150. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89151. /** @hidden */
  89152. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  89153. /** @hidden */
  89154. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89155. }
  89156. }
  89157. declare module BABYLON {
  89158. /**
  89159. * Set of assets to keep when moving a scene into an asset container.
  89160. */
  89161. export class KeepAssets extends AbstractScene {
  89162. }
  89163. /**
  89164. * Container with a set of assets that can be added or removed from a scene.
  89165. */
  89166. export class AssetContainer extends AbstractScene {
  89167. /**
  89168. * The scene the AssetContainer belongs to.
  89169. */
  89170. scene: Scene;
  89171. /**
  89172. * Instantiates an AssetContainer.
  89173. * @param scene The scene the AssetContainer belongs to.
  89174. */
  89175. constructor(scene: Scene);
  89176. /**
  89177. * Adds all the assets from the container to the scene.
  89178. */
  89179. addAllToScene(): void;
  89180. /**
  89181. * Removes all the assets in the container from the scene
  89182. */
  89183. removeAllFromScene(): void;
  89184. /**
  89185. * Disposes all the assets in the container
  89186. */
  89187. dispose(): void;
  89188. private _moveAssets;
  89189. /**
  89190. * Removes all the assets contained in the scene and adds them to the container.
  89191. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89192. */
  89193. moveAllFromScene(keepAssets?: KeepAssets): void;
  89194. /**
  89195. * 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.
  89196. * @returns the root mesh
  89197. */
  89198. createRootMesh(): Mesh;
  89199. }
  89200. }
  89201. declare module BABYLON {
  89202. /**
  89203. * Defines how the parser contract is defined.
  89204. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89205. */
  89206. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89207. /**
  89208. * Defines how the individual parser contract is defined.
  89209. * These parser can parse an individual asset
  89210. */
  89211. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89212. /**
  89213. * Base class of the scene acting as a container for the different elements composing a scene.
  89214. * This class is dynamically extended by the different components of the scene increasing
  89215. * flexibility and reducing coupling
  89216. */
  89217. export abstract class AbstractScene {
  89218. /**
  89219. * Stores the list of available parsers in the application.
  89220. */
  89221. private static _BabylonFileParsers;
  89222. /**
  89223. * Stores the list of available individual parsers in the application.
  89224. */
  89225. private static _IndividualBabylonFileParsers;
  89226. /**
  89227. * Adds a parser in the list of available ones
  89228. * @param name Defines the name of the parser
  89229. * @param parser Defines the parser to add
  89230. */
  89231. static AddParser(name: string, parser: BabylonFileParser): void;
  89232. /**
  89233. * Gets a general parser from the list of avaialble ones
  89234. * @param name Defines the name of the parser
  89235. * @returns the requested parser or null
  89236. */
  89237. static GetParser(name: string): Nullable<BabylonFileParser>;
  89238. /**
  89239. * Adds n individual parser in the list of available ones
  89240. * @param name Defines the name of the parser
  89241. * @param parser Defines the parser to add
  89242. */
  89243. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89244. /**
  89245. * Gets an individual parser from the list of avaialble ones
  89246. * @param name Defines the name of the parser
  89247. * @returns the requested parser or null
  89248. */
  89249. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89250. /**
  89251. * Parser json data and populate both a scene and its associated container object
  89252. * @param jsonData Defines the data to parse
  89253. * @param scene Defines the scene to parse the data for
  89254. * @param container Defines the container attached to the parsing sequence
  89255. * @param rootUrl Defines the root url of the data
  89256. */
  89257. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89258. /**
  89259. * Gets the list of root nodes (ie. nodes with no parent)
  89260. */
  89261. rootNodes: Node[];
  89262. /** All of the cameras added to this scene
  89263. * @see http://doc.babylonjs.com/babylon101/cameras
  89264. */
  89265. cameras: Camera[];
  89266. /**
  89267. * All of the lights added to this scene
  89268. * @see http://doc.babylonjs.com/babylon101/lights
  89269. */
  89270. lights: Light[];
  89271. /**
  89272. * All of the (abstract) meshes added to this scene
  89273. */
  89274. meshes: AbstractMesh[];
  89275. /**
  89276. * The list of skeletons added to the scene
  89277. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89278. */
  89279. skeletons: Skeleton[];
  89280. /**
  89281. * All of the particle systems added to this scene
  89282. * @see http://doc.babylonjs.com/babylon101/particles
  89283. */
  89284. particleSystems: IParticleSystem[];
  89285. /**
  89286. * Gets a list of Animations associated with the scene
  89287. */
  89288. animations: Animation[];
  89289. /**
  89290. * All of the animation groups added to this scene
  89291. * @see http://doc.babylonjs.com/how_to/group
  89292. */
  89293. animationGroups: AnimationGroup[];
  89294. /**
  89295. * All of the multi-materials added to this scene
  89296. * @see http://doc.babylonjs.com/how_to/multi_materials
  89297. */
  89298. multiMaterials: MultiMaterial[];
  89299. /**
  89300. * All of the materials added to this scene
  89301. * In the context of a Scene, it is not supposed to be modified manually.
  89302. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89303. * Note also that the order of the Material wihin the array is not significant and might change.
  89304. * @see http://doc.babylonjs.com/babylon101/materials
  89305. */
  89306. materials: Material[];
  89307. /**
  89308. * The list of morph target managers added to the scene
  89309. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89310. */
  89311. morphTargetManagers: MorphTargetManager[];
  89312. /**
  89313. * The list of geometries used in the scene.
  89314. */
  89315. geometries: Geometry[];
  89316. /**
  89317. * All of the tranform nodes added to this scene
  89318. * In the context of a Scene, it is not supposed to be modified manually.
  89319. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89320. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89321. * @see http://doc.babylonjs.com/how_to/transformnode
  89322. */
  89323. transformNodes: TransformNode[];
  89324. /**
  89325. * ActionManagers available on the scene.
  89326. */
  89327. actionManagers: AbstractActionManager[];
  89328. /**
  89329. * Textures to keep.
  89330. */
  89331. textures: BaseTexture[];
  89332. }
  89333. }
  89334. declare module BABYLON {
  89335. /**
  89336. * Defines a sound that can be played in the application.
  89337. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89339. */
  89340. export class Sound {
  89341. /**
  89342. * The name of the sound in the scene.
  89343. */
  89344. name: string;
  89345. /**
  89346. * Does the sound autoplay once loaded.
  89347. */
  89348. autoplay: boolean;
  89349. /**
  89350. * Does the sound loop after it finishes playing once.
  89351. */
  89352. loop: boolean;
  89353. /**
  89354. * Does the sound use a custom attenuation curve to simulate the falloff
  89355. * happening when the source gets further away from the camera.
  89356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89357. */
  89358. useCustomAttenuation: boolean;
  89359. /**
  89360. * The sound track id this sound belongs to.
  89361. */
  89362. soundTrackId: number;
  89363. /**
  89364. * Is this sound currently played.
  89365. */
  89366. isPlaying: boolean;
  89367. /**
  89368. * Is this sound currently paused.
  89369. */
  89370. isPaused: boolean;
  89371. /**
  89372. * Does this sound enables spatial sound.
  89373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89374. */
  89375. spatialSound: boolean;
  89376. /**
  89377. * Define the reference distance the sound should be heard perfectly.
  89378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89379. */
  89380. refDistance: number;
  89381. /**
  89382. * Define the roll off factor of spatial sounds.
  89383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89384. */
  89385. rolloffFactor: number;
  89386. /**
  89387. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89389. */
  89390. maxDistance: number;
  89391. /**
  89392. * Define the distance attenuation model the sound will follow.
  89393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89394. */
  89395. distanceModel: string;
  89396. /**
  89397. * @hidden
  89398. * Back Compat
  89399. **/
  89400. onended: () => any;
  89401. /**
  89402. * Observable event when the current playing sound finishes.
  89403. */
  89404. onEndedObservable: Observable<Sound>;
  89405. private _panningModel;
  89406. private _playbackRate;
  89407. private _streaming;
  89408. private _startTime;
  89409. private _startOffset;
  89410. private _position;
  89411. /** @hidden */
  89412. _positionInEmitterSpace: boolean;
  89413. private _localDirection;
  89414. private _volume;
  89415. private _isReadyToPlay;
  89416. private _isDirectional;
  89417. private _readyToPlayCallback;
  89418. private _audioBuffer;
  89419. private _soundSource;
  89420. private _streamingSource;
  89421. private _soundPanner;
  89422. private _soundGain;
  89423. private _inputAudioNode;
  89424. private _outputAudioNode;
  89425. private _coneInnerAngle;
  89426. private _coneOuterAngle;
  89427. private _coneOuterGain;
  89428. private _scene;
  89429. private _connectedTransformNode;
  89430. private _customAttenuationFunction;
  89431. private _registerFunc;
  89432. private _isOutputConnected;
  89433. private _htmlAudioElement;
  89434. private _urlType;
  89435. /** @hidden */
  89436. static _SceneComponentInitialization: (scene: Scene) => void;
  89437. /**
  89438. * Create a sound and attach it to a scene
  89439. * @param name Name of your sound
  89440. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89441. * @param scene defines the scene the sound belongs to
  89442. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89443. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89444. */
  89445. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89446. /**
  89447. * Release the sound and its associated resources
  89448. */
  89449. dispose(): void;
  89450. /**
  89451. * Gets if the sounds is ready to be played or not.
  89452. * @returns true if ready, otherwise false
  89453. */
  89454. isReady(): boolean;
  89455. private _soundLoaded;
  89456. /**
  89457. * Sets the data of the sound from an audiobuffer
  89458. * @param audioBuffer The audioBuffer containing the data
  89459. */
  89460. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89461. /**
  89462. * Updates the current sounds options such as maxdistance, loop...
  89463. * @param options A JSON object containing values named as the object properties
  89464. */
  89465. updateOptions(options: any): void;
  89466. private _createSpatialParameters;
  89467. private _updateSpatialParameters;
  89468. /**
  89469. * Switch the panning model to HRTF:
  89470. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89472. */
  89473. switchPanningModelToHRTF(): void;
  89474. /**
  89475. * Switch the panning model to Equal Power:
  89476. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89478. */
  89479. switchPanningModelToEqualPower(): void;
  89480. private _switchPanningModel;
  89481. /**
  89482. * Connect this sound to a sound track audio node like gain...
  89483. * @param soundTrackAudioNode the sound track audio node to connect to
  89484. */
  89485. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89486. /**
  89487. * Transform this sound into a directional source
  89488. * @param coneInnerAngle Size of the inner cone in degree
  89489. * @param coneOuterAngle Size of the outer cone in degree
  89490. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89491. */
  89492. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89493. /**
  89494. * Gets or sets the inner angle for the directional cone.
  89495. */
  89496. /**
  89497. * Gets or sets the inner angle for the directional cone.
  89498. */
  89499. directionalConeInnerAngle: number;
  89500. /**
  89501. * Gets or sets the outer angle for the directional cone.
  89502. */
  89503. /**
  89504. * Gets or sets the outer angle for the directional cone.
  89505. */
  89506. directionalConeOuterAngle: number;
  89507. /**
  89508. * Sets the position of the emitter if spatial sound is enabled
  89509. * @param newPosition Defines the new posisiton
  89510. */
  89511. setPosition(newPosition: Vector3): void;
  89512. /**
  89513. * Sets the local direction of the emitter if spatial sound is enabled
  89514. * @param newLocalDirection Defines the new local direction
  89515. */
  89516. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89517. private _updateDirection;
  89518. /** @hidden */
  89519. updateDistanceFromListener(): void;
  89520. /**
  89521. * Sets a new custom attenuation function for the sound.
  89522. * @param callback Defines the function used for the attenuation
  89523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89524. */
  89525. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89526. /**
  89527. * Play the sound
  89528. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89529. * @param offset (optional) Start the sound setting it at a specific time
  89530. */
  89531. play(time?: number, offset?: number): void;
  89532. private _onended;
  89533. /**
  89534. * Stop the sound
  89535. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89536. */
  89537. stop(time?: number): void;
  89538. /**
  89539. * Put the sound in pause
  89540. */
  89541. pause(): void;
  89542. /**
  89543. * Sets a dedicated volume for this sounds
  89544. * @param newVolume Define the new volume of the sound
  89545. * @param time Define in how long the sound should be at this value
  89546. */
  89547. setVolume(newVolume: number, time?: number): void;
  89548. /**
  89549. * Set the sound play back rate
  89550. * @param newPlaybackRate Define the playback rate the sound should be played at
  89551. */
  89552. setPlaybackRate(newPlaybackRate: number): void;
  89553. /**
  89554. * Gets the volume of the sound.
  89555. * @returns the volume of the sound
  89556. */
  89557. getVolume(): number;
  89558. /**
  89559. * Attach the sound to a dedicated mesh
  89560. * @param transformNode The transform node to connect the sound with
  89561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89562. */
  89563. attachToMesh(transformNode: TransformNode): void;
  89564. /**
  89565. * Detach the sound from the previously attached mesh
  89566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89567. */
  89568. detachFromMesh(): void;
  89569. private _onRegisterAfterWorldMatrixUpdate;
  89570. /**
  89571. * Clone the current sound in the scene.
  89572. * @returns the new sound clone
  89573. */
  89574. clone(): Nullable<Sound>;
  89575. /**
  89576. * Gets the current underlying audio buffer containing the data
  89577. * @returns the audio buffer
  89578. */
  89579. getAudioBuffer(): Nullable<AudioBuffer>;
  89580. /**
  89581. * Serializes the Sound in a JSON representation
  89582. * @returns the JSON representation of the sound
  89583. */
  89584. serialize(): any;
  89585. /**
  89586. * Parse a JSON representation of a sound to innstantiate in a given scene
  89587. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89588. * @param scene Define the scene the new parsed sound should be created in
  89589. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89590. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89591. * @returns the newly parsed sound
  89592. */
  89593. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89594. }
  89595. }
  89596. declare module BABYLON {
  89597. /**
  89598. * This defines an action helpful to play a defined sound on a triggered action.
  89599. */
  89600. export class PlaySoundAction extends Action {
  89601. private _sound;
  89602. /**
  89603. * Instantiate the action
  89604. * @param triggerOptions defines the trigger options
  89605. * @param sound defines the sound to play
  89606. * @param condition defines the trigger related conditions
  89607. */
  89608. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89609. /** @hidden */
  89610. _prepare(): void;
  89611. /**
  89612. * Execute the action and play the sound.
  89613. */
  89614. execute(): void;
  89615. /**
  89616. * Serializes the actions and its related information.
  89617. * @param parent defines the object to serialize in
  89618. * @returns the serialized object
  89619. */
  89620. serialize(parent: any): any;
  89621. }
  89622. /**
  89623. * This defines an action helpful to stop a defined sound on a triggered action.
  89624. */
  89625. export class StopSoundAction extends Action {
  89626. private _sound;
  89627. /**
  89628. * Instantiate the action
  89629. * @param triggerOptions defines the trigger options
  89630. * @param sound defines the sound to stop
  89631. * @param condition defines the trigger related conditions
  89632. */
  89633. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89634. /** @hidden */
  89635. _prepare(): void;
  89636. /**
  89637. * Execute the action and stop the sound.
  89638. */
  89639. execute(): void;
  89640. /**
  89641. * Serializes the actions and its related information.
  89642. * @param parent defines the object to serialize in
  89643. * @returns the serialized object
  89644. */
  89645. serialize(parent: any): any;
  89646. }
  89647. }
  89648. declare module BABYLON {
  89649. /**
  89650. * This defines an action responsible to change the value of a property
  89651. * by interpolating between its current value and the newly set one once triggered.
  89652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89653. */
  89654. export class InterpolateValueAction extends Action {
  89655. /**
  89656. * Defines the path of the property where the value should be interpolated
  89657. */
  89658. propertyPath: string;
  89659. /**
  89660. * Defines the target value at the end of the interpolation.
  89661. */
  89662. value: any;
  89663. /**
  89664. * Defines the time it will take for the property to interpolate to the value.
  89665. */
  89666. duration: number;
  89667. /**
  89668. * Defines if the other scene animations should be stopped when the action has been triggered
  89669. */
  89670. stopOtherAnimations?: boolean;
  89671. /**
  89672. * Defines a callback raised once the interpolation animation has been done.
  89673. */
  89674. onInterpolationDone?: () => void;
  89675. /**
  89676. * Observable triggered once the interpolation animation has been done.
  89677. */
  89678. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89679. private _target;
  89680. private _effectiveTarget;
  89681. private _property;
  89682. /**
  89683. * Instantiate the action
  89684. * @param triggerOptions defines the trigger options
  89685. * @param target defines the object containing the value to interpolate
  89686. * @param propertyPath defines the path to the property in the target object
  89687. * @param value defines the target value at the end of the interpolation
  89688. * @param duration deines the time it will take for the property to interpolate to the value.
  89689. * @param condition defines the trigger related conditions
  89690. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89691. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89692. */
  89693. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89694. /** @hidden */
  89695. _prepare(): void;
  89696. /**
  89697. * Execute the action starts the value interpolation.
  89698. */
  89699. execute(): void;
  89700. /**
  89701. * Serializes the actions and its related information.
  89702. * @param parent defines the object to serialize in
  89703. * @returns the serialized object
  89704. */
  89705. serialize(parent: any): any;
  89706. }
  89707. }
  89708. declare module BABYLON {
  89709. /**
  89710. * Options allowed during the creation of a sound track.
  89711. */
  89712. export interface ISoundTrackOptions {
  89713. /**
  89714. * The volume the sound track should take during creation
  89715. */
  89716. volume?: number;
  89717. /**
  89718. * Define if the sound track is the main sound track of the scene
  89719. */
  89720. mainTrack?: boolean;
  89721. }
  89722. /**
  89723. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  89724. * It will be also used in a future release to apply effects on a specific track.
  89725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89726. */
  89727. export class SoundTrack {
  89728. /**
  89729. * The unique identifier of the sound track in the scene.
  89730. */
  89731. id: number;
  89732. /**
  89733. * The list of sounds included in the sound track.
  89734. */
  89735. soundCollection: Array<Sound>;
  89736. private _outputAudioNode;
  89737. private _scene;
  89738. private _isMainTrack;
  89739. private _connectedAnalyser;
  89740. private _options;
  89741. private _isInitialized;
  89742. /**
  89743. * Creates a new sound track.
  89744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89745. * @param scene Define the scene the sound track belongs to
  89746. * @param options
  89747. */
  89748. constructor(scene: Scene, options?: ISoundTrackOptions);
  89749. private _initializeSoundTrackAudioGraph;
  89750. /**
  89751. * Release the sound track and its associated resources
  89752. */
  89753. dispose(): void;
  89754. /**
  89755. * Adds a sound to this sound track
  89756. * @param sound define the cound to add
  89757. * @ignoreNaming
  89758. */
  89759. AddSound(sound: Sound): void;
  89760. /**
  89761. * Removes a sound to this sound track
  89762. * @param sound define the cound to remove
  89763. * @ignoreNaming
  89764. */
  89765. RemoveSound(sound: Sound): void;
  89766. /**
  89767. * Set a global volume for the full sound track.
  89768. * @param newVolume Define the new volume of the sound track
  89769. */
  89770. setVolume(newVolume: number): void;
  89771. /**
  89772. * Switch the panning model to HRTF:
  89773. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89775. */
  89776. switchPanningModelToHRTF(): void;
  89777. /**
  89778. * Switch the panning model to Equal Power:
  89779. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89781. */
  89782. switchPanningModelToEqualPower(): void;
  89783. /**
  89784. * Connect the sound track to an audio analyser allowing some amazing
  89785. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89787. * @param analyser The analyser to connect to the engine
  89788. */
  89789. connectToAnalyser(analyser: Analyser): void;
  89790. }
  89791. }
  89792. declare module BABYLON {
  89793. interface AbstractScene {
  89794. /**
  89795. * The list of sounds used in the scene.
  89796. */
  89797. sounds: Nullable<Array<Sound>>;
  89798. }
  89799. interface Scene {
  89800. /**
  89801. * @hidden
  89802. * Backing field
  89803. */
  89804. _mainSoundTrack: SoundTrack;
  89805. /**
  89806. * The main sound track played by the scene.
  89807. * It cotains your primary collection of sounds.
  89808. */
  89809. mainSoundTrack: SoundTrack;
  89810. /**
  89811. * The list of sound tracks added to the scene
  89812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89813. */
  89814. soundTracks: Nullable<Array<SoundTrack>>;
  89815. /**
  89816. * Gets a sound using a given name
  89817. * @param name defines the name to search for
  89818. * @return the found sound or null if not found at all.
  89819. */
  89820. getSoundByName(name: string): Nullable<Sound>;
  89821. /**
  89822. * Gets or sets if audio support is enabled
  89823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89824. */
  89825. audioEnabled: boolean;
  89826. /**
  89827. * Gets or sets if audio will be output to headphones
  89828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89829. */
  89830. headphone: boolean;
  89831. }
  89832. /**
  89833. * Defines the sound scene component responsible to manage any sounds
  89834. * in a given scene.
  89835. */
  89836. export class AudioSceneComponent implements ISceneSerializableComponent {
  89837. /**
  89838. * The component name helpfull to identify the component in the list of scene components.
  89839. */
  89840. readonly name: string;
  89841. /**
  89842. * The scene the component belongs to.
  89843. */
  89844. scene: Scene;
  89845. private _audioEnabled;
  89846. /**
  89847. * Gets whether audio is enabled or not.
  89848. * Please use related enable/disable method to switch state.
  89849. */
  89850. readonly audioEnabled: boolean;
  89851. private _headphone;
  89852. /**
  89853. * Gets whether audio is outputing to headphone or not.
  89854. * Please use the according Switch methods to change output.
  89855. */
  89856. readonly headphone: boolean;
  89857. /**
  89858. * Creates a new instance of the component for the given scene
  89859. * @param scene Defines the scene to register the component in
  89860. */
  89861. constructor(scene: Scene);
  89862. /**
  89863. * Registers the component in a given scene
  89864. */
  89865. register(): void;
  89866. /**
  89867. * Rebuilds the elements related to this component in case of
  89868. * context lost for instance.
  89869. */
  89870. rebuild(): void;
  89871. /**
  89872. * Serializes the component data to the specified json object
  89873. * @param serializationObject The object to serialize to
  89874. */
  89875. serialize(serializationObject: any): void;
  89876. /**
  89877. * Adds all the element from the container to the scene
  89878. * @param container the container holding the elements
  89879. */
  89880. addFromContainer(container: AbstractScene): void;
  89881. /**
  89882. * Removes all the elements in the container from the scene
  89883. * @param container contains the elements to remove
  89884. */
  89885. removeFromContainer(container: AbstractScene): void;
  89886. /**
  89887. * Disposes the component and the associated ressources.
  89888. */
  89889. dispose(): void;
  89890. /**
  89891. * Disables audio in the associated scene.
  89892. */
  89893. disableAudio(): void;
  89894. /**
  89895. * Enables audio in the associated scene.
  89896. */
  89897. enableAudio(): void;
  89898. /**
  89899. * Switch audio to headphone output.
  89900. */
  89901. switchAudioModeForHeadphones(): void;
  89902. /**
  89903. * Switch audio to normal speakers.
  89904. */
  89905. switchAudioModeForNormalSpeakers(): void;
  89906. private _afterRender;
  89907. }
  89908. }
  89909. declare module BABYLON {
  89910. /**
  89911. * Wraps one or more Sound objects and selects one with random weight for playback.
  89912. */
  89913. export class WeightedSound {
  89914. /** When true a Sound will be selected and played when the current playing Sound completes. */
  89915. loop: boolean;
  89916. private _coneInnerAngle;
  89917. private _coneOuterAngle;
  89918. private _volume;
  89919. /** A Sound is currently playing. */
  89920. isPlaying: boolean;
  89921. /** A Sound is currently paused. */
  89922. isPaused: boolean;
  89923. private _sounds;
  89924. private _weights;
  89925. private _currentIndex?;
  89926. /**
  89927. * Creates a new WeightedSound from the list of sounds given.
  89928. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  89929. * @param sounds Array of Sounds that will be selected from.
  89930. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  89931. */
  89932. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  89933. /**
  89934. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  89935. */
  89936. /**
  89937. * The size of cone in degress for a directional sound in which there will be no attenuation.
  89938. */
  89939. directionalConeInnerAngle: number;
  89940. /**
  89941. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89942. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89943. */
  89944. /**
  89945. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89946. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89947. */
  89948. directionalConeOuterAngle: number;
  89949. /**
  89950. * Playback volume.
  89951. */
  89952. /**
  89953. * Playback volume.
  89954. */
  89955. volume: number;
  89956. private _onended;
  89957. /**
  89958. * Suspend playback
  89959. */
  89960. pause(): void;
  89961. /**
  89962. * Stop playback
  89963. */
  89964. stop(): void;
  89965. /**
  89966. * Start playback.
  89967. * @param startOffset Position the clip head at a specific time in seconds.
  89968. */
  89969. play(startOffset?: number): void;
  89970. }
  89971. }
  89972. declare module BABYLON {
  89973. /**
  89974. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  89975. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  89976. */
  89977. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  89978. /**
  89979. * Gets the name of the behavior.
  89980. */
  89981. readonly name: string;
  89982. /**
  89983. * The easing function used by animations
  89984. */
  89985. static EasingFunction: BackEase;
  89986. /**
  89987. * The easing mode used by animations
  89988. */
  89989. static EasingMode: number;
  89990. /**
  89991. * The duration of the animation, in milliseconds
  89992. */
  89993. transitionDuration: number;
  89994. /**
  89995. * Length of the distance animated by the transition when lower radius is reached
  89996. */
  89997. lowerRadiusTransitionRange: number;
  89998. /**
  89999. * Length of the distance animated by the transition when upper radius is reached
  90000. */
  90001. upperRadiusTransitionRange: number;
  90002. private _autoTransitionRange;
  90003. /**
  90004. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90005. */
  90006. /**
  90007. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90008. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90009. */
  90010. autoTransitionRange: boolean;
  90011. private _attachedCamera;
  90012. private _onAfterCheckInputsObserver;
  90013. private _onMeshTargetChangedObserver;
  90014. /**
  90015. * Initializes the behavior.
  90016. */
  90017. init(): void;
  90018. /**
  90019. * Attaches the behavior to its arc rotate camera.
  90020. * @param camera Defines the camera to attach the behavior to
  90021. */
  90022. attach(camera: ArcRotateCamera): void;
  90023. /**
  90024. * Detaches the behavior from its current arc rotate camera.
  90025. */
  90026. detach(): void;
  90027. private _radiusIsAnimating;
  90028. private _radiusBounceTransition;
  90029. private _animatables;
  90030. private _cachedWheelPrecision;
  90031. /**
  90032. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  90033. * @param radiusLimit The limit to check against.
  90034. * @return Bool to indicate if at limit.
  90035. */
  90036. private _isRadiusAtLimit;
  90037. /**
  90038. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90039. * @param radiusDelta The delta by which to animate to. Can be negative.
  90040. */
  90041. private _applyBoundRadiusAnimation;
  90042. /**
  90043. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90044. */
  90045. protected _clearAnimationLocks(): void;
  90046. /**
  90047. * Stops and removes all animations that have been applied to the camera
  90048. */
  90049. stopAllAnimations(): void;
  90050. }
  90051. }
  90052. declare module BABYLON {
  90053. /**
  90054. * 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.
  90055. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90056. */
  90057. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90058. /**
  90059. * Gets the name of the behavior.
  90060. */
  90061. readonly name: string;
  90062. private _mode;
  90063. private _radiusScale;
  90064. private _positionScale;
  90065. private _defaultElevation;
  90066. private _elevationReturnTime;
  90067. private _elevationReturnWaitTime;
  90068. private _zoomStopsAnimation;
  90069. private _framingTime;
  90070. /**
  90071. * The easing function used by animations
  90072. */
  90073. static EasingFunction: ExponentialEase;
  90074. /**
  90075. * The easing mode used by animations
  90076. */
  90077. static EasingMode: number;
  90078. /**
  90079. * Sets the current mode used by the behavior
  90080. */
  90081. /**
  90082. * Gets current mode used by the behavior.
  90083. */
  90084. mode: number;
  90085. /**
  90086. * Sets the scale applied to the radius (1 by default)
  90087. */
  90088. /**
  90089. * Gets the scale applied to the radius
  90090. */
  90091. radiusScale: number;
  90092. /**
  90093. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90094. */
  90095. /**
  90096. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90097. */
  90098. positionScale: number;
  90099. /**
  90100. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90101. * behaviour is triggered, in radians.
  90102. */
  90103. /**
  90104. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90105. * behaviour is triggered, in radians.
  90106. */
  90107. defaultElevation: number;
  90108. /**
  90109. * Sets the time (in milliseconds) taken to return to the default beta position.
  90110. * Negative value indicates camera should not return to default.
  90111. */
  90112. /**
  90113. * Gets the time (in milliseconds) taken to return to the default beta position.
  90114. * Negative value indicates camera should not return to default.
  90115. */
  90116. elevationReturnTime: number;
  90117. /**
  90118. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90119. */
  90120. /**
  90121. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90122. */
  90123. elevationReturnWaitTime: number;
  90124. /**
  90125. * Sets the flag that indicates if user zooming should stop animation.
  90126. */
  90127. /**
  90128. * Gets the flag that indicates if user zooming should stop animation.
  90129. */
  90130. zoomStopsAnimation: boolean;
  90131. /**
  90132. * Sets the transition time when framing the mesh, in milliseconds
  90133. */
  90134. /**
  90135. * Gets the transition time when framing the mesh, in milliseconds
  90136. */
  90137. framingTime: number;
  90138. /**
  90139. * Define if the behavior should automatically change the configured
  90140. * camera limits and sensibilities.
  90141. */
  90142. autoCorrectCameraLimitsAndSensibility: boolean;
  90143. private _onPrePointerObservableObserver;
  90144. private _onAfterCheckInputsObserver;
  90145. private _onMeshTargetChangedObserver;
  90146. private _attachedCamera;
  90147. private _isPointerDown;
  90148. private _lastInteractionTime;
  90149. /**
  90150. * Initializes the behavior.
  90151. */
  90152. init(): void;
  90153. /**
  90154. * Attaches the behavior to its arc rotate camera.
  90155. * @param camera Defines the camera to attach the behavior to
  90156. */
  90157. attach(camera: ArcRotateCamera): void;
  90158. /**
  90159. * Detaches the behavior from its current arc rotate camera.
  90160. */
  90161. detach(): void;
  90162. private _animatables;
  90163. private _betaIsAnimating;
  90164. private _betaTransition;
  90165. private _radiusTransition;
  90166. private _vectorTransition;
  90167. /**
  90168. * Targets the given mesh and updates zoom level accordingly.
  90169. * @param mesh The mesh to target.
  90170. * @param radius Optional. If a cached radius position already exists, overrides default.
  90171. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90172. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90173. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90174. */
  90175. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90176. /**
  90177. * Targets the given mesh with its children and updates zoom level accordingly.
  90178. * @param mesh The mesh to target.
  90179. * @param radius Optional. If a cached radius position already exists, overrides default.
  90180. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90181. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90182. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90183. */
  90184. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90185. /**
  90186. * Targets the given meshes with their children and updates zoom level accordingly.
  90187. * @param meshes The mesh to target.
  90188. * @param radius Optional. If a cached radius position already exists, overrides default.
  90189. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90190. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90191. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90192. */
  90193. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90194. /**
  90195. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90196. * @param minimumWorld Determines the smaller position of the bounding box extend
  90197. * @param maximumWorld Determines the bigger position of the bounding box extend
  90198. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90199. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90200. */
  90201. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90202. /**
  90203. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90204. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90205. * frustum width.
  90206. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90207. * to fully enclose the mesh in the viewing frustum.
  90208. */
  90209. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90210. /**
  90211. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90212. * is automatically returned to its default position (expected to be above ground plane).
  90213. */
  90214. private _maintainCameraAboveGround;
  90215. /**
  90216. * Returns the frustum slope based on the canvas ratio and camera FOV
  90217. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90218. */
  90219. private _getFrustumSlope;
  90220. /**
  90221. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90222. */
  90223. private _clearAnimationLocks;
  90224. /**
  90225. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90226. */
  90227. private _applyUserInteraction;
  90228. /**
  90229. * Stops and removes all animations that have been applied to the camera
  90230. */
  90231. stopAllAnimations(): void;
  90232. /**
  90233. * Gets a value indicating if the user is moving the camera
  90234. */
  90235. readonly isUserIsMoving: boolean;
  90236. /**
  90237. * The camera can move all the way towards the mesh.
  90238. */
  90239. static IgnoreBoundsSizeMode: number;
  90240. /**
  90241. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90242. */
  90243. static FitFrustumSidesMode: number;
  90244. }
  90245. }
  90246. declare module BABYLON {
  90247. /**
  90248. * Manage the pointers inputs to control an arc rotate camera.
  90249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90250. */
  90251. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90252. /**
  90253. * Defines the camera the input is attached to.
  90254. */
  90255. camera: ArcRotateCamera;
  90256. /**
  90257. * Defines the buttons associated with the input to handle camera move.
  90258. */
  90259. buttons: number[];
  90260. /**
  90261. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90262. */
  90263. angularSensibilityX: number;
  90264. /**
  90265. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90266. */
  90267. angularSensibilityY: number;
  90268. /**
  90269. * Defines the pointer pinch precision or how fast is the camera zooming.
  90270. */
  90271. pinchPrecision: number;
  90272. /**
  90273. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90274. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90275. */
  90276. pinchDeltaPercentage: number;
  90277. /**
  90278. * Defines the pointer panning sensibility or how fast is the camera moving.
  90279. */
  90280. panningSensibility: number;
  90281. /**
  90282. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90283. */
  90284. multiTouchPanning: boolean;
  90285. /**
  90286. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90287. */
  90288. multiTouchPanAndZoom: boolean;
  90289. /**
  90290. * Revers pinch action direction.
  90291. */
  90292. pinchInwards: boolean;
  90293. private _isPanClick;
  90294. private _pointerInput;
  90295. private _observer;
  90296. private _onMouseMove;
  90297. private _onGestureStart;
  90298. private _onGesture;
  90299. private _MSGestureHandler;
  90300. private _onLostFocus;
  90301. private _onContextMenu;
  90302. /**
  90303. * Attach the input controls to a specific dom element to get the input from.
  90304. * @param element Defines the element the controls should be listened from
  90305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90306. */
  90307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90308. /**
  90309. * Detach the current controls from the specified dom element.
  90310. * @param element Defines the element to stop listening the inputs from
  90311. */
  90312. detachControl(element: Nullable<HTMLElement>): void;
  90313. /**
  90314. * Gets the class name of the current intput.
  90315. * @returns the class name
  90316. */
  90317. getClassName(): string;
  90318. /**
  90319. * Get the friendly name associated with the input class.
  90320. * @returns the input friendly name
  90321. */
  90322. getSimpleName(): string;
  90323. }
  90324. }
  90325. declare module BABYLON {
  90326. /**
  90327. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90329. */
  90330. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90331. /**
  90332. * Defines the camera the input is attached to.
  90333. */
  90334. camera: ArcRotateCamera;
  90335. /**
  90336. * Defines the list of key codes associated with the up action (increase alpha)
  90337. */
  90338. keysUp: number[];
  90339. /**
  90340. * Defines the list of key codes associated with the down action (decrease alpha)
  90341. */
  90342. keysDown: number[];
  90343. /**
  90344. * Defines the list of key codes associated with the left action (increase beta)
  90345. */
  90346. keysLeft: number[];
  90347. /**
  90348. * Defines the list of key codes associated with the right action (decrease beta)
  90349. */
  90350. keysRight: number[];
  90351. /**
  90352. * Defines the list of key codes associated with the reset action.
  90353. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90354. */
  90355. keysReset: number[];
  90356. /**
  90357. * Defines the panning sensibility of the inputs.
  90358. * (How fast is the camera paning)
  90359. */
  90360. panningSensibility: number;
  90361. /**
  90362. * Defines the zooming sensibility of the inputs.
  90363. * (How fast is the camera zooming)
  90364. */
  90365. zoomingSensibility: number;
  90366. /**
  90367. * Defines wether maintaining the alt key down switch the movement mode from
  90368. * orientation to zoom.
  90369. */
  90370. useAltToZoom: boolean;
  90371. /**
  90372. * Rotation speed of the camera
  90373. */
  90374. angularSpeed: number;
  90375. private _keys;
  90376. private _ctrlPressed;
  90377. private _altPressed;
  90378. private _onCanvasBlurObserver;
  90379. private _onKeyboardObserver;
  90380. private _engine;
  90381. private _scene;
  90382. /**
  90383. * Attach the input controls to a specific dom element to get the input from.
  90384. * @param element Defines the element the controls should be listened from
  90385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90386. */
  90387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90388. /**
  90389. * Detach the current controls from the specified dom element.
  90390. * @param element Defines the element to stop listening the inputs from
  90391. */
  90392. detachControl(element: Nullable<HTMLElement>): void;
  90393. /**
  90394. * Update the current camera state depending on the inputs that have been used this frame.
  90395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90396. */
  90397. checkInputs(): void;
  90398. /**
  90399. * Gets the class name of the current intput.
  90400. * @returns the class name
  90401. */
  90402. getClassName(): string;
  90403. /**
  90404. * Get the friendly name associated with the input class.
  90405. * @returns the input friendly name
  90406. */
  90407. getSimpleName(): string;
  90408. }
  90409. }
  90410. declare module BABYLON {
  90411. /**
  90412. * Manage the mouse wheel inputs to control an arc rotate camera.
  90413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90414. */
  90415. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90416. /**
  90417. * Defines the camera the input is attached to.
  90418. */
  90419. camera: ArcRotateCamera;
  90420. /**
  90421. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90422. */
  90423. wheelPrecision: number;
  90424. /**
  90425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90427. */
  90428. wheelDeltaPercentage: number;
  90429. private _wheel;
  90430. private _observer;
  90431. /**
  90432. * Attach the input controls to a specific dom element to get the input from.
  90433. * @param element Defines the element the controls should be listened from
  90434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90435. */
  90436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90437. /**
  90438. * Detach the current controls from the specified dom element.
  90439. * @param element Defines the element to stop listening the inputs from
  90440. */
  90441. detachControl(element: Nullable<HTMLElement>): void;
  90442. /**
  90443. * Gets the class name of the current intput.
  90444. * @returns the class name
  90445. */
  90446. getClassName(): string;
  90447. /**
  90448. * Get the friendly name associated with the input class.
  90449. * @returns the input friendly name
  90450. */
  90451. getSimpleName(): string;
  90452. }
  90453. }
  90454. declare module BABYLON {
  90455. /**
  90456. * Default Inputs manager for the ArcRotateCamera.
  90457. * It groups all the default supported inputs for ease of use.
  90458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90459. */
  90460. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90461. /**
  90462. * Instantiates a new ArcRotateCameraInputsManager.
  90463. * @param camera Defines the camera the inputs belong to
  90464. */
  90465. constructor(camera: ArcRotateCamera);
  90466. /**
  90467. * Add mouse wheel input support to the input manager.
  90468. * @returns the current input manager
  90469. */
  90470. addMouseWheel(): ArcRotateCameraInputsManager;
  90471. /**
  90472. * Add pointers input support to the input manager.
  90473. * @returns the current input manager
  90474. */
  90475. addPointers(): ArcRotateCameraInputsManager;
  90476. /**
  90477. * Add keyboard input support to the input manager.
  90478. * @returns the current input manager
  90479. */
  90480. addKeyboard(): ArcRotateCameraInputsManager;
  90481. }
  90482. }
  90483. declare module BABYLON {
  90484. /**
  90485. * This represents an orbital type of camera.
  90486. *
  90487. * 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.
  90488. * 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.
  90489. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90490. */
  90491. export class ArcRotateCamera extends TargetCamera {
  90492. /**
  90493. * Defines the rotation angle of the camera along the longitudinal axis.
  90494. */
  90495. alpha: number;
  90496. /**
  90497. * Defines the rotation angle of the camera along the latitudinal axis.
  90498. */
  90499. beta: number;
  90500. /**
  90501. * Defines the radius of the camera from it s target point.
  90502. */
  90503. radius: number;
  90504. protected _target: Vector3;
  90505. protected _targetHost: Nullable<AbstractMesh>;
  90506. /**
  90507. * Defines the target point of the camera.
  90508. * The camera looks towards it form the radius distance.
  90509. */
  90510. target: Vector3;
  90511. /**
  90512. * Current inertia value on the longitudinal axis.
  90513. * The bigger this number the longer it will take for the camera to stop.
  90514. */
  90515. inertialAlphaOffset: number;
  90516. /**
  90517. * Current inertia value on the latitudinal axis.
  90518. * The bigger this number the longer it will take for the camera to stop.
  90519. */
  90520. inertialBetaOffset: number;
  90521. /**
  90522. * Current inertia value on the radius axis.
  90523. * The bigger this number the longer it will take for the camera to stop.
  90524. */
  90525. inertialRadiusOffset: number;
  90526. /**
  90527. * Minimum allowed angle on the longitudinal axis.
  90528. * This can help limiting how the Camera is able to move in the scene.
  90529. */
  90530. lowerAlphaLimit: Nullable<number>;
  90531. /**
  90532. * Maximum allowed angle on the longitudinal axis.
  90533. * This can help limiting how the Camera is able to move in the scene.
  90534. */
  90535. upperAlphaLimit: Nullable<number>;
  90536. /**
  90537. * Minimum allowed angle on the latitudinal axis.
  90538. * This can help limiting how the Camera is able to move in the scene.
  90539. */
  90540. lowerBetaLimit: number;
  90541. /**
  90542. * Maximum allowed angle on the latitudinal axis.
  90543. * This can help limiting how the Camera is able to move in the scene.
  90544. */
  90545. upperBetaLimit: number;
  90546. /**
  90547. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90548. * This can help limiting how the Camera is able to move in the scene.
  90549. */
  90550. lowerRadiusLimit: Nullable<number>;
  90551. /**
  90552. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90553. * This can help limiting how the Camera is able to move in the scene.
  90554. */
  90555. upperRadiusLimit: Nullable<number>;
  90556. /**
  90557. * Defines the current inertia value used during panning of the camera along the X axis.
  90558. */
  90559. inertialPanningX: number;
  90560. /**
  90561. * Defines the current inertia value used during panning of the camera along the Y axis.
  90562. */
  90563. inertialPanningY: number;
  90564. /**
  90565. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90566. * Basically if your fingers moves away from more than this distance you will be considered
  90567. * in pinch mode.
  90568. */
  90569. pinchToPanMaxDistance: number;
  90570. /**
  90571. * Defines the maximum distance the camera can pan.
  90572. * This could help keeping the cammera always in your scene.
  90573. */
  90574. panningDistanceLimit: Nullable<number>;
  90575. /**
  90576. * Defines the target of the camera before paning.
  90577. */
  90578. panningOriginTarget: Vector3;
  90579. /**
  90580. * Defines the value of the inertia used during panning.
  90581. * 0 would mean stop inertia and one would mean no decelleration at all.
  90582. */
  90583. panningInertia: number;
  90584. /**
  90585. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90586. */
  90587. angularSensibilityX: number;
  90588. /**
  90589. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90590. */
  90591. angularSensibilityY: number;
  90592. /**
  90593. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90594. */
  90595. pinchPrecision: number;
  90596. /**
  90597. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90598. * It will be used instead of pinchDeltaPrecision if different from 0.
  90599. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90600. */
  90601. pinchDeltaPercentage: number;
  90602. /**
  90603. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90604. */
  90605. panningSensibility: number;
  90606. /**
  90607. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90608. */
  90609. keysUp: number[];
  90610. /**
  90611. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90612. */
  90613. keysDown: number[];
  90614. /**
  90615. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90616. */
  90617. keysLeft: number[];
  90618. /**
  90619. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90620. */
  90621. keysRight: number[];
  90622. /**
  90623. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90624. */
  90625. wheelPrecision: number;
  90626. /**
  90627. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90628. * It will be used instead of pinchDeltaPrecision if different from 0.
  90629. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90630. */
  90631. wheelDeltaPercentage: number;
  90632. /**
  90633. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90634. */
  90635. zoomOnFactor: number;
  90636. /**
  90637. * Defines a screen offset for the camera position.
  90638. */
  90639. targetScreenOffset: Vector2;
  90640. /**
  90641. * Allows the camera to be completely reversed.
  90642. * If false the camera can not arrive upside down.
  90643. */
  90644. allowUpsideDown: boolean;
  90645. /**
  90646. * Define if double tap/click is used to restore the previously saved state of the camera.
  90647. */
  90648. useInputToRestoreState: boolean;
  90649. /** @hidden */
  90650. _viewMatrix: Matrix;
  90651. /** @hidden */
  90652. _useCtrlForPanning: boolean;
  90653. /** @hidden */
  90654. _panningMouseButton: number;
  90655. /**
  90656. * Defines the input associated to the camera.
  90657. */
  90658. inputs: ArcRotateCameraInputsManager;
  90659. /** @hidden */
  90660. _reset: () => void;
  90661. /**
  90662. * Defines the allowed panning axis.
  90663. */
  90664. panningAxis: Vector3;
  90665. protected _localDirection: Vector3;
  90666. protected _transformedDirection: Vector3;
  90667. private _bouncingBehavior;
  90668. /**
  90669. * Gets the bouncing behavior of the camera if it has been enabled.
  90670. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90671. */
  90672. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90673. /**
  90674. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90675. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90676. */
  90677. useBouncingBehavior: boolean;
  90678. private _framingBehavior;
  90679. /**
  90680. * Gets the framing behavior of the camera if it has been enabled.
  90681. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90682. */
  90683. readonly framingBehavior: Nullable<FramingBehavior>;
  90684. /**
  90685. * Defines if the framing behavior of the camera is enabled on the camera.
  90686. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90687. */
  90688. useFramingBehavior: boolean;
  90689. private _autoRotationBehavior;
  90690. /**
  90691. * Gets the auto rotation behavior of the camera if it has been enabled.
  90692. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90693. */
  90694. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90695. /**
  90696. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90697. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90698. */
  90699. useAutoRotationBehavior: boolean;
  90700. /**
  90701. * Observable triggered when the mesh target has been changed on the camera.
  90702. */
  90703. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90704. /**
  90705. * Event raised when the camera is colliding with a mesh.
  90706. */
  90707. onCollide: (collidedMesh: AbstractMesh) => void;
  90708. /**
  90709. * Defines whether the camera should check collision with the objects oh the scene.
  90710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  90711. */
  90712. checkCollisions: boolean;
  90713. /**
  90714. * Defines the collision radius of the camera.
  90715. * This simulates a sphere around the camera.
  90716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  90717. */
  90718. collisionRadius: Vector3;
  90719. protected _collider: Collider;
  90720. protected _previousPosition: Vector3;
  90721. protected _collisionVelocity: Vector3;
  90722. protected _newPosition: Vector3;
  90723. protected _previousAlpha: number;
  90724. protected _previousBeta: number;
  90725. protected _previousRadius: number;
  90726. protected _collisionTriggered: boolean;
  90727. protected _targetBoundingCenter: Nullable<Vector3>;
  90728. private _computationVector;
  90729. private _tempAxisVector;
  90730. private _tempAxisRotationMatrix;
  90731. /**
  90732. * Instantiates a new ArcRotateCamera in a given scene
  90733. * @param name Defines the name of the camera
  90734. * @param alpha Defines the camera rotation along the logitudinal axis
  90735. * @param beta Defines the camera rotation along the latitudinal axis
  90736. * @param radius Defines the camera distance from its target
  90737. * @param target Defines the camera target
  90738. * @param scene Defines the scene the camera belongs to
  90739. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90740. */
  90741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90742. /** @hidden */
  90743. _initCache(): void;
  90744. /** @hidden */
  90745. _updateCache(ignoreParentClass?: boolean): void;
  90746. protected _getTargetPosition(): Vector3;
  90747. private _storedAlpha;
  90748. private _storedBeta;
  90749. private _storedRadius;
  90750. private _storedTarget;
  90751. /**
  90752. * Stores the current state of the camera (alpha, beta, radius and target)
  90753. * @returns the camera itself
  90754. */
  90755. storeState(): Camera;
  90756. /**
  90757. * @hidden
  90758. * Restored camera state. You must call storeState() first
  90759. */
  90760. _restoreStateValues(): boolean;
  90761. /** @hidden */
  90762. _isSynchronizedViewMatrix(): boolean;
  90763. /**
  90764. * Attached controls to the current camera.
  90765. * @param element Defines the element the controls should be listened from
  90766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90767. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  90768. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  90769. */
  90770. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  90771. /**
  90772. * Detach the current controls from the camera.
  90773. * The camera will stop reacting to inputs.
  90774. * @param element Defines the element to stop listening the inputs from
  90775. */
  90776. detachControl(element: HTMLElement): void;
  90777. /** @hidden */
  90778. _checkInputs(): void;
  90779. protected _checkLimits(): void;
  90780. /**
  90781. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  90782. */
  90783. rebuildAnglesAndRadius(): void;
  90784. /**
  90785. * Use a position to define the current camera related information like aplha, beta and radius
  90786. * @param position Defines the position to set the camera at
  90787. */
  90788. setPosition(position: Vector3): void;
  90789. /**
  90790. * Defines the target the camera should look at.
  90791. * This will automatically adapt alpha beta and radius to fit within the new target.
  90792. * @param target Defines the new target as a Vector or a mesh
  90793. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  90794. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  90795. */
  90796. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  90797. /** @hidden */
  90798. _getViewMatrix(): Matrix;
  90799. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  90800. /**
  90801. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  90802. * @param meshes Defines the mesh to zoom on
  90803. * @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)
  90804. */
  90805. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  90806. /**
  90807. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  90808. * The target will be changed but the radius
  90809. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  90810. * @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)
  90811. */
  90812. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  90813. min: Vector3;
  90814. max: Vector3;
  90815. distance: number;
  90816. }, doNotUpdateMaxZ?: boolean): void;
  90817. /**
  90818. * @override
  90819. * Override Camera.createRigCamera
  90820. */
  90821. createRigCamera(name: string, cameraIndex: number): Camera;
  90822. /**
  90823. * @hidden
  90824. * @override
  90825. * Override Camera._updateRigCameras
  90826. */
  90827. _updateRigCameras(): void;
  90828. /**
  90829. * Destroy the camera and release the current resources hold by it.
  90830. */
  90831. dispose(): void;
  90832. /**
  90833. * Gets the current object class name.
  90834. * @return the class name
  90835. */
  90836. getClassName(): string;
  90837. }
  90838. }
  90839. declare module BABYLON {
  90840. /**
  90841. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  90842. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90843. */
  90844. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  90845. /**
  90846. * Gets the name of the behavior.
  90847. */
  90848. readonly name: string;
  90849. private _zoomStopsAnimation;
  90850. private _idleRotationSpeed;
  90851. private _idleRotationWaitTime;
  90852. private _idleRotationSpinupTime;
  90853. /**
  90854. * Sets the flag that indicates if user zooming should stop animation.
  90855. */
  90856. /**
  90857. * Gets the flag that indicates if user zooming should stop animation.
  90858. */
  90859. zoomStopsAnimation: boolean;
  90860. /**
  90861. * Sets the default speed at which the camera rotates around the model.
  90862. */
  90863. /**
  90864. * Gets the default speed at which the camera rotates around the model.
  90865. */
  90866. idleRotationSpeed: number;
  90867. /**
  90868. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  90869. */
  90870. /**
  90871. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  90872. */
  90873. idleRotationWaitTime: number;
  90874. /**
  90875. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90876. */
  90877. /**
  90878. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90879. */
  90880. idleRotationSpinupTime: number;
  90881. /**
  90882. * Gets a value indicating if the camera is currently rotating because of this behavior
  90883. */
  90884. readonly rotationInProgress: boolean;
  90885. private _onPrePointerObservableObserver;
  90886. private _onAfterCheckInputsObserver;
  90887. private _attachedCamera;
  90888. private _isPointerDown;
  90889. private _lastFrameTime;
  90890. private _lastInteractionTime;
  90891. private _cameraRotationSpeed;
  90892. /**
  90893. * Initializes the behavior.
  90894. */
  90895. init(): void;
  90896. /**
  90897. * Attaches the behavior to its arc rotate camera.
  90898. * @param camera Defines the camera to attach the behavior to
  90899. */
  90900. attach(camera: ArcRotateCamera): void;
  90901. /**
  90902. * Detaches the behavior from its current arc rotate camera.
  90903. */
  90904. detach(): void;
  90905. /**
  90906. * Returns true if user is scrolling.
  90907. * @return true if user is scrolling.
  90908. */
  90909. private _userIsZooming;
  90910. private _lastFrameRadius;
  90911. private _shouldAnimationStopForInteraction;
  90912. /**
  90913. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90914. */
  90915. private _applyUserInteraction;
  90916. private _userIsMoving;
  90917. }
  90918. }
  90919. declare module BABYLON {
  90920. /**
  90921. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  90922. */
  90923. export class AttachToBoxBehavior implements Behavior<Mesh> {
  90924. private ui;
  90925. /**
  90926. * The name of the behavior
  90927. */
  90928. name: string;
  90929. /**
  90930. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  90931. */
  90932. distanceAwayFromFace: number;
  90933. /**
  90934. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  90935. */
  90936. distanceAwayFromBottomOfFace: number;
  90937. private _faceVectors;
  90938. private _target;
  90939. private _scene;
  90940. private _onRenderObserver;
  90941. private _tmpMatrix;
  90942. private _tmpVector;
  90943. /**
  90944. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  90945. * @param ui The transform node that should be attched to the mesh
  90946. */
  90947. constructor(ui: TransformNode);
  90948. /**
  90949. * Initializes the behavior
  90950. */
  90951. init(): void;
  90952. private _closestFace;
  90953. private _zeroVector;
  90954. private _lookAtTmpMatrix;
  90955. private _lookAtToRef;
  90956. /**
  90957. * Attaches the AttachToBoxBehavior to the passed in mesh
  90958. * @param target The mesh that the specified node will be attached to
  90959. */
  90960. attach(target: Mesh): void;
  90961. /**
  90962. * Detaches the behavior from the mesh
  90963. */
  90964. detach(): void;
  90965. }
  90966. }
  90967. declare module BABYLON {
  90968. /**
  90969. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  90970. */
  90971. export class FadeInOutBehavior implements Behavior<Mesh> {
  90972. /**
  90973. * Time in milliseconds to delay before fading in (Default: 0)
  90974. */
  90975. delay: number;
  90976. /**
  90977. * Time in milliseconds for the mesh to fade in (Default: 300)
  90978. */
  90979. fadeInTime: number;
  90980. private _millisecondsPerFrame;
  90981. private _hovered;
  90982. private _hoverValue;
  90983. private _ownerNode;
  90984. /**
  90985. * Instatiates the FadeInOutBehavior
  90986. */
  90987. constructor();
  90988. /**
  90989. * The name of the behavior
  90990. */
  90991. readonly name: string;
  90992. /**
  90993. * Initializes the behavior
  90994. */
  90995. init(): void;
  90996. /**
  90997. * Attaches the fade behavior on the passed in mesh
  90998. * @param ownerNode The mesh that will be faded in/out once attached
  90999. */
  91000. attach(ownerNode: Mesh): void;
  91001. /**
  91002. * Detaches the behavior from the mesh
  91003. */
  91004. detach(): void;
  91005. /**
  91006. * Triggers the mesh to begin fading in or out
  91007. * @param value if the object should fade in or out (true to fade in)
  91008. */
  91009. fadeIn(value: boolean): void;
  91010. private _update;
  91011. private _setAllVisibility;
  91012. }
  91013. }
  91014. declare module BABYLON {
  91015. /**
  91016. * Class containing a set of static utilities functions for managing Pivots
  91017. * @hidden
  91018. */
  91019. export class PivotTools {
  91020. private static _PivotCached;
  91021. private static _OldPivotPoint;
  91022. private static _PivotTranslation;
  91023. private static _PivotTmpVector;
  91024. /** @hidden */
  91025. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  91026. /** @hidden */
  91027. static _RestorePivotPoint(mesh: AbstractMesh): void;
  91028. }
  91029. }
  91030. declare module BABYLON {
  91031. /**
  91032. * Class containing static functions to help procedurally build meshes
  91033. */
  91034. export class PlaneBuilder {
  91035. /**
  91036. * Creates a plane mesh
  91037. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91038. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91039. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91043. * @param name defines the name of the mesh
  91044. * @param options defines the options used to create the mesh
  91045. * @param scene defines the hosting scene
  91046. * @returns the plane mesh
  91047. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91048. */
  91049. static CreatePlane(name: string, options: {
  91050. size?: number;
  91051. width?: number;
  91052. height?: number;
  91053. sideOrientation?: number;
  91054. frontUVs?: Vector4;
  91055. backUVs?: Vector4;
  91056. updatable?: boolean;
  91057. sourcePlane?: Plane;
  91058. }, scene: Scene): Mesh;
  91059. }
  91060. }
  91061. declare module BABYLON {
  91062. /**
  91063. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  91064. */
  91065. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  91066. private static _AnyMouseID;
  91067. private _attachedNode;
  91068. private _dragPlane;
  91069. private _scene;
  91070. private _pointerObserver;
  91071. private _beforeRenderObserver;
  91072. private static _planeScene;
  91073. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  91074. /**
  91075. * 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)
  91076. */
  91077. maxDragAngle: number;
  91078. /**
  91079. * @hidden
  91080. */
  91081. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91082. /**
  91083. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91084. */
  91085. currentDraggingPointerID: number;
  91086. /**
  91087. * The last position where the pointer hit the drag plane in world space
  91088. */
  91089. lastDragPosition: Vector3;
  91090. /**
  91091. * If the behavior is currently in a dragging state
  91092. */
  91093. dragging: boolean;
  91094. /**
  91095. * 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)
  91096. */
  91097. dragDeltaRatio: number;
  91098. /**
  91099. * If the drag plane orientation should be updated during the dragging (Default: true)
  91100. */
  91101. updateDragPlane: boolean;
  91102. private _debugMode;
  91103. private _moving;
  91104. /**
  91105. * Fires each time the attached mesh is dragged with the pointer
  91106. * * delta between last drag position and current drag position in world space
  91107. * * dragDistance along the drag axis
  91108. * * dragPlaneNormal normal of the current drag plane used during the drag
  91109. * * dragPlanePoint in world space where the drag intersects the drag plane
  91110. */
  91111. onDragObservable: Observable<{
  91112. delta: Vector3;
  91113. dragPlanePoint: Vector3;
  91114. dragPlaneNormal: Vector3;
  91115. dragDistance: number;
  91116. pointerId: number;
  91117. }>;
  91118. /**
  91119. * Fires each time a drag begins (eg. mouse down on mesh)
  91120. */
  91121. onDragStartObservable: Observable<{
  91122. dragPlanePoint: Vector3;
  91123. pointerId: number;
  91124. }>;
  91125. /**
  91126. * Fires each time a drag ends (eg. mouse release after drag)
  91127. */
  91128. onDragEndObservable: Observable<{
  91129. dragPlanePoint: Vector3;
  91130. pointerId: number;
  91131. }>;
  91132. /**
  91133. * If the attached mesh should be moved when dragged
  91134. */
  91135. moveAttached: boolean;
  91136. /**
  91137. * If the drag behavior will react to drag events (Default: true)
  91138. */
  91139. enabled: boolean;
  91140. /**
  91141. * If camera controls should be detached during the drag
  91142. */
  91143. detachCameraControls: boolean;
  91144. /**
  91145. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91146. */
  91147. useObjectOrienationForDragging: boolean;
  91148. private _options;
  91149. /**
  91150. * Creates a pointer drag behavior that can be attached to a mesh
  91151. * @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)
  91152. */
  91153. constructor(options?: {
  91154. dragAxis?: Vector3;
  91155. dragPlaneNormal?: Vector3;
  91156. });
  91157. /**
  91158. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91159. */
  91160. validateDrag: (targetPosition: Vector3) => boolean;
  91161. /**
  91162. * The name of the behavior
  91163. */
  91164. readonly name: string;
  91165. /**
  91166. * Initializes the behavior
  91167. */
  91168. init(): void;
  91169. private _tmpVector;
  91170. private _alternatePickedPoint;
  91171. private _worldDragAxis;
  91172. private _targetPosition;
  91173. private _attachedElement;
  91174. /**
  91175. * Attaches the drag behavior the passed in mesh
  91176. * @param ownerNode The mesh that will be dragged around once attached
  91177. */
  91178. attach(ownerNode: AbstractMesh): void;
  91179. /**
  91180. * Force relase the drag action by code.
  91181. */
  91182. releaseDrag(): void;
  91183. private _startDragRay;
  91184. private _lastPointerRay;
  91185. /**
  91186. * Simulates the start of a pointer drag event on the behavior
  91187. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91188. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91189. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91190. */
  91191. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91192. private _startDrag;
  91193. private _dragDelta;
  91194. private _moveDrag;
  91195. private _pickWithRayOnDragPlane;
  91196. private _pointA;
  91197. private _pointB;
  91198. private _pointC;
  91199. private _lineA;
  91200. private _lineB;
  91201. private _localAxis;
  91202. private _lookAt;
  91203. private _updateDragPlanePosition;
  91204. /**
  91205. * Detaches the behavior from the mesh
  91206. */
  91207. detach(): void;
  91208. }
  91209. }
  91210. declare module BABYLON {
  91211. /**
  91212. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91213. */
  91214. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91215. private _dragBehaviorA;
  91216. private _dragBehaviorB;
  91217. private _startDistance;
  91218. private _initialScale;
  91219. private _targetScale;
  91220. private _ownerNode;
  91221. private _sceneRenderObserver;
  91222. /**
  91223. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91224. */
  91225. constructor();
  91226. /**
  91227. * The name of the behavior
  91228. */
  91229. readonly name: string;
  91230. /**
  91231. * Initializes the behavior
  91232. */
  91233. init(): void;
  91234. private _getCurrentDistance;
  91235. /**
  91236. * Attaches the scale behavior the passed in mesh
  91237. * @param ownerNode The mesh that will be scaled around once attached
  91238. */
  91239. attach(ownerNode: Mesh): void;
  91240. /**
  91241. * Detaches the behavior from the mesh
  91242. */
  91243. detach(): void;
  91244. }
  91245. }
  91246. declare module BABYLON {
  91247. /**
  91248. * 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
  91249. */
  91250. export class SixDofDragBehavior implements Behavior<Mesh> {
  91251. private static _virtualScene;
  91252. private _ownerNode;
  91253. private _sceneRenderObserver;
  91254. private _scene;
  91255. private _targetPosition;
  91256. private _virtualOriginMesh;
  91257. private _virtualDragMesh;
  91258. private _pointerObserver;
  91259. private _moving;
  91260. private _startingOrientation;
  91261. /**
  91262. * 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)
  91263. */
  91264. private zDragFactor;
  91265. /**
  91266. * If the object should rotate to face the drag origin
  91267. */
  91268. rotateDraggedObject: boolean;
  91269. /**
  91270. * If the behavior is currently in a dragging state
  91271. */
  91272. dragging: boolean;
  91273. /**
  91274. * 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)
  91275. */
  91276. dragDeltaRatio: number;
  91277. /**
  91278. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91279. */
  91280. currentDraggingPointerID: number;
  91281. /**
  91282. * If camera controls should be detached during the drag
  91283. */
  91284. detachCameraControls: boolean;
  91285. /**
  91286. * Fires each time a drag starts
  91287. */
  91288. onDragStartObservable: Observable<{}>;
  91289. /**
  91290. * Fires each time a drag ends (eg. mouse release after drag)
  91291. */
  91292. onDragEndObservable: Observable<{}>;
  91293. /**
  91294. * 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
  91295. */
  91296. constructor();
  91297. /**
  91298. * The name of the behavior
  91299. */
  91300. readonly name: string;
  91301. /**
  91302. * Initializes the behavior
  91303. */
  91304. init(): void;
  91305. /**
  91306. * Attaches the scale behavior the passed in mesh
  91307. * @param ownerNode The mesh that will be scaled around once attached
  91308. */
  91309. attach(ownerNode: Mesh): void;
  91310. /**
  91311. * Detaches the behavior from the mesh
  91312. */
  91313. detach(): void;
  91314. }
  91315. }
  91316. declare module BABYLON {
  91317. /**
  91318. * Class used to apply inverse kinematics to bones
  91319. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91320. */
  91321. export class BoneIKController {
  91322. private static _tmpVecs;
  91323. private static _tmpQuat;
  91324. private static _tmpMats;
  91325. /**
  91326. * Gets or sets the target mesh
  91327. */
  91328. targetMesh: AbstractMesh;
  91329. /** Gets or sets the mesh used as pole */
  91330. poleTargetMesh: AbstractMesh;
  91331. /**
  91332. * Gets or sets the bone used as pole
  91333. */
  91334. poleTargetBone: Nullable<Bone>;
  91335. /**
  91336. * Gets or sets the target position
  91337. */
  91338. targetPosition: Vector3;
  91339. /**
  91340. * Gets or sets the pole target position
  91341. */
  91342. poleTargetPosition: Vector3;
  91343. /**
  91344. * Gets or sets the pole target local offset
  91345. */
  91346. poleTargetLocalOffset: Vector3;
  91347. /**
  91348. * Gets or sets the pole angle
  91349. */
  91350. poleAngle: number;
  91351. /**
  91352. * Gets or sets the mesh associated with the controller
  91353. */
  91354. mesh: AbstractMesh;
  91355. /**
  91356. * 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)
  91357. */
  91358. slerpAmount: number;
  91359. private _bone1Quat;
  91360. private _bone1Mat;
  91361. private _bone2Ang;
  91362. private _bone1;
  91363. private _bone2;
  91364. private _bone1Length;
  91365. private _bone2Length;
  91366. private _maxAngle;
  91367. private _maxReach;
  91368. private _rightHandedSystem;
  91369. private _bendAxis;
  91370. private _slerping;
  91371. private _adjustRoll;
  91372. /**
  91373. * Gets or sets maximum allowed angle
  91374. */
  91375. maxAngle: number;
  91376. /**
  91377. * Creates a new BoneIKController
  91378. * @param mesh defines the mesh to control
  91379. * @param bone defines the bone to control
  91380. * @param options defines options to set up the controller
  91381. */
  91382. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91383. targetMesh?: AbstractMesh;
  91384. poleTargetMesh?: AbstractMesh;
  91385. poleTargetBone?: Bone;
  91386. poleTargetLocalOffset?: Vector3;
  91387. poleAngle?: number;
  91388. bendAxis?: Vector3;
  91389. maxAngle?: number;
  91390. slerpAmount?: number;
  91391. });
  91392. private _setMaxAngle;
  91393. /**
  91394. * Force the controller to update the bones
  91395. */
  91396. update(): void;
  91397. }
  91398. }
  91399. declare module BABYLON {
  91400. /**
  91401. * Class used to make a bone look toward a point in space
  91402. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91403. */
  91404. export class BoneLookController {
  91405. private static _tmpVecs;
  91406. private static _tmpQuat;
  91407. private static _tmpMats;
  91408. /**
  91409. * The target Vector3 that the bone will look at
  91410. */
  91411. target: Vector3;
  91412. /**
  91413. * The mesh that the bone is attached to
  91414. */
  91415. mesh: AbstractMesh;
  91416. /**
  91417. * The bone that will be looking to the target
  91418. */
  91419. bone: Bone;
  91420. /**
  91421. * The up axis of the coordinate system that is used when the bone is rotated
  91422. */
  91423. upAxis: Vector3;
  91424. /**
  91425. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91426. */
  91427. upAxisSpace: Space;
  91428. /**
  91429. * Used to make an adjustment to the yaw of the bone
  91430. */
  91431. adjustYaw: number;
  91432. /**
  91433. * Used to make an adjustment to the pitch of the bone
  91434. */
  91435. adjustPitch: number;
  91436. /**
  91437. * Used to make an adjustment to the roll of the bone
  91438. */
  91439. adjustRoll: number;
  91440. /**
  91441. * 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)
  91442. */
  91443. slerpAmount: number;
  91444. private _minYaw;
  91445. private _maxYaw;
  91446. private _minPitch;
  91447. private _maxPitch;
  91448. private _minYawSin;
  91449. private _minYawCos;
  91450. private _maxYawSin;
  91451. private _maxYawCos;
  91452. private _midYawConstraint;
  91453. private _minPitchTan;
  91454. private _maxPitchTan;
  91455. private _boneQuat;
  91456. private _slerping;
  91457. private _transformYawPitch;
  91458. private _transformYawPitchInv;
  91459. private _firstFrameSkipped;
  91460. private _yawRange;
  91461. private _fowardAxis;
  91462. /**
  91463. * Gets or sets the minimum yaw angle that the bone can look to
  91464. */
  91465. minYaw: number;
  91466. /**
  91467. * Gets or sets the maximum yaw angle that the bone can look to
  91468. */
  91469. maxYaw: number;
  91470. /**
  91471. * Gets or sets the minimum pitch angle that the bone can look to
  91472. */
  91473. minPitch: number;
  91474. /**
  91475. * Gets or sets the maximum pitch angle that the bone can look to
  91476. */
  91477. maxPitch: number;
  91478. /**
  91479. * Create a BoneLookController
  91480. * @param mesh the mesh that the bone belongs to
  91481. * @param bone the bone that will be looking to the target
  91482. * @param target the target Vector3 to look at
  91483. * @param options optional settings:
  91484. * * maxYaw: the maximum angle the bone will yaw to
  91485. * * minYaw: the minimum angle the bone will yaw to
  91486. * * maxPitch: the maximum angle the bone will pitch to
  91487. * * minPitch: the minimum angle the bone will yaw to
  91488. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91489. * * upAxis: the up axis of the coordinate system
  91490. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91491. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91492. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91493. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91494. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91495. * * adjustRoll: used to make an adjustment to the roll of the bone
  91496. **/
  91497. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91498. maxYaw?: number;
  91499. minYaw?: number;
  91500. maxPitch?: number;
  91501. minPitch?: number;
  91502. slerpAmount?: number;
  91503. upAxis?: Vector3;
  91504. upAxisSpace?: Space;
  91505. yawAxis?: Vector3;
  91506. pitchAxis?: Vector3;
  91507. adjustYaw?: number;
  91508. adjustPitch?: number;
  91509. adjustRoll?: number;
  91510. });
  91511. /**
  91512. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91513. */
  91514. update(): void;
  91515. private _getAngleDiff;
  91516. private _getAngleBetween;
  91517. private _isAngleBetween;
  91518. }
  91519. }
  91520. declare module BABYLON {
  91521. /**
  91522. * Manage the gamepad inputs to control an arc rotate camera.
  91523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91524. */
  91525. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91526. /**
  91527. * Defines the camera the input is attached to.
  91528. */
  91529. camera: ArcRotateCamera;
  91530. /**
  91531. * Defines the gamepad the input is gathering event from.
  91532. */
  91533. gamepad: Nullable<Gamepad>;
  91534. /**
  91535. * Defines the gamepad rotation sensiblity.
  91536. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91537. */
  91538. gamepadRotationSensibility: number;
  91539. /**
  91540. * Defines the gamepad move sensiblity.
  91541. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91542. */
  91543. gamepadMoveSensibility: number;
  91544. private _onGamepadConnectedObserver;
  91545. private _onGamepadDisconnectedObserver;
  91546. /**
  91547. * Attach the input controls to a specific dom element to get the input from.
  91548. * @param element Defines the element the controls should be listened from
  91549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91550. */
  91551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91552. /**
  91553. * Detach the current controls from the specified dom element.
  91554. * @param element Defines the element to stop listening the inputs from
  91555. */
  91556. detachControl(element: Nullable<HTMLElement>): void;
  91557. /**
  91558. * Update the current camera state depending on the inputs that have been used this frame.
  91559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91560. */
  91561. checkInputs(): void;
  91562. /**
  91563. * Gets the class name of the current intput.
  91564. * @returns the class name
  91565. */
  91566. getClassName(): string;
  91567. /**
  91568. * Get the friendly name associated with the input class.
  91569. * @returns the input friendly name
  91570. */
  91571. getSimpleName(): string;
  91572. }
  91573. }
  91574. declare module BABYLON {
  91575. interface ArcRotateCameraInputsManager {
  91576. /**
  91577. * Add orientation input support to the input manager.
  91578. * @returns the current input manager
  91579. */
  91580. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91581. }
  91582. /**
  91583. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91585. */
  91586. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91587. /**
  91588. * Defines the camera the input is attached to.
  91589. */
  91590. camera: ArcRotateCamera;
  91591. /**
  91592. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91593. */
  91594. alphaCorrection: number;
  91595. /**
  91596. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91597. */
  91598. gammaCorrection: number;
  91599. private _alpha;
  91600. private _gamma;
  91601. private _dirty;
  91602. private _deviceOrientationHandler;
  91603. /**
  91604. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91605. */
  91606. constructor();
  91607. /**
  91608. * Attach the input controls to a specific dom element to get the input from.
  91609. * @param element Defines the element the controls should be listened from
  91610. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91611. */
  91612. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91613. /** @hidden */
  91614. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91615. /**
  91616. * Update the current camera state depending on the inputs that have been used this frame.
  91617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91618. */
  91619. checkInputs(): void;
  91620. /**
  91621. * Detach the current controls from the specified dom element.
  91622. * @param element Defines the element to stop listening the inputs from
  91623. */
  91624. detachControl(element: Nullable<HTMLElement>): void;
  91625. /**
  91626. * Gets the class name of the current intput.
  91627. * @returns the class name
  91628. */
  91629. getClassName(): string;
  91630. /**
  91631. * Get the friendly name associated with the input class.
  91632. * @returns the input friendly name
  91633. */
  91634. getSimpleName(): string;
  91635. }
  91636. }
  91637. declare module BABYLON {
  91638. /**
  91639. * Listen to mouse events to control the camera.
  91640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91641. */
  91642. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91643. /**
  91644. * Defines the camera the input is attached to.
  91645. */
  91646. camera: FlyCamera;
  91647. /**
  91648. * Defines if touch is enabled. (Default is true.)
  91649. */
  91650. touchEnabled: boolean;
  91651. /**
  91652. * Defines the buttons associated with the input to handle camera rotation.
  91653. */
  91654. buttons: number[];
  91655. /**
  91656. * Assign buttons for Yaw control.
  91657. */
  91658. buttonsYaw: number[];
  91659. /**
  91660. * Assign buttons for Pitch control.
  91661. */
  91662. buttonsPitch: number[];
  91663. /**
  91664. * Assign buttons for Roll control.
  91665. */
  91666. buttonsRoll: number[];
  91667. /**
  91668. * Detect if any button is being pressed while mouse is moved.
  91669. * -1 = Mouse locked.
  91670. * 0 = Left button.
  91671. * 1 = Middle Button.
  91672. * 2 = Right Button.
  91673. */
  91674. activeButton: number;
  91675. /**
  91676. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91677. * Higher values reduce its sensitivity.
  91678. */
  91679. angularSensibility: number;
  91680. private _mousemoveCallback;
  91681. private _observer;
  91682. private _rollObserver;
  91683. private previousPosition;
  91684. private noPreventDefault;
  91685. private element;
  91686. /**
  91687. * Listen to mouse events to control the camera.
  91688. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91689. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91690. */
  91691. constructor(touchEnabled?: boolean);
  91692. /**
  91693. * Attach the mouse control to the HTML DOM element.
  91694. * @param element Defines the element that listens to the input events.
  91695. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91696. */
  91697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91698. /**
  91699. * Detach the current controls from the specified dom element.
  91700. * @param element Defines the element to stop listening the inputs from
  91701. */
  91702. detachControl(element: Nullable<HTMLElement>): void;
  91703. /**
  91704. * Gets the class name of the current input.
  91705. * @returns the class name.
  91706. */
  91707. getClassName(): string;
  91708. /**
  91709. * Get the friendly name associated with the input class.
  91710. * @returns the input's friendly name.
  91711. */
  91712. getSimpleName(): string;
  91713. private _pointerInput;
  91714. private _onMouseMove;
  91715. /**
  91716. * Rotate camera by mouse offset.
  91717. */
  91718. private rotateCamera;
  91719. }
  91720. }
  91721. declare module BABYLON {
  91722. /**
  91723. * Default Inputs manager for the FlyCamera.
  91724. * It groups all the default supported inputs for ease of use.
  91725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91726. */
  91727. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  91728. /**
  91729. * Instantiates a new FlyCameraInputsManager.
  91730. * @param camera Defines the camera the inputs belong to.
  91731. */
  91732. constructor(camera: FlyCamera);
  91733. /**
  91734. * Add keyboard input support to the input manager.
  91735. * @returns the new FlyCameraKeyboardMoveInput().
  91736. */
  91737. addKeyboard(): FlyCameraInputsManager;
  91738. /**
  91739. * Add mouse input support to the input manager.
  91740. * @param touchEnabled Enable touch screen support.
  91741. * @returns the new FlyCameraMouseInput().
  91742. */
  91743. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  91744. }
  91745. }
  91746. declare module BABYLON {
  91747. /**
  91748. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91749. * such as in a 3D Space Shooter or a Flight Simulator.
  91750. */
  91751. export class FlyCamera extends TargetCamera {
  91752. /**
  91753. * Define the collision ellipsoid of the camera.
  91754. * This is helpful for simulating a camera body, like a player's body.
  91755. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91756. */
  91757. ellipsoid: Vector3;
  91758. /**
  91759. * Define an offset for the position of the ellipsoid around the camera.
  91760. * This can be helpful if the camera is attached away from the player's body center,
  91761. * such as at its head.
  91762. */
  91763. ellipsoidOffset: Vector3;
  91764. /**
  91765. * Enable or disable collisions of the camera with the rest of the scene objects.
  91766. */
  91767. checkCollisions: boolean;
  91768. /**
  91769. * Enable or disable gravity on the camera.
  91770. */
  91771. applyGravity: boolean;
  91772. /**
  91773. * Define the current direction the camera is moving to.
  91774. */
  91775. cameraDirection: Vector3;
  91776. /**
  91777. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  91778. * This overrides and empties cameraRotation.
  91779. */
  91780. rotationQuaternion: Quaternion;
  91781. /**
  91782. * Track Roll to maintain the wanted Rolling when looking around.
  91783. */
  91784. _trackRoll: number;
  91785. /**
  91786. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  91787. */
  91788. rollCorrect: number;
  91789. /**
  91790. * Mimic a banked turn, Rolling the camera when Yawing.
  91791. * It's recommended to use rollCorrect = 10 for faster banking correction.
  91792. */
  91793. bankedTurn: boolean;
  91794. /**
  91795. * Limit in radians for how much Roll banking will add. (Default: 90°)
  91796. */
  91797. bankedTurnLimit: number;
  91798. /**
  91799. * Value of 0 disables the banked Roll.
  91800. * Value of 1 is equal to the Yaw angle in radians.
  91801. */
  91802. bankedTurnMultiplier: number;
  91803. /**
  91804. * The inputs manager loads all the input sources, such as keyboard and mouse.
  91805. */
  91806. inputs: FlyCameraInputsManager;
  91807. /**
  91808. * Gets the input sensibility for mouse input.
  91809. * Higher values reduce sensitivity.
  91810. */
  91811. /**
  91812. * Sets the input sensibility for a mouse input.
  91813. * Higher values reduce sensitivity.
  91814. */
  91815. angularSensibility: number;
  91816. /**
  91817. * Get the keys for camera movement forward.
  91818. */
  91819. /**
  91820. * Set the keys for camera movement forward.
  91821. */
  91822. keysForward: number[];
  91823. /**
  91824. * Get the keys for camera movement backward.
  91825. */
  91826. keysBackward: number[];
  91827. /**
  91828. * Get the keys for camera movement up.
  91829. */
  91830. /**
  91831. * Set the keys for camera movement up.
  91832. */
  91833. keysUp: number[];
  91834. /**
  91835. * Get the keys for camera movement down.
  91836. */
  91837. /**
  91838. * Set the keys for camera movement down.
  91839. */
  91840. keysDown: number[];
  91841. /**
  91842. * Get the keys for camera movement left.
  91843. */
  91844. /**
  91845. * Set the keys for camera movement left.
  91846. */
  91847. keysLeft: number[];
  91848. /**
  91849. * Set the keys for camera movement right.
  91850. */
  91851. /**
  91852. * Set the keys for camera movement right.
  91853. */
  91854. keysRight: number[];
  91855. /**
  91856. * Event raised when the camera collides with a mesh in the scene.
  91857. */
  91858. onCollide: (collidedMesh: AbstractMesh) => void;
  91859. private _collider;
  91860. private _needMoveForGravity;
  91861. private _oldPosition;
  91862. private _diffPosition;
  91863. private _newPosition;
  91864. /** @hidden */
  91865. _localDirection: Vector3;
  91866. /** @hidden */
  91867. _transformedDirection: Vector3;
  91868. /**
  91869. * Instantiates a FlyCamera.
  91870. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91871. * such as in a 3D Space Shooter or a Flight Simulator.
  91872. * @param name Define the name of the camera in the scene.
  91873. * @param position Define the starting position of the camera in the scene.
  91874. * @param scene Define the scene the camera belongs to.
  91875. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  91876. */
  91877. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91878. /**
  91879. * Attach a control to the HTML DOM element.
  91880. * @param element Defines the element that listens to the input events.
  91881. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  91882. */
  91883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91884. /**
  91885. * Detach a control from the HTML DOM element.
  91886. * The camera will stop reacting to that input.
  91887. * @param element Defines the element that listens to the input events.
  91888. */
  91889. detachControl(element: HTMLElement): void;
  91890. private _collisionMask;
  91891. /**
  91892. * Get the mask that the camera ignores in collision events.
  91893. */
  91894. /**
  91895. * Set the mask that the camera ignores in collision events.
  91896. */
  91897. collisionMask: number;
  91898. /** @hidden */
  91899. _collideWithWorld(displacement: Vector3): void;
  91900. /** @hidden */
  91901. private _onCollisionPositionChange;
  91902. /** @hidden */
  91903. _checkInputs(): void;
  91904. /** @hidden */
  91905. _decideIfNeedsToMove(): boolean;
  91906. /** @hidden */
  91907. _updatePosition(): void;
  91908. /**
  91909. * Restore the Roll to its target value at the rate specified.
  91910. * @param rate - Higher means slower restoring.
  91911. * @hidden
  91912. */
  91913. restoreRoll(rate: number): void;
  91914. /**
  91915. * Destroy the camera and release the current resources held by it.
  91916. */
  91917. dispose(): void;
  91918. /**
  91919. * Get the current object class name.
  91920. * @returns the class name.
  91921. */
  91922. getClassName(): string;
  91923. }
  91924. }
  91925. declare module BABYLON {
  91926. /**
  91927. * Listen to keyboard events to control the camera.
  91928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91929. */
  91930. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  91931. /**
  91932. * Defines the camera the input is attached to.
  91933. */
  91934. camera: FlyCamera;
  91935. /**
  91936. * The list of keyboard keys used to control the forward move of the camera.
  91937. */
  91938. keysForward: number[];
  91939. /**
  91940. * The list of keyboard keys used to control the backward move of the camera.
  91941. */
  91942. keysBackward: number[];
  91943. /**
  91944. * The list of keyboard keys used to control the forward move of the camera.
  91945. */
  91946. keysUp: number[];
  91947. /**
  91948. * The list of keyboard keys used to control the backward move of the camera.
  91949. */
  91950. keysDown: number[];
  91951. /**
  91952. * The list of keyboard keys used to control the right strafe move of the camera.
  91953. */
  91954. keysRight: number[];
  91955. /**
  91956. * The list of keyboard keys used to control the left strafe move of the camera.
  91957. */
  91958. keysLeft: number[];
  91959. private _keys;
  91960. private _onCanvasBlurObserver;
  91961. private _onKeyboardObserver;
  91962. private _engine;
  91963. private _scene;
  91964. /**
  91965. * Attach the input controls to a specific dom element to get the input from.
  91966. * @param element Defines the element the controls should be listened from
  91967. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91968. */
  91969. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91970. /**
  91971. * Detach the current controls from the specified dom element.
  91972. * @param element Defines the element to stop listening the inputs from
  91973. */
  91974. detachControl(element: Nullable<HTMLElement>): void;
  91975. /**
  91976. * Gets the class name of the current intput.
  91977. * @returns the class name
  91978. */
  91979. getClassName(): string;
  91980. /** @hidden */
  91981. _onLostFocus(e: FocusEvent): void;
  91982. /**
  91983. * Get the friendly name associated with the input class.
  91984. * @returns the input friendly name
  91985. */
  91986. getSimpleName(): string;
  91987. /**
  91988. * Update the current camera state depending on the inputs that have been used this frame.
  91989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91990. */
  91991. checkInputs(): void;
  91992. }
  91993. }
  91994. declare module BABYLON {
  91995. interface FreeCameraInputsManager {
  91996. /**
  91997. * Add orientation input support to the input manager.
  91998. * @returns the current input manager
  91999. */
  92000. addDeviceOrientation(): FreeCameraInputsManager;
  92001. }
  92002. /**
  92003. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  92004. * Screen rotation is taken into account.
  92005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92006. */
  92007. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  92008. private _camera;
  92009. private _screenOrientationAngle;
  92010. private _constantTranform;
  92011. private _screenQuaternion;
  92012. private _alpha;
  92013. private _beta;
  92014. private _gamma;
  92015. /**
  92016. * Instantiates a new input
  92017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92018. */
  92019. constructor();
  92020. /**
  92021. * Define the camera controlled by the input.
  92022. */
  92023. camera: FreeCamera;
  92024. /**
  92025. * Attach the input controls to a specific dom element to get the input from.
  92026. * @param element Defines the element the controls should be listened from
  92027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92028. */
  92029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92030. private _orientationChanged;
  92031. private _deviceOrientation;
  92032. /**
  92033. * Detach the current controls from the specified dom element.
  92034. * @param element Defines the element to stop listening the inputs from
  92035. */
  92036. detachControl(element: Nullable<HTMLElement>): void;
  92037. /**
  92038. * Update the current camera state depending on the inputs that have been used this frame.
  92039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92040. */
  92041. checkInputs(): void;
  92042. /**
  92043. * Gets the class name of the current intput.
  92044. * @returns the class name
  92045. */
  92046. getClassName(): string;
  92047. /**
  92048. * Get the friendly name associated with the input class.
  92049. * @returns the input friendly name
  92050. */
  92051. getSimpleName(): string;
  92052. }
  92053. }
  92054. declare module BABYLON {
  92055. /**
  92056. * Manage the gamepad inputs to control a free camera.
  92057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92058. */
  92059. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  92060. /**
  92061. * Define the camera the input is attached to.
  92062. */
  92063. camera: FreeCamera;
  92064. /**
  92065. * Define the Gamepad controlling the input
  92066. */
  92067. gamepad: Nullable<Gamepad>;
  92068. /**
  92069. * Defines the gamepad rotation sensiblity.
  92070. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92071. */
  92072. gamepadAngularSensibility: number;
  92073. /**
  92074. * Defines the gamepad move sensiblity.
  92075. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92076. */
  92077. gamepadMoveSensibility: number;
  92078. private _onGamepadConnectedObserver;
  92079. private _onGamepadDisconnectedObserver;
  92080. private _cameraTransform;
  92081. private _deltaTransform;
  92082. private _vector3;
  92083. private _vector2;
  92084. /**
  92085. * Attach the input controls to a specific dom element to get the input from.
  92086. * @param element Defines the element the controls should be listened from
  92087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92088. */
  92089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92090. /**
  92091. * Detach the current controls from the specified dom element.
  92092. * @param element Defines the element to stop listening the inputs from
  92093. */
  92094. detachControl(element: Nullable<HTMLElement>): void;
  92095. /**
  92096. * Update the current camera state depending on the inputs that have been used this frame.
  92097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92098. */
  92099. checkInputs(): void;
  92100. /**
  92101. * Gets the class name of the current intput.
  92102. * @returns the class name
  92103. */
  92104. getClassName(): string;
  92105. /**
  92106. * Get the friendly name associated with the input class.
  92107. * @returns the input friendly name
  92108. */
  92109. getSimpleName(): string;
  92110. }
  92111. }
  92112. declare module BABYLON {
  92113. /**
  92114. * Defines the potential axis of a Joystick
  92115. */
  92116. export enum JoystickAxis {
  92117. /** X axis */
  92118. X = 0,
  92119. /** Y axis */
  92120. Y = 1,
  92121. /** Z axis */
  92122. Z = 2
  92123. }
  92124. /**
  92125. * Class used to define virtual joystick (used in touch mode)
  92126. */
  92127. export class VirtualJoystick {
  92128. /**
  92129. * Gets or sets a boolean indicating that left and right values must be inverted
  92130. */
  92131. reverseLeftRight: boolean;
  92132. /**
  92133. * Gets or sets a boolean indicating that up and down values must be inverted
  92134. */
  92135. reverseUpDown: boolean;
  92136. /**
  92137. * Gets the offset value for the position (ie. the change of the position value)
  92138. */
  92139. deltaPosition: Vector3;
  92140. /**
  92141. * Gets a boolean indicating if the virtual joystick was pressed
  92142. */
  92143. pressed: boolean;
  92144. /**
  92145. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92146. */
  92147. static Canvas: Nullable<HTMLCanvasElement>;
  92148. private static _globalJoystickIndex;
  92149. private static vjCanvasContext;
  92150. private static vjCanvasWidth;
  92151. private static vjCanvasHeight;
  92152. private static halfWidth;
  92153. private _action;
  92154. private _axisTargetedByLeftAndRight;
  92155. private _axisTargetedByUpAndDown;
  92156. private _joystickSensibility;
  92157. private _inversedSensibility;
  92158. private _joystickPointerID;
  92159. private _joystickColor;
  92160. private _joystickPointerPos;
  92161. private _joystickPreviousPointerPos;
  92162. private _joystickPointerStartPos;
  92163. private _deltaJoystickVector;
  92164. private _leftJoystick;
  92165. private _touches;
  92166. private _onPointerDownHandlerRef;
  92167. private _onPointerMoveHandlerRef;
  92168. private _onPointerUpHandlerRef;
  92169. private _onResize;
  92170. /**
  92171. * Creates a new virtual joystick
  92172. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92173. */
  92174. constructor(leftJoystick?: boolean);
  92175. /**
  92176. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92177. * @param newJoystickSensibility defines the new sensibility
  92178. */
  92179. setJoystickSensibility(newJoystickSensibility: number): void;
  92180. private _onPointerDown;
  92181. private _onPointerMove;
  92182. private _onPointerUp;
  92183. /**
  92184. * Change the color of the virtual joystick
  92185. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92186. */
  92187. setJoystickColor(newColor: string): void;
  92188. /**
  92189. * Defines a callback to call when the joystick is touched
  92190. * @param action defines the callback
  92191. */
  92192. setActionOnTouch(action: () => any): void;
  92193. /**
  92194. * Defines which axis you'd like to control for left & right
  92195. * @param axis defines the axis to use
  92196. */
  92197. setAxisForLeftRight(axis: JoystickAxis): void;
  92198. /**
  92199. * Defines which axis you'd like to control for up & down
  92200. * @param axis defines the axis to use
  92201. */
  92202. setAxisForUpDown(axis: JoystickAxis): void;
  92203. private _drawVirtualJoystick;
  92204. /**
  92205. * Release internal HTML canvas
  92206. */
  92207. releaseCanvas(): void;
  92208. }
  92209. }
  92210. declare module BABYLON {
  92211. interface FreeCameraInputsManager {
  92212. /**
  92213. * Add virtual joystick input support to the input manager.
  92214. * @returns the current input manager
  92215. */
  92216. addVirtualJoystick(): FreeCameraInputsManager;
  92217. }
  92218. /**
  92219. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92221. */
  92222. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92223. /**
  92224. * Defines the camera the input is attached to.
  92225. */
  92226. camera: FreeCamera;
  92227. private _leftjoystick;
  92228. private _rightjoystick;
  92229. /**
  92230. * Gets the left stick of the virtual joystick.
  92231. * @returns The virtual Joystick
  92232. */
  92233. getLeftJoystick(): VirtualJoystick;
  92234. /**
  92235. * Gets the right stick of the virtual joystick.
  92236. * @returns The virtual Joystick
  92237. */
  92238. getRightJoystick(): VirtualJoystick;
  92239. /**
  92240. * Update the current camera state depending on the inputs that have been used this frame.
  92241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92242. */
  92243. checkInputs(): void;
  92244. /**
  92245. * Attach the input controls to a specific dom element to get the input from.
  92246. * @param element Defines the element the controls should be listened from
  92247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92248. */
  92249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92250. /**
  92251. * Detach the current controls from the specified dom element.
  92252. * @param element Defines the element to stop listening the inputs from
  92253. */
  92254. detachControl(element: Nullable<HTMLElement>): void;
  92255. /**
  92256. * Gets the class name of the current intput.
  92257. * @returns the class name
  92258. */
  92259. getClassName(): string;
  92260. /**
  92261. * Get the friendly name associated with the input class.
  92262. * @returns the input friendly name
  92263. */
  92264. getSimpleName(): string;
  92265. }
  92266. }
  92267. declare module BABYLON {
  92268. /**
  92269. * This represents a FPS type of camera controlled by touch.
  92270. * This is like a universal camera minus the Gamepad controls.
  92271. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92272. */
  92273. export class TouchCamera extends FreeCamera {
  92274. /**
  92275. * Defines the touch sensibility for rotation.
  92276. * The higher the faster.
  92277. */
  92278. touchAngularSensibility: number;
  92279. /**
  92280. * Defines the touch sensibility for move.
  92281. * The higher the faster.
  92282. */
  92283. touchMoveSensibility: number;
  92284. /**
  92285. * Instantiates a new touch camera.
  92286. * This represents a FPS type of camera controlled by touch.
  92287. * This is like a universal camera minus the Gamepad controls.
  92288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92289. * @param name Define the name of the camera in the scene
  92290. * @param position Define the start position of the camera in the scene
  92291. * @param scene Define the scene the camera belongs to
  92292. */
  92293. constructor(name: string, position: Vector3, scene: Scene);
  92294. /**
  92295. * Gets the current object class name.
  92296. * @return the class name
  92297. */
  92298. getClassName(): string;
  92299. /** @hidden */
  92300. _setupInputs(): void;
  92301. }
  92302. }
  92303. declare module BABYLON {
  92304. /**
  92305. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92306. * being tilted forward or back and left or right.
  92307. */
  92308. export class DeviceOrientationCamera extends FreeCamera {
  92309. private _initialQuaternion;
  92310. private _quaternionCache;
  92311. /**
  92312. * Creates a new device orientation camera
  92313. * @param name The name of the camera
  92314. * @param position The start position camera
  92315. * @param scene The scene the camera belongs to
  92316. */
  92317. constructor(name: string, position: Vector3, scene: Scene);
  92318. /**
  92319. * Gets the current instance class name ("DeviceOrientationCamera").
  92320. * This helps avoiding instanceof at run time.
  92321. * @returns the class name
  92322. */
  92323. getClassName(): string;
  92324. /**
  92325. * @hidden
  92326. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92327. */
  92328. _checkInputs(): void;
  92329. /**
  92330. * Reset the camera to its default orientation on the specified axis only.
  92331. * @param axis The axis to reset
  92332. */
  92333. resetToCurrentRotation(axis?: Axis): void;
  92334. }
  92335. }
  92336. declare module BABYLON {
  92337. /**
  92338. * Manage the keyboard inputs to control the movement of a follow camera.
  92339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92340. */
  92341. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92342. /**
  92343. * Defines the camera the input is attached to.
  92344. */
  92345. camera: FollowCamera;
  92346. /**
  92347. * Defines the list of key codes associated with the up action (increase heightOffset)
  92348. */
  92349. keysHeightOffsetIncr: number[];
  92350. /**
  92351. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92352. */
  92353. keysHeightOffsetDecr: number[];
  92354. /**
  92355. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92356. */
  92357. keysHeightOffsetModifierAlt: boolean;
  92358. /**
  92359. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92360. */
  92361. keysHeightOffsetModifierCtrl: boolean;
  92362. /**
  92363. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92364. */
  92365. keysHeightOffsetModifierShift: boolean;
  92366. /**
  92367. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92368. */
  92369. keysRotationOffsetIncr: number[];
  92370. /**
  92371. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92372. */
  92373. keysRotationOffsetDecr: number[];
  92374. /**
  92375. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92376. */
  92377. keysRotationOffsetModifierAlt: boolean;
  92378. /**
  92379. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92380. */
  92381. keysRotationOffsetModifierCtrl: boolean;
  92382. /**
  92383. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92384. */
  92385. keysRotationOffsetModifierShift: boolean;
  92386. /**
  92387. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92388. */
  92389. keysRadiusIncr: number[];
  92390. /**
  92391. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92392. */
  92393. keysRadiusDecr: number[];
  92394. /**
  92395. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92396. */
  92397. keysRadiusModifierAlt: boolean;
  92398. /**
  92399. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92400. */
  92401. keysRadiusModifierCtrl: boolean;
  92402. /**
  92403. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92404. */
  92405. keysRadiusModifierShift: boolean;
  92406. /**
  92407. * Defines the rate of change of heightOffset.
  92408. */
  92409. heightSensibility: number;
  92410. /**
  92411. * Defines the rate of change of rotationOffset.
  92412. */
  92413. rotationSensibility: number;
  92414. /**
  92415. * Defines the rate of change of radius.
  92416. */
  92417. radiusSensibility: number;
  92418. private _keys;
  92419. private _ctrlPressed;
  92420. private _altPressed;
  92421. private _shiftPressed;
  92422. private _onCanvasBlurObserver;
  92423. private _onKeyboardObserver;
  92424. private _engine;
  92425. private _scene;
  92426. /**
  92427. * Attach the input controls to a specific dom element to get the input from.
  92428. * @param element Defines the element the controls should be listened from
  92429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92430. */
  92431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92432. /**
  92433. * Detach the current controls from the specified dom element.
  92434. * @param element Defines the element to stop listening the inputs from
  92435. */
  92436. detachControl(element: Nullable<HTMLElement>): void;
  92437. /**
  92438. * Update the current camera state depending on the inputs that have been used this frame.
  92439. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92440. */
  92441. checkInputs(): void;
  92442. /**
  92443. * Gets the class name of the current input.
  92444. * @returns the class name
  92445. */
  92446. getClassName(): string;
  92447. /**
  92448. * Get the friendly name associated with the input class.
  92449. * @returns the input friendly name
  92450. */
  92451. getSimpleName(): string;
  92452. /**
  92453. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92454. * allow modification of the heightOffset value.
  92455. */
  92456. private _modifierHeightOffset;
  92457. /**
  92458. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92459. * allow modification of the rotationOffset value.
  92460. */
  92461. private _modifierRotationOffset;
  92462. /**
  92463. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92464. * allow modification of the radius value.
  92465. */
  92466. private _modifierRadius;
  92467. }
  92468. }
  92469. declare module BABYLON {
  92470. /**
  92471. * Manage the mouse wheel inputs to control a follow camera.
  92472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92473. */
  92474. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92475. /**
  92476. * Defines the camera the input is attached to.
  92477. */
  92478. camera: FollowCamera;
  92479. /**
  92480. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92481. */
  92482. axisControlRadius: boolean;
  92483. /**
  92484. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92485. */
  92486. axisControlHeight: boolean;
  92487. /**
  92488. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92489. */
  92490. axisControlRotation: boolean;
  92491. /**
  92492. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92493. * relation to mouseWheel events.
  92494. */
  92495. wheelPrecision: number;
  92496. /**
  92497. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92498. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92499. */
  92500. wheelDeltaPercentage: number;
  92501. private _wheel;
  92502. private _observer;
  92503. /**
  92504. * Attach the input controls to a specific dom element to get the input from.
  92505. * @param element Defines the element the controls should be listened from
  92506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92507. */
  92508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92509. /**
  92510. * Detach the current controls from the specified dom element.
  92511. * @param element Defines the element to stop listening the inputs from
  92512. */
  92513. detachControl(element: Nullable<HTMLElement>): void;
  92514. /**
  92515. * Gets the class name of the current intput.
  92516. * @returns the class name
  92517. */
  92518. getClassName(): string;
  92519. /**
  92520. * Get the friendly name associated with the input class.
  92521. * @returns the input friendly name
  92522. */
  92523. getSimpleName(): string;
  92524. }
  92525. }
  92526. declare module BABYLON {
  92527. /**
  92528. * Default Inputs manager for the FollowCamera.
  92529. * It groups all the default supported inputs for ease of use.
  92530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92531. */
  92532. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92533. /**
  92534. * Instantiates a new FollowCameraInputsManager.
  92535. * @param camera Defines the camera the inputs belong to
  92536. */
  92537. constructor(camera: FollowCamera);
  92538. /**
  92539. * Add keyboard input support to the input manager.
  92540. * @returns the current input manager
  92541. */
  92542. addKeyboard(): FollowCameraInputsManager;
  92543. /**
  92544. * Add mouse wheel input support to the input manager.
  92545. * @returns the current input manager
  92546. */
  92547. addMouseWheel(): FollowCameraInputsManager;
  92548. /**
  92549. * Add pointers input support to the input manager.
  92550. * @returns the current input manager
  92551. */
  92552. addPointers(): FollowCameraInputsManager;
  92553. /**
  92554. * Add orientation input support to the input manager.
  92555. * @returns the current input manager
  92556. */
  92557. addVRDeviceOrientation(): FollowCameraInputsManager;
  92558. }
  92559. }
  92560. declare module BABYLON {
  92561. /**
  92562. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92563. * an arc rotate version arcFollowCamera are available.
  92564. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92565. */
  92566. export class FollowCamera extends TargetCamera {
  92567. /**
  92568. * Distance the follow camera should follow an object at
  92569. */
  92570. radius: number;
  92571. /**
  92572. * Minimum allowed distance of the camera to the axis of rotation
  92573. * (The camera can not get closer).
  92574. * This can help limiting how the Camera is able to move in the scene.
  92575. */
  92576. lowerRadiusLimit: Nullable<number>;
  92577. /**
  92578. * Maximum allowed distance of the camera to the axis of rotation
  92579. * (The camera can not get further).
  92580. * This can help limiting how the Camera is able to move in the scene.
  92581. */
  92582. upperRadiusLimit: Nullable<number>;
  92583. /**
  92584. * Define a rotation offset between the camera and the object it follows
  92585. */
  92586. rotationOffset: number;
  92587. /**
  92588. * Minimum allowed angle to camera position relative to target object.
  92589. * This can help limiting how the Camera is able to move in the scene.
  92590. */
  92591. lowerRotationOffsetLimit: Nullable<number>;
  92592. /**
  92593. * Maximum allowed angle to camera position relative to target object.
  92594. * This can help limiting how the Camera is able to move in the scene.
  92595. */
  92596. upperRotationOffsetLimit: Nullable<number>;
  92597. /**
  92598. * Define a height offset between the camera and the object it follows.
  92599. * It can help following an object from the top (like a car chaing a plane)
  92600. */
  92601. heightOffset: number;
  92602. /**
  92603. * Minimum allowed height of camera position relative to target object.
  92604. * This can help limiting how the Camera is able to move in the scene.
  92605. */
  92606. lowerHeightOffsetLimit: Nullable<number>;
  92607. /**
  92608. * Maximum allowed height of camera position relative to target object.
  92609. * This can help limiting how the Camera is able to move in the scene.
  92610. */
  92611. upperHeightOffsetLimit: Nullable<number>;
  92612. /**
  92613. * Define how fast the camera can accelerate to follow it s target.
  92614. */
  92615. cameraAcceleration: number;
  92616. /**
  92617. * Define the speed limit of the camera following an object.
  92618. */
  92619. maxCameraSpeed: number;
  92620. /**
  92621. * Define the target of the camera.
  92622. */
  92623. lockedTarget: Nullable<AbstractMesh>;
  92624. /**
  92625. * Defines the input associated with the camera.
  92626. */
  92627. inputs: FollowCameraInputsManager;
  92628. /**
  92629. * Instantiates the follow camera.
  92630. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92631. * @param name Define the name of the camera in the scene
  92632. * @param position Define the position of the camera
  92633. * @param scene Define the scene the camera belong to
  92634. * @param lockedTarget Define the target of the camera
  92635. */
  92636. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92637. private _follow;
  92638. /**
  92639. * Attached controls to the current camera.
  92640. * @param element Defines the element the controls should be listened from
  92641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92642. */
  92643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92644. /**
  92645. * Detach the current controls from the camera.
  92646. * The camera will stop reacting to inputs.
  92647. * @param element Defines the element to stop listening the inputs from
  92648. */
  92649. detachControl(element: HTMLElement): void;
  92650. /** @hidden */
  92651. _checkInputs(): void;
  92652. private _checkLimits;
  92653. /**
  92654. * Gets the camera class name.
  92655. * @returns the class name
  92656. */
  92657. getClassName(): string;
  92658. }
  92659. /**
  92660. * Arc Rotate version of the follow camera.
  92661. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92662. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92663. */
  92664. export class ArcFollowCamera extends TargetCamera {
  92665. /** The longitudinal angle of the camera */
  92666. alpha: number;
  92667. /** The latitudinal angle of the camera */
  92668. beta: number;
  92669. /** The radius of the camera from its target */
  92670. radius: number;
  92671. /** Define the camera target (the messh it should follow) */
  92672. target: Nullable<AbstractMesh>;
  92673. private _cartesianCoordinates;
  92674. /**
  92675. * Instantiates a new ArcFollowCamera
  92676. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92677. * @param name Define the name of the camera
  92678. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92679. * @param beta Define the rotation angle of the camera around the elevation axis
  92680. * @param radius Define the radius of the camera from its target point
  92681. * @param target Define the target of the camera
  92682. * @param scene Define the scene the camera belongs to
  92683. */
  92684. constructor(name: string,
  92685. /** The longitudinal angle of the camera */
  92686. alpha: number,
  92687. /** The latitudinal angle of the camera */
  92688. beta: number,
  92689. /** The radius of the camera from its target */
  92690. radius: number,
  92691. /** Define the camera target (the messh it should follow) */
  92692. target: Nullable<AbstractMesh>, scene: Scene);
  92693. private _follow;
  92694. /** @hidden */
  92695. _checkInputs(): void;
  92696. /**
  92697. * Returns the class name of the object.
  92698. * It is mostly used internally for serialization purposes.
  92699. */
  92700. getClassName(): string;
  92701. }
  92702. }
  92703. declare module BABYLON {
  92704. /**
  92705. * 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,
  92706. * which still works and will still be found in many Playgrounds.
  92707. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92708. */
  92709. export class UniversalCamera extends TouchCamera {
  92710. /**
  92711. * Defines the gamepad rotation sensiblity.
  92712. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92713. */
  92714. gamepadAngularSensibility: number;
  92715. /**
  92716. * Defines the gamepad move sensiblity.
  92717. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92718. */
  92719. gamepadMoveSensibility: number;
  92720. /**
  92721. * 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,
  92722. * which still works and will still be found in many Playgrounds.
  92723. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92724. * @param name Define the name of the camera in the scene
  92725. * @param position Define the start position of the camera in the scene
  92726. * @param scene Define the scene the camera belongs to
  92727. */
  92728. constructor(name: string, position: Vector3, scene: Scene);
  92729. /**
  92730. * Gets the current object class name.
  92731. * @return the class name
  92732. */
  92733. getClassName(): string;
  92734. }
  92735. }
  92736. declare module BABYLON {
  92737. /**
  92738. * This represents a FPS type of camera. This is only here for back compat purpose.
  92739. * Please use the UniversalCamera instead as both are identical.
  92740. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92741. */
  92742. export class GamepadCamera extends UniversalCamera {
  92743. /**
  92744. * Instantiates a new Gamepad Camera
  92745. * This represents a FPS type of camera. This is only here for back compat purpose.
  92746. * Please use the UniversalCamera instead as both are identical.
  92747. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92748. * @param name Define the name of the camera in the scene
  92749. * @param position Define the start position of the camera in the scene
  92750. * @param scene Define the scene the camera belongs to
  92751. */
  92752. constructor(name: string, position: Vector3, scene: Scene);
  92753. /**
  92754. * Gets the current object class name.
  92755. * @return the class name
  92756. */
  92757. getClassName(): string;
  92758. }
  92759. }
  92760. declare module BABYLON {
  92761. /** @hidden */
  92762. export var passPixelShader: {
  92763. name: string;
  92764. shader: string;
  92765. };
  92766. }
  92767. declare module BABYLON {
  92768. /** @hidden */
  92769. export var passCubePixelShader: {
  92770. name: string;
  92771. shader: string;
  92772. };
  92773. }
  92774. declare module BABYLON {
  92775. /**
  92776. * PassPostProcess which produces an output the same as it's input
  92777. */
  92778. export class PassPostProcess extends PostProcess {
  92779. /**
  92780. * Creates the PassPostProcess
  92781. * @param name The name of the effect.
  92782. * @param options The required width/height ratio to downsize to before computing the render pass.
  92783. * @param camera The camera to apply the render pass to.
  92784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92785. * @param engine The engine which the post process will be applied. (default: current engine)
  92786. * @param reusable If the post process can be reused on the same frame. (default: false)
  92787. * @param textureType The type of texture to be used when performing the post processing.
  92788. * @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)
  92789. */
  92790. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92791. }
  92792. /**
  92793. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  92794. */
  92795. export class PassCubePostProcess extends PostProcess {
  92796. private _face;
  92797. /**
  92798. * Gets or sets the cube face to display.
  92799. * * 0 is +X
  92800. * * 1 is -X
  92801. * * 2 is +Y
  92802. * * 3 is -Y
  92803. * * 4 is +Z
  92804. * * 5 is -Z
  92805. */
  92806. face: number;
  92807. /**
  92808. * Creates the PassCubePostProcess
  92809. * @param name The name of the effect.
  92810. * @param options The required width/height ratio to downsize to before computing the render pass.
  92811. * @param camera The camera to apply the render pass to.
  92812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92813. * @param engine The engine which the post process will be applied. (default: current engine)
  92814. * @param reusable If the post process can be reused on the same frame. (default: false)
  92815. * @param textureType The type of texture to be used when performing the post processing.
  92816. * @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)
  92817. */
  92818. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92819. }
  92820. }
  92821. declare module BABYLON {
  92822. /** @hidden */
  92823. export var anaglyphPixelShader: {
  92824. name: string;
  92825. shader: string;
  92826. };
  92827. }
  92828. declare module BABYLON {
  92829. /**
  92830. * Postprocess used to generate anaglyphic rendering
  92831. */
  92832. export class AnaglyphPostProcess extends PostProcess {
  92833. private _passedProcess;
  92834. /**
  92835. * Creates a new AnaglyphPostProcess
  92836. * @param name defines postprocess name
  92837. * @param options defines creation options or target ratio scale
  92838. * @param rigCameras defines cameras using this postprocess
  92839. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  92840. * @param engine defines hosting engine
  92841. * @param reusable defines if the postprocess will be reused multiple times per frame
  92842. */
  92843. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  92844. }
  92845. }
  92846. declare module BABYLON {
  92847. /**
  92848. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  92849. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92850. */
  92851. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  92852. /**
  92853. * Creates a new AnaglyphArcRotateCamera
  92854. * @param name defines camera name
  92855. * @param alpha defines alpha angle (in radians)
  92856. * @param beta defines beta angle (in radians)
  92857. * @param radius defines radius
  92858. * @param target defines camera target
  92859. * @param interaxialDistance defines distance between each color axis
  92860. * @param scene defines the hosting scene
  92861. */
  92862. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  92863. /**
  92864. * Gets camera class name
  92865. * @returns AnaglyphArcRotateCamera
  92866. */
  92867. getClassName(): string;
  92868. }
  92869. }
  92870. declare module BABYLON {
  92871. /**
  92872. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  92873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92874. */
  92875. export class AnaglyphFreeCamera extends FreeCamera {
  92876. /**
  92877. * Creates a new AnaglyphFreeCamera
  92878. * @param name defines camera name
  92879. * @param position defines initial position
  92880. * @param interaxialDistance defines distance between each color axis
  92881. * @param scene defines the hosting scene
  92882. */
  92883. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92884. /**
  92885. * Gets camera class name
  92886. * @returns AnaglyphFreeCamera
  92887. */
  92888. getClassName(): string;
  92889. }
  92890. }
  92891. declare module BABYLON {
  92892. /**
  92893. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  92894. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92895. */
  92896. export class AnaglyphGamepadCamera extends GamepadCamera {
  92897. /**
  92898. * Creates a new AnaglyphGamepadCamera
  92899. * @param name defines camera name
  92900. * @param position defines initial position
  92901. * @param interaxialDistance defines distance between each color axis
  92902. * @param scene defines the hosting scene
  92903. */
  92904. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92905. /**
  92906. * Gets camera class name
  92907. * @returns AnaglyphGamepadCamera
  92908. */
  92909. getClassName(): string;
  92910. }
  92911. }
  92912. declare module BABYLON {
  92913. /**
  92914. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  92915. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92916. */
  92917. export class AnaglyphUniversalCamera extends UniversalCamera {
  92918. /**
  92919. * Creates a new AnaglyphUniversalCamera
  92920. * @param name defines camera name
  92921. * @param position defines initial position
  92922. * @param interaxialDistance defines distance between each color axis
  92923. * @param scene defines the hosting scene
  92924. */
  92925. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92926. /**
  92927. * Gets camera class name
  92928. * @returns AnaglyphUniversalCamera
  92929. */
  92930. getClassName(): string;
  92931. }
  92932. }
  92933. declare module BABYLON {
  92934. /** @hidden */
  92935. export var stereoscopicInterlacePixelShader: {
  92936. name: string;
  92937. shader: string;
  92938. };
  92939. }
  92940. declare module BABYLON {
  92941. /**
  92942. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  92943. */
  92944. export class StereoscopicInterlacePostProcess extends PostProcess {
  92945. private _stepSize;
  92946. private _passedProcess;
  92947. /**
  92948. * Initializes a StereoscopicInterlacePostProcess
  92949. * @param name The name of the effect.
  92950. * @param rigCameras The rig cameras to be appled to the post process
  92951. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  92952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92953. * @param engine The engine which the post process will be applied. (default: current engine)
  92954. * @param reusable If the post process can be reused on the same frame. (default: false)
  92955. */
  92956. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  92957. }
  92958. }
  92959. declare module BABYLON {
  92960. /**
  92961. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  92962. * @see http://doc.babylonjs.com/features/cameras
  92963. */
  92964. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  92965. /**
  92966. * Creates a new StereoscopicArcRotateCamera
  92967. * @param name defines camera name
  92968. * @param alpha defines alpha angle (in radians)
  92969. * @param beta defines beta angle (in radians)
  92970. * @param radius defines radius
  92971. * @param target defines camera target
  92972. * @param interaxialDistance defines distance between each color axis
  92973. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92974. * @param scene defines the hosting scene
  92975. */
  92976. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92977. /**
  92978. * Gets camera class name
  92979. * @returns StereoscopicArcRotateCamera
  92980. */
  92981. getClassName(): string;
  92982. }
  92983. }
  92984. declare module BABYLON {
  92985. /**
  92986. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  92987. * @see http://doc.babylonjs.com/features/cameras
  92988. */
  92989. export class StereoscopicFreeCamera extends FreeCamera {
  92990. /**
  92991. * Creates a new StereoscopicFreeCamera
  92992. * @param name defines camera name
  92993. * @param position defines initial position
  92994. * @param interaxialDistance defines distance between each color axis
  92995. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92996. * @param scene defines the hosting scene
  92997. */
  92998. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92999. /**
  93000. * Gets camera class name
  93001. * @returns StereoscopicFreeCamera
  93002. */
  93003. getClassName(): string;
  93004. }
  93005. }
  93006. declare module BABYLON {
  93007. /**
  93008. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  93009. * @see http://doc.babylonjs.com/features/cameras
  93010. */
  93011. export class StereoscopicGamepadCamera extends GamepadCamera {
  93012. /**
  93013. * Creates a new StereoscopicGamepadCamera
  93014. * @param name defines camera name
  93015. * @param position defines initial position
  93016. * @param interaxialDistance defines distance between each color axis
  93017. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93018. * @param scene defines the hosting scene
  93019. */
  93020. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93021. /**
  93022. * Gets camera class name
  93023. * @returns StereoscopicGamepadCamera
  93024. */
  93025. getClassName(): string;
  93026. }
  93027. }
  93028. declare module BABYLON {
  93029. /**
  93030. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  93031. * @see http://doc.babylonjs.com/features/cameras
  93032. */
  93033. export class StereoscopicUniversalCamera extends UniversalCamera {
  93034. /**
  93035. * Creates a new StereoscopicUniversalCamera
  93036. * @param name defines camera name
  93037. * @param position defines initial position
  93038. * @param interaxialDistance defines distance between each color axis
  93039. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93040. * @param scene defines the hosting scene
  93041. */
  93042. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93043. /**
  93044. * Gets camera class name
  93045. * @returns StereoscopicUniversalCamera
  93046. */
  93047. getClassName(): string;
  93048. }
  93049. }
  93050. declare module BABYLON {
  93051. /**
  93052. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93053. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93054. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93055. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93056. */
  93057. export class VirtualJoysticksCamera extends FreeCamera {
  93058. /**
  93059. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  93060. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93061. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93062. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93063. * @param name Define the name of the camera in the scene
  93064. * @param position Define the start position of the camera in the scene
  93065. * @param scene Define the scene the camera belongs to
  93066. */
  93067. constructor(name: string, position: Vector3, scene: Scene);
  93068. /**
  93069. * Gets the current object class name.
  93070. * @return the class name
  93071. */
  93072. getClassName(): string;
  93073. }
  93074. }
  93075. declare module BABYLON {
  93076. /**
  93077. * This represents all the required metrics to create a VR camera.
  93078. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93079. */
  93080. export class VRCameraMetrics {
  93081. /**
  93082. * Define the horizontal resolution off the screen.
  93083. */
  93084. hResolution: number;
  93085. /**
  93086. * Define the vertical resolution off the screen.
  93087. */
  93088. vResolution: number;
  93089. /**
  93090. * Define the horizontal screen size.
  93091. */
  93092. hScreenSize: number;
  93093. /**
  93094. * Define the vertical screen size.
  93095. */
  93096. vScreenSize: number;
  93097. /**
  93098. * Define the vertical screen center position.
  93099. */
  93100. vScreenCenter: number;
  93101. /**
  93102. * Define the distance of the eyes to the screen.
  93103. */
  93104. eyeToScreenDistance: number;
  93105. /**
  93106. * Define the distance between both lenses
  93107. */
  93108. lensSeparationDistance: number;
  93109. /**
  93110. * Define the distance between both viewer's eyes.
  93111. */
  93112. interpupillaryDistance: number;
  93113. /**
  93114. * Define the distortion factor of the VR postprocess.
  93115. * Please, touch with care.
  93116. */
  93117. distortionK: number[];
  93118. /**
  93119. * Define the chromatic aberration correction factors for the VR post process.
  93120. */
  93121. chromaAbCorrection: number[];
  93122. /**
  93123. * Define the scale factor of the post process.
  93124. * The smaller the better but the slower.
  93125. */
  93126. postProcessScaleFactor: number;
  93127. /**
  93128. * Define an offset for the lens center.
  93129. */
  93130. lensCenterOffset: number;
  93131. /**
  93132. * Define if the current vr camera should compensate the distortion of the lense or not.
  93133. */
  93134. compensateDistortion: boolean;
  93135. /**
  93136. * Gets the rendering aspect ratio based on the provided resolutions.
  93137. */
  93138. readonly aspectRatio: number;
  93139. /**
  93140. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93141. */
  93142. readonly aspectRatioFov: number;
  93143. /**
  93144. * @hidden
  93145. */
  93146. readonly leftHMatrix: Matrix;
  93147. /**
  93148. * @hidden
  93149. */
  93150. readonly rightHMatrix: Matrix;
  93151. /**
  93152. * @hidden
  93153. */
  93154. readonly leftPreViewMatrix: Matrix;
  93155. /**
  93156. * @hidden
  93157. */
  93158. readonly rightPreViewMatrix: Matrix;
  93159. /**
  93160. * Get the default VRMetrics based on the most generic setup.
  93161. * @returns the default vr metrics
  93162. */
  93163. static GetDefault(): VRCameraMetrics;
  93164. }
  93165. }
  93166. declare module BABYLON {
  93167. /** @hidden */
  93168. export var vrDistortionCorrectionPixelShader: {
  93169. name: string;
  93170. shader: string;
  93171. };
  93172. }
  93173. declare module BABYLON {
  93174. /**
  93175. * VRDistortionCorrectionPostProcess used for mobile VR
  93176. */
  93177. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93178. private _isRightEye;
  93179. private _distortionFactors;
  93180. private _postProcessScaleFactor;
  93181. private _lensCenterOffset;
  93182. private _scaleIn;
  93183. private _scaleFactor;
  93184. private _lensCenter;
  93185. /**
  93186. * Initializes the VRDistortionCorrectionPostProcess
  93187. * @param name The name of the effect.
  93188. * @param camera The camera to apply the render pass to.
  93189. * @param isRightEye If this is for the right eye distortion
  93190. * @param vrMetrics All the required metrics for the VR camera
  93191. */
  93192. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93193. }
  93194. }
  93195. declare module BABYLON {
  93196. /**
  93197. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93198. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93199. */
  93200. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93201. /**
  93202. * Creates a new VRDeviceOrientationArcRotateCamera
  93203. * @param name defines camera name
  93204. * @param alpha defines the camera rotation along the logitudinal axis
  93205. * @param beta defines the camera rotation along the latitudinal axis
  93206. * @param radius defines the camera distance from its target
  93207. * @param target defines the camera target
  93208. * @param scene defines the scene the camera belongs to
  93209. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93210. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93211. */
  93212. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93213. /**
  93214. * Gets camera class name
  93215. * @returns VRDeviceOrientationArcRotateCamera
  93216. */
  93217. getClassName(): string;
  93218. }
  93219. }
  93220. declare module BABYLON {
  93221. /**
  93222. * Camera used to simulate VR rendering (based on FreeCamera)
  93223. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93224. */
  93225. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93226. /**
  93227. * Creates a new VRDeviceOrientationFreeCamera
  93228. * @param name defines camera name
  93229. * @param position defines the start position of the camera
  93230. * @param scene defines the scene the camera belongs to
  93231. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93232. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93233. */
  93234. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93235. /**
  93236. * Gets camera class name
  93237. * @returns VRDeviceOrientationFreeCamera
  93238. */
  93239. getClassName(): string;
  93240. }
  93241. }
  93242. declare module BABYLON {
  93243. /**
  93244. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93245. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93246. */
  93247. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93248. /**
  93249. * Creates a new VRDeviceOrientationGamepadCamera
  93250. * @param name defines camera name
  93251. * @param position defines the start position of the camera
  93252. * @param scene defines the scene the camera belongs to
  93253. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93254. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93255. */
  93256. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93257. /**
  93258. * Gets camera class name
  93259. * @returns VRDeviceOrientationGamepadCamera
  93260. */
  93261. getClassName(): string;
  93262. }
  93263. }
  93264. declare module BABYLON {
  93265. /**
  93266. * Defines supported buttons for XBox360 compatible gamepads
  93267. */
  93268. export enum Xbox360Button {
  93269. /** A */
  93270. A = 0,
  93271. /** B */
  93272. B = 1,
  93273. /** X */
  93274. X = 2,
  93275. /** Y */
  93276. Y = 3,
  93277. /** Start */
  93278. Start = 4,
  93279. /** Back */
  93280. Back = 5,
  93281. /** Left button */
  93282. LB = 6,
  93283. /** Right button */
  93284. RB = 7,
  93285. /** Left stick */
  93286. LeftStick = 8,
  93287. /** Right stick */
  93288. RightStick = 9
  93289. }
  93290. /** Defines values for XBox360 DPad */
  93291. export enum Xbox360Dpad {
  93292. /** Up */
  93293. Up = 0,
  93294. /** Down */
  93295. Down = 1,
  93296. /** Left */
  93297. Left = 2,
  93298. /** Right */
  93299. Right = 3
  93300. }
  93301. /**
  93302. * Defines a XBox360 gamepad
  93303. */
  93304. export class Xbox360Pad extends Gamepad {
  93305. private _leftTrigger;
  93306. private _rightTrigger;
  93307. private _onlefttriggerchanged;
  93308. private _onrighttriggerchanged;
  93309. private _onbuttondown;
  93310. private _onbuttonup;
  93311. private _ondpaddown;
  93312. private _ondpadup;
  93313. /** Observable raised when a button is pressed */
  93314. onButtonDownObservable: Observable<Xbox360Button>;
  93315. /** Observable raised when a button is released */
  93316. onButtonUpObservable: Observable<Xbox360Button>;
  93317. /** Observable raised when a pad is pressed */
  93318. onPadDownObservable: Observable<Xbox360Dpad>;
  93319. /** Observable raised when a pad is released */
  93320. onPadUpObservable: Observable<Xbox360Dpad>;
  93321. private _buttonA;
  93322. private _buttonB;
  93323. private _buttonX;
  93324. private _buttonY;
  93325. private _buttonBack;
  93326. private _buttonStart;
  93327. private _buttonLB;
  93328. private _buttonRB;
  93329. private _buttonLeftStick;
  93330. private _buttonRightStick;
  93331. private _dPadUp;
  93332. private _dPadDown;
  93333. private _dPadLeft;
  93334. private _dPadRight;
  93335. private _isXboxOnePad;
  93336. /**
  93337. * Creates a new XBox360 gamepad object
  93338. * @param id defines the id of this gamepad
  93339. * @param index defines its index
  93340. * @param gamepad defines the internal HTML gamepad object
  93341. * @param xboxOne defines if it is a XBox One gamepad
  93342. */
  93343. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93344. /**
  93345. * Defines the callback to call when left trigger is pressed
  93346. * @param callback defines the callback to use
  93347. */
  93348. onlefttriggerchanged(callback: (value: number) => void): void;
  93349. /**
  93350. * Defines the callback to call when right trigger is pressed
  93351. * @param callback defines the callback to use
  93352. */
  93353. onrighttriggerchanged(callback: (value: number) => void): void;
  93354. /**
  93355. * Gets the left trigger value
  93356. */
  93357. /**
  93358. * Sets the left trigger value
  93359. */
  93360. leftTrigger: number;
  93361. /**
  93362. * Gets the right trigger value
  93363. */
  93364. /**
  93365. * Sets the right trigger value
  93366. */
  93367. rightTrigger: number;
  93368. /**
  93369. * Defines the callback to call when a button is pressed
  93370. * @param callback defines the callback to use
  93371. */
  93372. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93373. /**
  93374. * Defines the callback to call when a button is released
  93375. * @param callback defines the callback to use
  93376. */
  93377. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93378. /**
  93379. * Defines the callback to call when a pad is pressed
  93380. * @param callback defines the callback to use
  93381. */
  93382. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93383. /**
  93384. * Defines the callback to call when a pad is released
  93385. * @param callback defines the callback to use
  93386. */
  93387. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93388. private _setButtonValue;
  93389. private _setDPadValue;
  93390. /**
  93391. * Gets the value of the `A` button
  93392. */
  93393. /**
  93394. * Sets the value of the `A` button
  93395. */
  93396. buttonA: number;
  93397. /**
  93398. * Gets the value of the `B` button
  93399. */
  93400. /**
  93401. * Sets the value of the `B` button
  93402. */
  93403. buttonB: number;
  93404. /**
  93405. * Gets the value of the `X` button
  93406. */
  93407. /**
  93408. * Sets the value of the `X` button
  93409. */
  93410. buttonX: number;
  93411. /**
  93412. * Gets the value of the `Y` button
  93413. */
  93414. /**
  93415. * Sets the value of the `Y` button
  93416. */
  93417. buttonY: number;
  93418. /**
  93419. * Gets the value of the `Start` button
  93420. */
  93421. /**
  93422. * Sets the value of the `Start` button
  93423. */
  93424. buttonStart: number;
  93425. /**
  93426. * Gets the value of the `Back` button
  93427. */
  93428. /**
  93429. * Sets the value of the `Back` button
  93430. */
  93431. buttonBack: number;
  93432. /**
  93433. * Gets the value of the `Left` button
  93434. */
  93435. /**
  93436. * Sets the value of the `Left` button
  93437. */
  93438. buttonLB: number;
  93439. /**
  93440. * Gets the value of the `Right` button
  93441. */
  93442. /**
  93443. * Sets the value of the `Right` button
  93444. */
  93445. buttonRB: number;
  93446. /**
  93447. * Gets the value of the Left joystick
  93448. */
  93449. /**
  93450. * Sets the value of the Left joystick
  93451. */
  93452. buttonLeftStick: number;
  93453. /**
  93454. * Gets the value of the Right joystick
  93455. */
  93456. /**
  93457. * Sets the value of the Right joystick
  93458. */
  93459. buttonRightStick: number;
  93460. /**
  93461. * Gets the value of D-pad up
  93462. */
  93463. /**
  93464. * Sets the value of D-pad up
  93465. */
  93466. dPadUp: number;
  93467. /**
  93468. * Gets the value of D-pad down
  93469. */
  93470. /**
  93471. * Sets the value of D-pad down
  93472. */
  93473. dPadDown: number;
  93474. /**
  93475. * Gets the value of D-pad left
  93476. */
  93477. /**
  93478. * Sets the value of D-pad left
  93479. */
  93480. dPadLeft: number;
  93481. /**
  93482. * Gets the value of D-pad right
  93483. */
  93484. /**
  93485. * Sets the value of D-pad right
  93486. */
  93487. dPadRight: number;
  93488. /**
  93489. * Force the gamepad to synchronize with device values
  93490. */
  93491. update(): void;
  93492. /**
  93493. * Disposes the gamepad
  93494. */
  93495. dispose(): void;
  93496. }
  93497. }
  93498. declare module BABYLON {
  93499. /**
  93500. * Base class of materials working in push mode in babylon JS
  93501. * @hidden
  93502. */
  93503. export class PushMaterial extends Material {
  93504. protected _activeEffect: Effect;
  93505. protected _normalMatrix: Matrix;
  93506. /**
  93507. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93508. * This means that the material can keep using a previous shader while a new one is being compiled.
  93509. * This is mostly used when shader parallel compilation is supported (true by default)
  93510. */
  93511. allowShaderHotSwapping: boolean;
  93512. constructor(name: string, scene: Scene);
  93513. getEffect(): Effect;
  93514. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93515. /**
  93516. * Binds the given world matrix to the active effect
  93517. *
  93518. * @param world the matrix to bind
  93519. */
  93520. bindOnlyWorldMatrix(world: Matrix): void;
  93521. /**
  93522. * Binds the given normal matrix to the active effect
  93523. *
  93524. * @param normalMatrix the matrix to bind
  93525. */
  93526. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93527. bind(world: Matrix, mesh?: Mesh): void;
  93528. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93529. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93530. }
  93531. }
  93532. declare module BABYLON {
  93533. /**
  93534. * This groups all the flags used to control the materials channel.
  93535. */
  93536. export class MaterialFlags {
  93537. private static _DiffuseTextureEnabled;
  93538. /**
  93539. * Are diffuse textures enabled in the application.
  93540. */
  93541. static DiffuseTextureEnabled: boolean;
  93542. private static _AmbientTextureEnabled;
  93543. /**
  93544. * Are ambient textures enabled in the application.
  93545. */
  93546. static AmbientTextureEnabled: boolean;
  93547. private static _OpacityTextureEnabled;
  93548. /**
  93549. * Are opacity textures enabled in the application.
  93550. */
  93551. static OpacityTextureEnabled: boolean;
  93552. private static _ReflectionTextureEnabled;
  93553. /**
  93554. * Are reflection textures enabled in the application.
  93555. */
  93556. static ReflectionTextureEnabled: boolean;
  93557. private static _EmissiveTextureEnabled;
  93558. /**
  93559. * Are emissive textures enabled in the application.
  93560. */
  93561. static EmissiveTextureEnabled: boolean;
  93562. private static _SpecularTextureEnabled;
  93563. /**
  93564. * Are specular textures enabled in the application.
  93565. */
  93566. static SpecularTextureEnabled: boolean;
  93567. private static _BumpTextureEnabled;
  93568. /**
  93569. * Are bump textures enabled in the application.
  93570. */
  93571. static BumpTextureEnabled: boolean;
  93572. private static _LightmapTextureEnabled;
  93573. /**
  93574. * Are lightmap textures enabled in the application.
  93575. */
  93576. static LightmapTextureEnabled: boolean;
  93577. private static _RefractionTextureEnabled;
  93578. /**
  93579. * Are refraction textures enabled in the application.
  93580. */
  93581. static RefractionTextureEnabled: boolean;
  93582. private static _ColorGradingTextureEnabled;
  93583. /**
  93584. * Are color grading textures enabled in the application.
  93585. */
  93586. static ColorGradingTextureEnabled: boolean;
  93587. private static _FresnelEnabled;
  93588. /**
  93589. * Are fresnels enabled in the application.
  93590. */
  93591. static FresnelEnabled: boolean;
  93592. }
  93593. }
  93594. declare module BABYLON {
  93595. /** @hidden */
  93596. export var defaultFragmentDeclaration: {
  93597. name: string;
  93598. shader: string;
  93599. };
  93600. }
  93601. declare module BABYLON {
  93602. /** @hidden */
  93603. export var defaultUboDeclaration: {
  93604. name: string;
  93605. shader: string;
  93606. };
  93607. }
  93608. declare module BABYLON {
  93609. /** @hidden */
  93610. export var lightFragmentDeclaration: {
  93611. name: string;
  93612. shader: string;
  93613. };
  93614. }
  93615. declare module BABYLON {
  93616. /** @hidden */
  93617. export var lightUboDeclaration: {
  93618. name: string;
  93619. shader: string;
  93620. };
  93621. }
  93622. declare module BABYLON {
  93623. /** @hidden */
  93624. export var lightsFragmentFunctions: {
  93625. name: string;
  93626. shader: string;
  93627. };
  93628. }
  93629. declare module BABYLON {
  93630. /** @hidden */
  93631. export var shadowsFragmentFunctions: {
  93632. name: string;
  93633. shader: string;
  93634. };
  93635. }
  93636. declare module BABYLON {
  93637. /** @hidden */
  93638. export var fresnelFunction: {
  93639. name: string;
  93640. shader: string;
  93641. };
  93642. }
  93643. declare module BABYLON {
  93644. /** @hidden */
  93645. export var reflectionFunction: {
  93646. name: string;
  93647. shader: string;
  93648. };
  93649. }
  93650. declare module BABYLON {
  93651. /** @hidden */
  93652. export var bumpFragmentFunctions: {
  93653. name: string;
  93654. shader: string;
  93655. };
  93656. }
  93657. declare module BABYLON {
  93658. /** @hidden */
  93659. export var logDepthDeclaration: {
  93660. name: string;
  93661. shader: string;
  93662. };
  93663. }
  93664. declare module BABYLON {
  93665. /** @hidden */
  93666. export var bumpFragment: {
  93667. name: string;
  93668. shader: string;
  93669. };
  93670. }
  93671. declare module BABYLON {
  93672. /** @hidden */
  93673. export var depthPrePass: {
  93674. name: string;
  93675. shader: string;
  93676. };
  93677. }
  93678. declare module BABYLON {
  93679. /** @hidden */
  93680. export var lightFragment: {
  93681. name: string;
  93682. shader: string;
  93683. };
  93684. }
  93685. declare module BABYLON {
  93686. /** @hidden */
  93687. export var logDepthFragment: {
  93688. name: string;
  93689. shader: string;
  93690. };
  93691. }
  93692. declare module BABYLON {
  93693. /** @hidden */
  93694. export var defaultPixelShader: {
  93695. name: string;
  93696. shader: string;
  93697. };
  93698. }
  93699. declare module BABYLON {
  93700. /** @hidden */
  93701. export var defaultVertexDeclaration: {
  93702. name: string;
  93703. shader: string;
  93704. };
  93705. }
  93706. declare module BABYLON {
  93707. /** @hidden */
  93708. export var bumpVertexDeclaration: {
  93709. name: string;
  93710. shader: string;
  93711. };
  93712. }
  93713. declare module BABYLON {
  93714. /** @hidden */
  93715. export var bumpVertex: {
  93716. name: string;
  93717. shader: string;
  93718. };
  93719. }
  93720. declare module BABYLON {
  93721. /** @hidden */
  93722. export var fogVertex: {
  93723. name: string;
  93724. shader: string;
  93725. };
  93726. }
  93727. declare module BABYLON {
  93728. /** @hidden */
  93729. export var shadowsVertex: {
  93730. name: string;
  93731. shader: string;
  93732. };
  93733. }
  93734. declare module BABYLON {
  93735. /** @hidden */
  93736. export var pointCloudVertex: {
  93737. name: string;
  93738. shader: string;
  93739. };
  93740. }
  93741. declare module BABYLON {
  93742. /** @hidden */
  93743. export var logDepthVertex: {
  93744. name: string;
  93745. shader: string;
  93746. };
  93747. }
  93748. declare module BABYLON {
  93749. /** @hidden */
  93750. export var defaultVertexShader: {
  93751. name: string;
  93752. shader: string;
  93753. };
  93754. }
  93755. declare module BABYLON {
  93756. /** @hidden */
  93757. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93758. MAINUV1: boolean;
  93759. MAINUV2: boolean;
  93760. DIFFUSE: boolean;
  93761. DIFFUSEDIRECTUV: number;
  93762. AMBIENT: boolean;
  93763. AMBIENTDIRECTUV: number;
  93764. OPACITY: boolean;
  93765. OPACITYDIRECTUV: number;
  93766. OPACITYRGB: boolean;
  93767. REFLECTION: boolean;
  93768. EMISSIVE: boolean;
  93769. EMISSIVEDIRECTUV: number;
  93770. SPECULAR: boolean;
  93771. SPECULARDIRECTUV: number;
  93772. BUMP: boolean;
  93773. BUMPDIRECTUV: number;
  93774. PARALLAX: boolean;
  93775. PARALLAXOCCLUSION: boolean;
  93776. SPECULAROVERALPHA: boolean;
  93777. CLIPPLANE: boolean;
  93778. CLIPPLANE2: boolean;
  93779. CLIPPLANE3: boolean;
  93780. CLIPPLANE4: boolean;
  93781. ALPHATEST: boolean;
  93782. DEPTHPREPASS: boolean;
  93783. ALPHAFROMDIFFUSE: boolean;
  93784. POINTSIZE: boolean;
  93785. FOG: boolean;
  93786. SPECULARTERM: boolean;
  93787. DIFFUSEFRESNEL: boolean;
  93788. OPACITYFRESNEL: boolean;
  93789. REFLECTIONFRESNEL: boolean;
  93790. REFRACTIONFRESNEL: boolean;
  93791. EMISSIVEFRESNEL: boolean;
  93792. FRESNEL: boolean;
  93793. NORMAL: boolean;
  93794. UV1: boolean;
  93795. UV2: boolean;
  93796. VERTEXCOLOR: boolean;
  93797. VERTEXALPHA: boolean;
  93798. NUM_BONE_INFLUENCERS: number;
  93799. BonesPerMesh: number;
  93800. BONETEXTURE: boolean;
  93801. INSTANCES: boolean;
  93802. GLOSSINESS: boolean;
  93803. ROUGHNESS: boolean;
  93804. EMISSIVEASILLUMINATION: boolean;
  93805. LINKEMISSIVEWITHDIFFUSE: boolean;
  93806. REFLECTIONFRESNELFROMSPECULAR: boolean;
  93807. LIGHTMAP: boolean;
  93808. LIGHTMAPDIRECTUV: number;
  93809. OBJECTSPACE_NORMALMAP: boolean;
  93810. USELIGHTMAPASSHADOWMAP: boolean;
  93811. REFLECTIONMAP_3D: boolean;
  93812. REFLECTIONMAP_SPHERICAL: boolean;
  93813. REFLECTIONMAP_PLANAR: boolean;
  93814. REFLECTIONMAP_CUBIC: boolean;
  93815. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  93816. REFLECTIONMAP_PROJECTION: boolean;
  93817. REFLECTIONMAP_SKYBOX: boolean;
  93818. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  93819. REFLECTIONMAP_EXPLICIT: boolean;
  93820. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  93821. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  93822. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  93823. INVERTCUBICMAP: boolean;
  93824. LOGARITHMICDEPTH: boolean;
  93825. REFRACTION: boolean;
  93826. REFRACTIONMAP_3D: boolean;
  93827. REFLECTIONOVERALPHA: boolean;
  93828. TWOSIDEDLIGHTING: boolean;
  93829. SHADOWFLOAT: boolean;
  93830. MORPHTARGETS: boolean;
  93831. MORPHTARGETS_NORMAL: boolean;
  93832. MORPHTARGETS_TANGENT: boolean;
  93833. NUM_MORPH_INFLUENCERS: number;
  93834. NONUNIFORMSCALING: boolean;
  93835. PREMULTIPLYALPHA: boolean;
  93836. IMAGEPROCESSING: boolean;
  93837. VIGNETTE: boolean;
  93838. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93839. VIGNETTEBLENDMODEOPAQUE: boolean;
  93840. TONEMAPPING: boolean;
  93841. TONEMAPPING_ACES: boolean;
  93842. CONTRAST: boolean;
  93843. COLORCURVES: boolean;
  93844. COLORGRADING: boolean;
  93845. COLORGRADING3D: boolean;
  93846. SAMPLER3DGREENDEPTH: boolean;
  93847. SAMPLER3DBGRMAP: boolean;
  93848. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93849. /**
  93850. * If the reflection texture on this material is in linear color space
  93851. * @hidden
  93852. */
  93853. IS_REFLECTION_LINEAR: boolean;
  93854. /**
  93855. * If the refraction texture on this material is in linear color space
  93856. * @hidden
  93857. */
  93858. IS_REFRACTION_LINEAR: boolean;
  93859. EXPOSURE: boolean;
  93860. constructor();
  93861. setReflectionMode(modeToEnable: string): void;
  93862. }
  93863. /**
  93864. * This is the default material used in Babylon. It is the best trade off between quality
  93865. * and performances.
  93866. * @see http://doc.babylonjs.com/babylon101/materials
  93867. */
  93868. export class StandardMaterial extends PushMaterial {
  93869. private _diffuseTexture;
  93870. /**
  93871. * The basic texture of the material as viewed under a light.
  93872. */
  93873. diffuseTexture: Nullable<BaseTexture>;
  93874. private _ambientTexture;
  93875. /**
  93876. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  93877. */
  93878. ambientTexture: Nullable<BaseTexture>;
  93879. private _opacityTexture;
  93880. /**
  93881. * Define the transparency of the material from a texture.
  93882. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  93883. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  93884. */
  93885. opacityTexture: Nullable<BaseTexture>;
  93886. private _reflectionTexture;
  93887. /**
  93888. * Define the texture used to display the reflection.
  93889. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93890. */
  93891. reflectionTexture: Nullable<BaseTexture>;
  93892. private _emissiveTexture;
  93893. /**
  93894. * Define texture of the material as if self lit.
  93895. * This will be mixed in the final result even in the absence of light.
  93896. */
  93897. emissiveTexture: Nullable<BaseTexture>;
  93898. private _specularTexture;
  93899. /**
  93900. * Define how the color and intensity of the highlight given by the light in the material.
  93901. */
  93902. specularTexture: Nullable<BaseTexture>;
  93903. private _bumpTexture;
  93904. /**
  93905. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  93906. * 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.
  93907. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  93908. */
  93909. bumpTexture: Nullable<BaseTexture>;
  93910. private _lightmapTexture;
  93911. /**
  93912. * Complex lighting can be computationally expensive to compute at runtime.
  93913. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  93914. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  93915. */
  93916. lightmapTexture: Nullable<BaseTexture>;
  93917. private _refractionTexture;
  93918. /**
  93919. * Define the texture used to display the refraction.
  93920. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93921. */
  93922. refractionTexture: Nullable<BaseTexture>;
  93923. /**
  93924. * The color of the material lit by the environmental background lighting.
  93925. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  93926. */
  93927. ambientColor: Color3;
  93928. /**
  93929. * The basic color of the material as viewed under a light.
  93930. */
  93931. diffuseColor: Color3;
  93932. /**
  93933. * Define how the color and intensity of the highlight given by the light in the material.
  93934. */
  93935. specularColor: Color3;
  93936. /**
  93937. * Define the color of the material as if self lit.
  93938. * This will be mixed in the final result even in the absence of light.
  93939. */
  93940. emissiveColor: Color3;
  93941. /**
  93942. * Defines how sharp are the highlights in the material.
  93943. * The bigger the value the sharper giving a more glossy feeling to the result.
  93944. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  93945. */
  93946. specularPower: number;
  93947. private _useAlphaFromDiffuseTexture;
  93948. /**
  93949. * Does the transparency come from the diffuse texture alpha channel.
  93950. */
  93951. useAlphaFromDiffuseTexture: boolean;
  93952. private _useEmissiveAsIllumination;
  93953. /**
  93954. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  93955. */
  93956. useEmissiveAsIllumination: boolean;
  93957. private _linkEmissiveWithDiffuse;
  93958. /**
  93959. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  93960. * the emissive level when the final color is close to one.
  93961. */
  93962. linkEmissiveWithDiffuse: boolean;
  93963. private _useSpecularOverAlpha;
  93964. /**
  93965. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  93966. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  93967. */
  93968. useSpecularOverAlpha: boolean;
  93969. private _useReflectionOverAlpha;
  93970. /**
  93971. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  93972. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  93973. */
  93974. useReflectionOverAlpha: boolean;
  93975. private _disableLighting;
  93976. /**
  93977. * Does lights from the scene impacts this material.
  93978. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  93979. */
  93980. disableLighting: boolean;
  93981. private _useObjectSpaceNormalMap;
  93982. /**
  93983. * Allows using an object space normal map (instead of tangent space).
  93984. */
  93985. useObjectSpaceNormalMap: boolean;
  93986. private _useParallax;
  93987. /**
  93988. * Is parallax enabled or not.
  93989. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93990. */
  93991. useParallax: boolean;
  93992. private _useParallaxOcclusion;
  93993. /**
  93994. * Is parallax occlusion enabled or not.
  93995. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  93996. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93997. */
  93998. useParallaxOcclusion: boolean;
  93999. /**
  94000. * 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.
  94001. */
  94002. parallaxScaleBias: number;
  94003. private _roughness;
  94004. /**
  94005. * Helps to define how blurry the reflections should appears in the material.
  94006. */
  94007. roughness: number;
  94008. /**
  94009. * In case of refraction, define the value of the indice of refraction.
  94010. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94011. */
  94012. indexOfRefraction: number;
  94013. /**
  94014. * Invert the refraction texture alongside the y axis.
  94015. * It can be useful with procedural textures or probe for instance.
  94016. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94017. */
  94018. invertRefractionY: boolean;
  94019. /**
  94020. * Defines the alpha limits in alpha test mode.
  94021. */
  94022. alphaCutOff: number;
  94023. private _useLightmapAsShadowmap;
  94024. /**
  94025. * In case of light mapping, define whether the map contains light or shadow informations.
  94026. */
  94027. useLightmapAsShadowmap: boolean;
  94028. private _diffuseFresnelParameters;
  94029. /**
  94030. * Define the diffuse fresnel parameters of the material.
  94031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94032. */
  94033. diffuseFresnelParameters: FresnelParameters;
  94034. private _opacityFresnelParameters;
  94035. /**
  94036. * Define the opacity fresnel parameters of the material.
  94037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94038. */
  94039. opacityFresnelParameters: FresnelParameters;
  94040. private _reflectionFresnelParameters;
  94041. /**
  94042. * Define the reflection fresnel parameters of the material.
  94043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94044. */
  94045. reflectionFresnelParameters: FresnelParameters;
  94046. private _refractionFresnelParameters;
  94047. /**
  94048. * Define the refraction fresnel parameters of the material.
  94049. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94050. */
  94051. refractionFresnelParameters: FresnelParameters;
  94052. private _emissiveFresnelParameters;
  94053. /**
  94054. * Define the emissive fresnel parameters of the material.
  94055. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94056. */
  94057. emissiveFresnelParameters: FresnelParameters;
  94058. private _useReflectionFresnelFromSpecular;
  94059. /**
  94060. * If true automatically deducts the fresnels values from the material specularity.
  94061. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94062. */
  94063. useReflectionFresnelFromSpecular: boolean;
  94064. private _useGlossinessFromSpecularMapAlpha;
  94065. /**
  94066. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  94067. */
  94068. useGlossinessFromSpecularMapAlpha: boolean;
  94069. private _maxSimultaneousLights;
  94070. /**
  94071. * Defines the maximum number of lights that can be used in the material
  94072. */
  94073. maxSimultaneousLights: number;
  94074. private _invertNormalMapX;
  94075. /**
  94076. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  94077. */
  94078. invertNormalMapX: boolean;
  94079. private _invertNormalMapY;
  94080. /**
  94081. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94082. */
  94083. invertNormalMapY: boolean;
  94084. private _twoSidedLighting;
  94085. /**
  94086. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94087. */
  94088. twoSidedLighting: boolean;
  94089. /**
  94090. * Default configuration related to image processing available in the standard Material.
  94091. */
  94092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94093. /**
  94094. * Gets the image processing configuration used either in this material.
  94095. */
  94096. /**
  94097. * Sets the Default image processing configuration used either in the this material.
  94098. *
  94099. * If sets to null, the scene one is in use.
  94100. */
  94101. imageProcessingConfiguration: ImageProcessingConfiguration;
  94102. /**
  94103. * Keep track of the image processing observer to allow dispose and replace.
  94104. */
  94105. private _imageProcessingObserver;
  94106. /**
  94107. * Attaches a new image processing configuration to the Standard Material.
  94108. * @param configuration
  94109. */
  94110. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94111. /**
  94112. * Gets wether the color curves effect is enabled.
  94113. */
  94114. /**
  94115. * Sets wether the color curves effect is enabled.
  94116. */
  94117. cameraColorCurvesEnabled: boolean;
  94118. /**
  94119. * Gets wether the color grading effect is enabled.
  94120. */
  94121. /**
  94122. * Gets wether the color grading effect is enabled.
  94123. */
  94124. cameraColorGradingEnabled: boolean;
  94125. /**
  94126. * Gets wether tonemapping is enabled or not.
  94127. */
  94128. /**
  94129. * Sets wether tonemapping is enabled or not
  94130. */
  94131. cameraToneMappingEnabled: boolean;
  94132. /**
  94133. * The camera exposure used on this material.
  94134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94135. * This corresponds to a photographic exposure.
  94136. */
  94137. /**
  94138. * The camera exposure used on this material.
  94139. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94140. * This corresponds to a photographic exposure.
  94141. */
  94142. cameraExposure: number;
  94143. /**
  94144. * Gets The camera contrast used on this material.
  94145. */
  94146. /**
  94147. * Sets The camera contrast used on this material.
  94148. */
  94149. cameraContrast: number;
  94150. /**
  94151. * Gets the Color Grading 2D Lookup Texture.
  94152. */
  94153. /**
  94154. * Sets the Color Grading 2D Lookup Texture.
  94155. */
  94156. cameraColorGradingTexture: Nullable<BaseTexture>;
  94157. /**
  94158. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94159. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94160. * 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;
  94161. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94162. */
  94163. /**
  94164. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94165. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94166. * 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;
  94167. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94168. */
  94169. cameraColorCurves: Nullable<ColorCurves>;
  94170. /**
  94171. * Custom callback helping to override the default shader used in the material.
  94172. */
  94173. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94174. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94175. protected _worldViewProjectionMatrix: Matrix;
  94176. protected _globalAmbientColor: Color3;
  94177. protected _useLogarithmicDepth: boolean;
  94178. /**
  94179. * Instantiates a new standard material.
  94180. * This is the default material used in Babylon. It is the best trade off between quality
  94181. * and performances.
  94182. * @see http://doc.babylonjs.com/babylon101/materials
  94183. * @param name Define the name of the material in the scene
  94184. * @param scene Define the scene the material belong to
  94185. */
  94186. constructor(name: string, scene: Scene);
  94187. /**
  94188. * Gets a boolean indicating that current material needs to register RTT
  94189. */
  94190. readonly hasRenderTargetTextures: boolean;
  94191. /**
  94192. * Gets the current class name of the material e.g. "StandardMaterial"
  94193. * Mainly use in serialization.
  94194. * @returns the class name
  94195. */
  94196. getClassName(): string;
  94197. /**
  94198. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94199. * You can try switching to logarithmic depth.
  94200. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94201. */
  94202. useLogarithmicDepth: boolean;
  94203. /**
  94204. * Specifies if the material will require alpha blending
  94205. * @returns a boolean specifying if alpha blending is needed
  94206. */
  94207. needAlphaBlending(): boolean;
  94208. /**
  94209. * Specifies if this material should be rendered in alpha test mode
  94210. * @returns a boolean specifying if an alpha test is needed.
  94211. */
  94212. needAlphaTesting(): boolean;
  94213. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94214. /**
  94215. * Get the texture used for alpha test purpose.
  94216. * @returns the diffuse texture in case of the standard material.
  94217. */
  94218. getAlphaTestTexture(): Nullable<BaseTexture>;
  94219. /**
  94220. * Get if the submesh is ready to be used and all its information available.
  94221. * Child classes can use it to update shaders
  94222. * @param mesh defines the mesh to check
  94223. * @param subMesh defines which submesh to check
  94224. * @param useInstances specifies that instances should be used
  94225. * @returns a boolean indicating that the submesh is ready or not
  94226. */
  94227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94228. /**
  94229. * Builds the material UBO layouts.
  94230. * Used internally during the effect preparation.
  94231. */
  94232. buildUniformLayout(): void;
  94233. /**
  94234. * Unbinds the material from the mesh
  94235. */
  94236. unbind(): void;
  94237. /**
  94238. * Binds the submesh to this material by preparing the effect and shader to draw
  94239. * @param world defines the world transformation matrix
  94240. * @param mesh defines the mesh containing the submesh
  94241. * @param subMesh defines the submesh to bind the material to
  94242. */
  94243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94244. /**
  94245. * Get the list of animatables in the material.
  94246. * @returns the list of animatables object used in the material
  94247. */
  94248. getAnimatables(): IAnimatable[];
  94249. /**
  94250. * Gets the active textures from the material
  94251. * @returns an array of textures
  94252. */
  94253. getActiveTextures(): BaseTexture[];
  94254. /**
  94255. * Specifies if the material uses a texture
  94256. * @param texture defines the texture to check against the material
  94257. * @returns a boolean specifying if the material uses the texture
  94258. */
  94259. hasTexture(texture: BaseTexture): boolean;
  94260. /**
  94261. * Disposes the material
  94262. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94263. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94264. */
  94265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94266. /**
  94267. * Makes a duplicate of the material, and gives it a new name
  94268. * @param name defines the new name for the duplicated material
  94269. * @returns the cloned material
  94270. */
  94271. clone(name: string): StandardMaterial;
  94272. /**
  94273. * Serializes this material in a JSON representation
  94274. * @returns the serialized material object
  94275. */
  94276. serialize(): any;
  94277. /**
  94278. * Creates a standard material from parsed material data
  94279. * @param source defines the JSON representation of the material
  94280. * @param scene defines the hosting scene
  94281. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94282. * @returns a new standard material
  94283. */
  94284. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94285. /**
  94286. * Are diffuse textures enabled in the application.
  94287. */
  94288. static DiffuseTextureEnabled: boolean;
  94289. /**
  94290. * Are ambient textures enabled in the application.
  94291. */
  94292. static AmbientTextureEnabled: boolean;
  94293. /**
  94294. * Are opacity textures enabled in the application.
  94295. */
  94296. static OpacityTextureEnabled: boolean;
  94297. /**
  94298. * Are reflection textures enabled in the application.
  94299. */
  94300. static ReflectionTextureEnabled: boolean;
  94301. /**
  94302. * Are emissive textures enabled in the application.
  94303. */
  94304. static EmissiveTextureEnabled: boolean;
  94305. /**
  94306. * Are specular textures enabled in the application.
  94307. */
  94308. static SpecularTextureEnabled: boolean;
  94309. /**
  94310. * Are bump textures enabled in the application.
  94311. */
  94312. static BumpTextureEnabled: boolean;
  94313. /**
  94314. * Are lightmap textures enabled in the application.
  94315. */
  94316. static LightmapTextureEnabled: boolean;
  94317. /**
  94318. * Are refraction textures enabled in the application.
  94319. */
  94320. static RefractionTextureEnabled: boolean;
  94321. /**
  94322. * Are color grading textures enabled in the application.
  94323. */
  94324. static ColorGradingTextureEnabled: boolean;
  94325. /**
  94326. * Are fresnels enabled in the application.
  94327. */
  94328. static FresnelEnabled: boolean;
  94329. }
  94330. }
  94331. declare module BABYLON {
  94332. /**
  94333. * A class extending Texture allowing drawing on a texture
  94334. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94335. */
  94336. export class DynamicTexture extends Texture {
  94337. private _generateMipMaps;
  94338. private _canvas;
  94339. private _context;
  94340. private _engine;
  94341. /**
  94342. * Creates a DynamicTexture
  94343. * @param name defines the name of the texture
  94344. * @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
  94345. * @param scene defines the scene where you want the texture
  94346. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94347. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94348. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94349. */
  94350. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94351. /**
  94352. * Get the current class name of the texture useful for serialization or dynamic coding.
  94353. * @returns "DynamicTexture"
  94354. */
  94355. getClassName(): string;
  94356. /**
  94357. * Gets the current state of canRescale
  94358. */
  94359. readonly canRescale: boolean;
  94360. private _recreate;
  94361. /**
  94362. * Scales the texture
  94363. * @param ratio the scale factor to apply to both width and height
  94364. */
  94365. scale(ratio: number): void;
  94366. /**
  94367. * Resizes the texture
  94368. * @param width the new width
  94369. * @param height the new height
  94370. */
  94371. scaleTo(width: number, height: number): void;
  94372. /**
  94373. * Gets the context of the canvas used by the texture
  94374. * @returns the canvas context of the dynamic texture
  94375. */
  94376. getContext(): CanvasRenderingContext2D;
  94377. /**
  94378. * Clears the texture
  94379. */
  94380. clear(): void;
  94381. /**
  94382. * Updates the texture
  94383. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94384. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94385. */
  94386. update(invertY?: boolean, premulAlpha?: boolean): void;
  94387. /**
  94388. * Draws text onto the texture
  94389. * @param text defines the text to be drawn
  94390. * @param x defines the placement of the text from the left
  94391. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94392. * @param font defines the font to be used with font-style, font-size, font-name
  94393. * @param color defines the color used for the text
  94394. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94395. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94396. * @param update defines whether texture is immediately update (default is true)
  94397. */
  94398. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94399. /**
  94400. * Clones the texture
  94401. * @returns the clone of the texture.
  94402. */
  94403. clone(): DynamicTexture;
  94404. /**
  94405. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94406. * @returns a serialized dynamic texture object
  94407. */
  94408. serialize(): any;
  94409. /** @hidden */
  94410. _rebuild(): void;
  94411. }
  94412. }
  94413. declare module BABYLON {
  94414. /** @hidden */
  94415. export var imageProcessingPixelShader: {
  94416. name: string;
  94417. shader: string;
  94418. };
  94419. }
  94420. declare module BABYLON {
  94421. /**
  94422. * ImageProcessingPostProcess
  94423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94424. */
  94425. export class ImageProcessingPostProcess extends PostProcess {
  94426. /**
  94427. * Default configuration related to image processing available in the PBR Material.
  94428. */
  94429. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94430. /**
  94431. * Gets the image processing configuration used either in this material.
  94432. */
  94433. /**
  94434. * Sets the Default image processing configuration used either in the this material.
  94435. *
  94436. * If sets to null, the scene one is in use.
  94437. */
  94438. imageProcessingConfiguration: ImageProcessingConfiguration;
  94439. /**
  94440. * Keep track of the image processing observer to allow dispose and replace.
  94441. */
  94442. private _imageProcessingObserver;
  94443. /**
  94444. * Attaches a new image processing configuration to the PBR Material.
  94445. * @param configuration
  94446. */
  94447. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94448. /**
  94449. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94450. */
  94451. /**
  94452. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94453. */
  94454. colorCurves: Nullable<ColorCurves>;
  94455. /**
  94456. * Gets wether the color curves effect is enabled.
  94457. */
  94458. /**
  94459. * Sets wether the color curves effect is enabled.
  94460. */
  94461. colorCurvesEnabled: boolean;
  94462. /**
  94463. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94464. */
  94465. /**
  94466. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94467. */
  94468. colorGradingTexture: Nullable<BaseTexture>;
  94469. /**
  94470. * Gets wether the color grading effect is enabled.
  94471. */
  94472. /**
  94473. * Gets wether the color grading effect is enabled.
  94474. */
  94475. colorGradingEnabled: boolean;
  94476. /**
  94477. * Gets exposure used in the effect.
  94478. */
  94479. /**
  94480. * Sets exposure used in the effect.
  94481. */
  94482. exposure: number;
  94483. /**
  94484. * Gets wether tonemapping is enabled or not.
  94485. */
  94486. /**
  94487. * Sets wether tonemapping is enabled or not
  94488. */
  94489. toneMappingEnabled: boolean;
  94490. /**
  94491. * Gets contrast used in the effect.
  94492. */
  94493. /**
  94494. * Sets contrast used in the effect.
  94495. */
  94496. contrast: number;
  94497. /**
  94498. * Gets Vignette stretch size.
  94499. */
  94500. /**
  94501. * Sets Vignette stretch size.
  94502. */
  94503. vignetteStretch: number;
  94504. /**
  94505. * Gets Vignette centre X Offset.
  94506. */
  94507. /**
  94508. * Sets Vignette centre X Offset.
  94509. */
  94510. vignetteCentreX: number;
  94511. /**
  94512. * Gets Vignette centre Y Offset.
  94513. */
  94514. /**
  94515. * Sets Vignette centre Y Offset.
  94516. */
  94517. vignetteCentreY: number;
  94518. /**
  94519. * Gets Vignette weight or intensity of the vignette effect.
  94520. */
  94521. /**
  94522. * Sets Vignette weight or intensity of the vignette effect.
  94523. */
  94524. vignetteWeight: number;
  94525. /**
  94526. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94527. * if vignetteEnabled is set to true.
  94528. */
  94529. /**
  94530. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94531. * if vignetteEnabled is set to true.
  94532. */
  94533. vignetteColor: Color4;
  94534. /**
  94535. * Gets Camera field of view used by the Vignette effect.
  94536. */
  94537. /**
  94538. * Sets Camera field of view used by the Vignette effect.
  94539. */
  94540. vignetteCameraFov: number;
  94541. /**
  94542. * Gets the vignette blend mode allowing different kind of effect.
  94543. */
  94544. /**
  94545. * Sets the vignette blend mode allowing different kind of effect.
  94546. */
  94547. vignetteBlendMode: number;
  94548. /**
  94549. * Gets wether the vignette effect is enabled.
  94550. */
  94551. /**
  94552. * Sets wether the vignette effect is enabled.
  94553. */
  94554. vignetteEnabled: boolean;
  94555. private _fromLinearSpace;
  94556. /**
  94557. * Gets wether the input of the processing is in Gamma or Linear Space.
  94558. */
  94559. /**
  94560. * Sets wether the input of the processing is in Gamma or Linear Space.
  94561. */
  94562. fromLinearSpace: boolean;
  94563. /**
  94564. * Defines cache preventing GC.
  94565. */
  94566. private _defines;
  94567. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94568. /**
  94569. * "ImageProcessingPostProcess"
  94570. * @returns "ImageProcessingPostProcess"
  94571. */
  94572. getClassName(): string;
  94573. protected _updateParameters(): void;
  94574. dispose(camera?: Camera): void;
  94575. }
  94576. }
  94577. declare module BABYLON {
  94578. /**
  94579. * Class containing static functions to help procedurally build meshes
  94580. */
  94581. export class GroundBuilder {
  94582. /**
  94583. * Creates a ground mesh
  94584. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94585. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94587. * @param name defines the name of the mesh
  94588. * @param options defines the options used to create the mesh
  94589. * @param scene defines the hosting scene
  94590. * @returns the ground mesh
  94591. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94592. */
  94593. static CreateGround(name: string, options: {
  94594. width?: number;
  94595. height?: number;
  94596. subdivisions?: number;
  94597. subdivisionsX?: number;
  94598. subdivisionsY?: number;
  94599. updatable?: boolean;
  94600. }, scene: any): Mesh;
  94601. /**
  94602. * Creates a tiled ground mesh
  94603. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94604. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94605. * * 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
  94606. * * 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
  94607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94608. * @param name defines the name of the mesh
  94609. * @param options defines the options used to create the mesh
  94610. * @param scene defines the hosting scene
  94611. * @returns the tiled ground mesh
  94612. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94613. */
  94614. static CreateTiledGround(name: string, options: {
  94615. xmin: number;
  94616. zmin: number;
  94617. xmax: number;
  94618. zmax: number;
  94619. subdivisions?: {
  94620. w: number;
  94621. h: number;
  94622. };
  94623. precision?: {
  94624. w: number;
  94625. h: number;
  94626. };
  94627. updatable?: boolean;
  94628. }, scene: Scene): Mesh;
  94629. /**
  94630. * Creates a ground mesh from a height map
  94631. * * The parameter `url` sets the URL of the height map image resource.
  94632. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94633. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94634. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94635. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94636. * * 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.
  94637. * * 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).
  94638. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94640. * @param name defines the name of the mesh
  94641. * @param url defines the url to the height map
  94642. * @param options defines the options used to create the mesh
  94643. * @param scene defines the hosting scene
  94644. * @returns the ground mesh
  94645. * @see https://doc.babylonjs.com/babylon101/height_map
  94646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94647. */
  94648. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94649. width?: number;
  94650. height?: number;
  94651. subdivisions?: number;
  94652. minHeight?: number;
  94653. maxHeight?: number;
  94654. colorFilter?: Color3;
  94655. alphaFilter?: number;
  94656. updatable?: boolean;
  94657. onReady?: (mesh: GroundMesh) => void;
  94658. }, scene: Scene): GroundMesh;
  94659. }
  94660. }
  94661. declare module BABYLON {
  94662. /**
  94663. * Class containing static functions to help procedurally build meshes
  94664. */
  94665. export class TorusBuilder {
  94666. /**
  94667. * Creates a torus mesh
  94668. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94669. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94670. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94674. * @param name defines the name of the mesh
  94675. * @param options defines the options used to create the mesh
  94676. * @param scene defines the hosting scene
  94677. * @returns the torus mesh
  94678. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94679. */
  94680. static CreateTorus(name: string, options: {
  94681. diameter?: number;
  94682. thickness?: number;
  94683. tessellation?: number;
  94684. updatable?: boolean;
  94685. sideOrientation?: number;
  94686. frontUVs?: Vector4;
  94687. backUVs?: Vector4;
  94688. }, scene: any): Mesh;
  94689. }
  94690. }
  94691. declare module BABYLON {
  94692. /**
  94693. * Class containing static functions to help procedurally build meshes
  94694. */
  94695. export class CylinderBuilder {
  94696. /**
  94697. * Creates a cylinder or a cone mesh
  94698. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94699. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94700. * * 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.
  94701. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94702. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94703. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94704. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94705. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94706. * * 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).
  94707. * * 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
  94708. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94709. * * 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
  94710. * * 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.
  94711. * * If `enclose` is false, a ring surface is one element.
  94712. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94713. * * 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
  94714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94717. * @param name defines the name of the mesh
  94718. * @param options defines the options used to create the mesh
  94719. * @param scene defines the hosting scene
  94720. * @returns the cylinder mesh
  94721. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94722. */
  94723. static CreateCylinder(name: string, options: {
  94724. height?: number;
  94725. diameterTop?: number;
  94726. diameterBottom?: number;
  94727. diameter?: number;
  94728. tessellation?: number;
  94729. subdivisions?: number;
  94730. arc?: number;
  94731. faceColors?: Color4[];
  94732. faceUV?: Vector4[];
  94733. updatable?: boolean;
  94734. hasRings?: boolean;
  94735. enclose?: boolean;
  94736. sideOrientation?: number;
  94737. frontUVs?: Vector4;
  94738. backUVs?: Vector4;
  94739. }, scene: any): Mesh;
  94740. }
  94741. }
  94742. declare module BABYLON {
  94743. /**
  94744. * Manager for handling gamepads
  94745. */
  94746. export class GamepadManager {
  94747. private _scene?;
  94748. private _babylonGamepads;
  94749. private _oneGamepadConnected;
  94750. /** @hidden */
  94751. _isMonitoring: boolean;
  94752. private _gamepadEventSupported;
  94753. private _gamepadSupport;
  94754. /**
  94755. * observable to be triggered when the gamepad controller has been connected
  94756. */
  94757. onGamepadConnectedObservable: Observable<Gamepad>;
  94758. /**
  94759. * observable to be triggered when the gamepad controller has been disconnected
  94760. */
  94761. onGamepadDisconnectedObservable: Observable<Gamepad>;
  94762. private _onGamepadConnectedEvent;
  94763. private _onGamepadDisconnectedEvent;
  94764. /**
  94765. * Initializes the gamepad manager
  94766. * @param _scene BabylonJS scene
  94767. */
  94768. constructor(_scene?: Scene | undefined);
  94769. /**
  94770. * The gamepads in the game pad manager
  94771. */
  94772. readonly gamepads: Gamepad[];
  94773. /**
  94774. * Get the gamepad controllers based on type
  94775. * @param type The type of gamepad controller
  94776. * @returns Nullable gamepad
  94777. */
  94778. getGamepadByType(type?: number): Nullable<Gamepad>;
  94779. /**
  94780. * Disposes the gamepad manager
  94781. */
  94782. dispose(): void;
  94783. private _addNewGamepad;
  94784. private _startMonitoringGamepads;
  94785. private _stopMonitoringGamepads;
  94786. /** @hidden */
  94787. _checkGamepadsStatus(): void;
  94788. private _updateGamepadObjects;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. interface Scene {
  94793. /** @hidden */
  94794. _gamepadManager: Nullable<GamepadManager>;
  94795. /**
  94796. * Gets the gamepad manager associated with the scene
  94797. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  94798. */
  94799. gamepadManager: GamepadManager;
  94800. }
  94801. /**
  94802. * Interface representing a free camera inputs manager
  94803. */
  94804. interface FreeCameraInputsManager {
  94805. /**
  94806. * Adds gamepad input support to the FreeCameraInputsManager.
  94807. * @returns the FreeCameraInputsManager
  94808. */
  94809. addGamepad(): FreeCameraInputsManager;
  94810. }
  94811. /**
  94812. * Interface representing an arc rotate camera inputs manager
  94813. */
  94814. interface ArcRotateCameraInputsManager {
  94815. /**
  94816. * Adds gamepad input support to the ArcRotateCamera InputManager.
  94817. * @returns the camera inputs manager
  94818. */
  94819. addGamepad(): ArcRotateCameraInputsManager;
  94820. }
  94821. /**
  94822. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  94823. */
  94824. export class GamepadSystemSceneComponent implements ISceneComponent {
  94825. /**
  94826. * The component name helpfull to identify the component in the list of scene components.
  94827. */
  94828. readonly name: string;
  94829. /**
  94830. * The scene the component belongs to.
  94831. */
  94832. scene: Scene;
  94833. /**
  94834. * Creates a new instance of the component for the given scene
  94835. * @param scene Defines the scene to register the component in
  94836. */
  94837. constructor(scene: Scene);
  94838. /**
  94839. * Registers the component in a given scene
  94840. */
  94841. register(): void;
  94842. /**
  94843. * Rebuilds the elements related to this component in case of
  94844. * context lost for instance.
  94845. */
  94846. rebuild(): void;
  94847. /**
  94848. * Disposes the component and the associated ressources
  94849. */
  94850. dispose(): void;
  94851. private _beforeCameraUpdate;
  94852. }
  94853. }
  94854. declare module BABYLON {
  94855. /**
  94856. * Options to modify the vr teleportation behavior.
  94857. */
  94858. export interface VRTeleportationOptions {
  94859. /**
  94860. * The name of the mesh which should be used as the teleportation floor. (default: null)
  94861. */
  94862. floorMeshName?: string;
  94863. /**
  94864. * A list of meshes to be used as the teleportation floor. (default: empty)
  94865. */
  94866. floorMeshes?: Mesh[];
  94867. }
  94868. /**
  94869. * Options to modify the vr experience helper's behavior.
  94870. */
  94871. export interface VRExperienceHelperOptions extends WebVROptions {
  94872. /**
  94873. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  94874. */
  94875. createDeviceOrientationCamera?: boolean;
  94876. /**
  94877. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  94878. */
  94879. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  94880. /**
  94881. * Uses the main button on the controller to toggle the laser casted. (default: true)
  94882. */
  94883. laserToggle?: boolean;
  94884. /**
  94885. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  94886. */
  94887. floorMeshes?: Mesh[];
  94888. /**
  94889. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  94890. */
  94891. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  94892. }
  94893. /**
  94894. * Helps to quickly add VR support to an existing scene.
  94895. * See http://doc.babylonjs.com/how_to/webvr_helper
  94896. */
  94897. export class VRExperienceHelper {
  94898. /** Options to modify the vr experience helper's behavior. */
  94899. webVROptions: VRExperienceHelperOptions;
  94900. private _scene;
  94901. private _position;
  94902. private _btnVR;
  94903. private _btnVRDisplayed;
  94904. private _webVRsupported;
  94905. private _webVRready;
  94906. private _webVRrequesting;
  94907. private _webVRpresenting;
  94908. private _hasEnteredVR;
  94909. private _fullscreenVRpresenting;
  94910. private _canvas;
  94911. private _webVRCamera;
  94912. private _vrDeviceOrientationCamera;
  94913. private _deviceOrientationCamera;
  94914. private _existingCamera;
  94915. private _onKeyDown;
  94916. private _onVrDisplayPresentChange;
  94917. private _onVRDisplayChanged;
  94918. private _onVRRequestPresentStart;
  94919. private _onVRRequestPresentComplete;
  94920. /**
  94921. * Observable raised when entering VR.
  94922. */
  94923. onEnteringVRObservable: Observable<VRExperienceHelper>;
  94924. /**
  94925. * Observable raised when exiting VR.
  94926. */
  94927. onExitingVRObservable: Observable<VRExperienceHelper>;
  94928. /**
  94929. * Observable raised when controller mesh is loaded.
  94930. */
  94931. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94932. /** Return this.onEnteringVRObservable
  94933. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  94934. */
  94935. readonly onEnteringVR: Observable<VRExperienceHelper>;
  94936. /** Return this.onExitingVRObservable
  94937. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  94938. */
  94939. readonly onExitingVR: Observable<VRExperienceHelper>;
  94940. /** Return this.onControllerMeshLoadedObservable
  94941. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  94942. */
  94943. readonly onControllerMeshLoaded: Observable<WebVRController>;
  94944. private _rayLength;
  94945. private _useCustomVRButton;
  94946. private _teleportationRequested;
  94947. private _teleportActive;
  94948. private _floorMeshName;
  94949. private _floorMeshesCollection;
  94950. private _rotationAllowed;
  94951. private _teleportBackwardsVector;
  94952. private _teleportationTarget;
  94953. private _isDefaultTeleportationTarget;
  94954. private _postProcessMove;
  94955. private _teleportationFillColor;
  94956. private _teleportationBorderColor;
  94957. private _rotationAngle;
  94958. private _haloCenter;
  94959. private _cameraGazer;
  94960. private _padSensibilityUp;
  94961. private _padSensibilityDown;
  94962. private _leftController;
  94963. private _rightController;
  94964. /**
  94965. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  94966. */
  94967. onNewMeshSelected: Observable<AbstractMesh>;
  94968. /**
  94969. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  94970. */
  94971. onNewMeshPicked: Observable<PickingInfo>;
  94972. private _circleEase;
  94973. /**
  94974. * Observable raised before camera teleportation
  94975. */
  94976. onBeforeCameraTeleport: Observable<Vector3>;
  94977. /**
  94978. * Observable raised after camera teleportation
  94979. */
  94980. onAfterCameraTeleport: Observable<Vector3>;
  94981. /**
  94982. * Observable raised when current selected mesh gets unselected
  94983. */
  94984. onSelectedMeshUnselected: Observable<AbstractMesh>;
  94985. private _raySelectionPredicate;
  94986. /**
  94987. * To be optionaly changed by user to define custom ray selection
  94988. */
  94989. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  94990. /**
  94991. * To be optionaly changed by user to define custom selection logic (after ray selection)
  94992. */
  94993. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  94994. /**
  94995. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  94996. */
  94997. teleportationEnabled: boolean;
  94998. private _defaultHeight;
  94999. private _teleportationInitialized;
  95000. private _interactionsEnabled;
  95001. private _interactionsRequested;
  95002. private _displayGaze;
  95003. private _displayLaserPointer;
  95004. /**
  95005. * The mesh used to display where the user is going to teleport.
  95006. */
  95007. /**
  95008. * Sets the mesh to be used to display where the user is going to teleport.
  95009. */
  95010. teleportationTarget: Mesh;
  95011. /**
  95012. * 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
  95013. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  95014. * See http://doc.babylonjs.com/resources/baking_transformations
  95015. */
  95016. gazeTrackerMesh: Mesh;
  95017. /**
  95018. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  95019. */
  95020. updateGazeTrackerScale: boolean;
  95021. /**
  95022. * If the gaze trackers color should be updated when selecting meshes
  95023. */
  95024. updateGazeTrackerColor: boolean;
  95025. /**
  95026. * The gaze tracking mesh corresponding to the left controller
  95027. */
  95028. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  95029. /**
  95030. * The gaze tracking mesh corresponding to the right controller
  95031. */
  95032. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  95033. /**
  95034. * If the ray of the gaze should be displayed.
  95035. */
  95036. /**
  95037. * Sets if the ray of the gaze should be displayed.
  95038. */
  95039. displayGaze: boolean;
  95040. /**
  95041. * If the ray of the LaserPointer should be displayed.
  95042. */
  95043. /**
  95044. * Sets if the ray of the LaserPointer should be displayed.
  95045. */
  95046. displayLaserPointer: boolean;
  95047. /**
  95048. * The deviceOrientationCamera used as the camera when not in VR.
  95049. */
  95050. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  95051. /**
  95052. * Based on the current WebVR support, returns the current VR camera used.
  95053. */
  95054. readonly currentVRCamera: Nullable<Camera>;
  95055. /**
  95056. * The webVRCamera which is used when in VR.
  95057. */
  95058. readonly webVRCamera: WebVRFreeCamera;
  95059. /**
  95060. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  95061. */
  95062. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  95063. private readonly _teleportationRequestInitiated;
  95064. /**
  95065. * Defines wether or not Pointer lock should be requested when switching to
  95066. * full screen.
  95067. */
  95068. requestPointerLockOnFullScreen: boolean;
  95069. /**
  95070. * Instantiates a VRExperienceHelper.
  95071. * Helps to quickly add VR support to an existing scene.
  95072. * @param scene The scene the VRExperienceHelper belongs to.
  95073. * @param webVROptions Options to modify the vr experience helper's behavior.
  95074. */
  95075. constructor(scene: Scene,
  95076. /** Options to modify the vr experience helper's behavior. */
  95077. webVROptions?: VRExperienceHelperOptions);
  95078. private _onDefaultMeshLoaded;
  95079. private _onResize;
  95080. private _onFullscreenChange;
  95081. /**
  95082. * Gets a value indicating if we are currently in VR mode.
  95083. */
  95084. readonly isInVRMode: boolean;
  95085. private onVrDisplayPresentChange;
  95086. private onVRDisplayChanged;
  95087. private moveButtonToBottomRight;
  95088. private displayVRButton;
  95089. private updateButtonVisibility;
  95090. private _cachedAngularSensibility;
  95091. /**
  95092. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95093. * Otherwise, will use the fullscreen API.
  95094. */
  95095. enterVR(): void;
  95096. /**
  95097. * Attempt to exit VR, or fullscreen.
  95098. */
  95099. exitVR(): void;
  95100. /**
  95101. * The position of the vr experience helper.
  95102. */
  95103. /**
  95104. * Sets the position of the vr experience helper.
  95105. */
  95106. position: Vector3;
  95107. /**
  95108. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95109. */
  95110. enableInteractions(): void;
  95111. private readonly _noControllerIsActive;
  95112. private beforeRender;
  95113. private _isTeleportationFloor;
  95114. /**
  95115. * Adds a floor mesh to be used for teleportation.
  95116. * @param floorMesh the mesh to be used for teleportation.
  95117. */
  95118. addFloorMesh(floorMesh: Mesh): void;
  95119. /**
  95120. * Removes a floor mesh from being used for teleportation.
  95121. * @param floorMesh the mesh to be removed.
  95122. */
  95123. removeFloorMesh(floorMesh: Mesh): void;
  95124. /**
  95125. * Enables interactions and teleportation using the VR controllers and gaze.
  95126. * @param vrTeleportationOptions options to modify teleportation behavior.
  95127. */
  95128. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95129. private _onNewGamepadConnected;
  95130. private _tryEnableInteractionOnController;
  95131. private _onNewGamepadDisconnected;
  95132. private _enableInteractionOnController;
  95133. private _checkTeleportWithRay;
  95134. private _checkRotate;
  95135. private _checkTeleportBackwards;
  95136. private _enableTeleportationOnController;
  95137. private _createTeleportationCircles;
  95138. private _displayTeleportationTarget;
  95139. private _hideTeleportationTarget;
  95140. private _rotateCamera;
  95141. private _moveTeleportationSelectorTo;
  95142. private _workingVector;
  95143. private _workingQuaternion;
  95144. private _workingMatrix;
  95145. /**
  95146. * Teleports the users feet to the desired location
  95147. * @param location The location where the user's feet should be placed
  95148. */
  95149. teleportCamera(location: Vector3): void;
  95150. private _convertNormalToDirectionOfRay;
  95151. private _castRayAndSelectObject;
  95152. private _notifySelectedMeshUnselected;
  95153. /**
  95154. * Sets the color of the laser ray from the vr controllers.
  95155. * @param color new color for the ray.
  95156. */
  95157. changeLaserColor(color: Color3): void;
  95158. /**
  95159. * Sets the color of the ray from the vr headsets gaze.
  95160. * @param color new color for the ray.
  95161. */
  95162. changeGazeColor(color: Color3): void;
  95163. /**
  95164. * Exits VR and disposes of the vr experience helper
  95165. */
  95166. dispose(): void;
  95167. /**
  95168. * Gets the name of the VRExperienceHelper class
  95169. * @returns "VRExperienceHelper"
  95170. */
  95171. getClassName(): string;
  95172. }
  95173. }
  95174. declare module BABYLON {
  95175. /**
  95176. * Manages an XRSession
  95177. * @see https://doc.babylonjs.com/how_to/webxr
  95178. */
  95179. export class WebXRSessionManager implements IDisposable {
  95180. private scene;
  95181. /**
  95182. * Fires every time a new xrFrame arrives which can be used to update the camera
  95183. */
  95184. onXRFrameObservable: Observable<any>;
  95185. /**
  95186. * Fires when the xr session is ended either by the device or manually done
  95187. */
  95188. onXRSessionEnded: Observable<any>;
  95189. /** @hidden */
  95190. _xrSession: XRSession;
  95191. /** @hidden */
  95192. _frameOfReference: XRFrameOfReference;
  95193. /** @hidden */
  95194. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95195. /** @hidden */
  95196. _currentXRFrame: Nullable<XRFrame>;
  95197. private _xrNavigator;
  95198. private _xrDevice;
  95199. private _tmpMatrix;
  95200. /**
  95201. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95202. * @param scene The scene which the session should be created for
  95203. */
  95204. constructor(scene: Scene);
  95205. /**
  95206. * Initializes the manager
  95207. * After initialization enterXR can be called to start an XR session
  95208. * @returns Promise which resolves after it is initialized
  95209. */
  95210. initializeAsync(): Promise<void>;
  95211. /**
  95212. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95213. * @param sessionCreationOptions xr options to create the session with
  95214. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95215. * @returns Promise which resolves after it enters XR
  95216. */
  95217. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95218. /**
  95219. * Stops the xrSession and restores the renderloop
  95220. * @returns Promise which resolves after it exits XR
  95221. */
  95222. exitXRAsync(): Promise<void>;
  95223. /**
  95224. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95225. * @param ray ray to cast into the environment
  95226. * @returns Promise which resolves with a collision point in the environment if it exists
  95227. */
  95228. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95229. /**
  95230. * Checks if a session would be supported for the creation options specified
  95231. * @param options creation options to check if they are supported
  95232. * @returns true if supported
  95233. */
  95234. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95235. /**
  95236. * @hidden
  95237. * Converts the render layer of xrSession to a render target
  95238. * @param session session to create render target for
  95239. * @param scene scene the new render target should be created for
  95240. */
  95241. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95242. /**
  95243. * Disposes of the session manager
  95244. */
  95245. dispose(): void;
  95246. }
  95247. }
  95248. declare module BABYLON {
  95249. /**
  95250. * WebXR Camera which holds the views for the xrSession
  95251. * @see https://doc.babylonjs.com/how_to/webxr
  95252. */
  95253. export class WebXRCamera extends FreeCamera {
  95254. private static _TmpMatrix;
  95255. /**
  95256. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95257. * @param name the name of the camera
  95258. * @param scene the scene to add the camera to
  95259. */
  95260. constructor(name: string, scene: Scene);
  95261. private _updateNumberOfRigCameras;
  95262. /** @hidden */
  95263. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95264. /**
  95265. * Updates the cameras position from the current pose information of the XR session
  95266. * @param xrSessionManager the session containing pose information
  95267. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95268. */
  95269. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95270. }
  95271. }
  95272. declare module BABYLON {
  95273. /**
  95274. * States of the webXR experience
  95275. */
  95276. export enum WebXRState {
  95277. /**
  95278. * Transitioning to being in XR mode
  95279. */
  95280. ENTERING_XR = 0,
  95281. /**
  95282. * Transitioning to non XR mode
  95283. */
  95284. EXITING_XR = 1,
  95285. /**
  95286. * In XR mode and presenting
  95287. */
  95288. IN_XR = 2,
  95289. /**
  95290. * Not entered XR mode
  95291. */
  95292. NOT_IN_XR = 3
  95293. }
  95294. /**
  95295. * Helper class used to enable XR
  95296. * @see https://doc.babylonjs.com/how_to/webxr
  95297. */
  95298. export class WebXRExperienceHelper implements IDisposable {
  95299. private scene;
  95300. /**
  95301. * 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
  95302. */
  95303. container: AbstractMesh;
  95304. /**
  95305. * Camera used to render xr content
  95306. */
  95307. camera: WebXRCamera;
  95308. /**
  95309. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95310. */
  95311. state: WebXRState;
  95312. private _setState;
  95313. private static _TmpVector;
  95314. /**
  95315. * Fires when the state of the experience helper has changed
  95316. */
  95317. onStateChangedObservable: Observable<WebXRState>;
  95318. /** @hidden */
  95319. _sessionManager: WebXRSessionManager;
  95320. private _nonVRCamera;
  95321. private _originalSceneAutoClear;
  95322. private _supported;
  95323. /**
  95324. * Creates the experience helper
  95325. * @param scene the scene to attach the experience helper to
  95326. * @returns a promise for the experience helper
  95327. */
  95328. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95329. /**
  95330. * Creates a WebXRExperienceHelper
  95331. * @param scene The scene the helper should be created in
  95332. */
  95333. private constructor();
  95334. /**
  95335. * Exits XR mode and returns the scene to its original state
  95336. * @returns promise that resolves after xr mode has exited
  95337. */
  95338. exitXRAsync(): Promise<void>;
  95339. /**
  95340. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95341. * @param sessionCreationOptions options for the XR session
  95342. * @param frameOfReference frame of reference of the XR session
  95343. * @returns promise that resolves after xr mode has entered
  95344. */
  95345. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95346. /**
  95347. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95348. * @param ray ray to cast into the environment
  95349. * @returns Promise which resolves with a collision point in the environment if it exists
  95350. */
  95351. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95352. /**
  95353. * Updates the global position of the camera by moving the camera's container
  95354. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95355. * @param position The desired global position of the camera
  95356. */
  95357. setPositionOfCameraUsingContainer(position: Vector3): void;
  95358. /**
  95359. * Rotates the xr camera by rotating the camera's container around the camera's position
  95360. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95361. * @param rotation the desired quaternion rotation to apply to the camera
  95362. */
  95363. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95364. /**
  95365. * Checks if the creation options are supported by the xr session
  95366. * @param options creation options
  95367. * @returns true if supported
  95368. */
  95369. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95370. /**
  95371. * Disposes of the experience helper
  95372. */
  95373. dispose(): void;
  95374. }
  95375. }
  95376. declare module BABYLON {
  95377. /**
  95378. * Button which can be used to enter a different mode of XR
  95379. */
  95380. export class WebXREnterExitUIButton {
  95381. /** button element */
  95382. element: HTMLElement;
  95383. /** XR initialization options for the button */
  95384. initializationOptions: XRSessionCreationOptions;
  95385. /**
  95386. * Creates a WebXREnterExitUIButton
  95387. * @param element button element
  95388. * @param initializationOptions XR initialization options for the button
  95389. */
  95390. constructor(
  95391. /** button element */
  95392. element: HTMLElement,
  95393. /** XR initialization options for the button */
  95394. initializationOptions: XRSessionCreationOptions);
  95395. /**
  95396. * Overwritable function which can be used to update the button's visuals when the state changes
  95397. * @param activeButton the current active button in the UI
  95398. */
  95399. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95400. }
  95401. /**
  95402. * Options to create the webXR UI
  95403. */
  95404. export class WebXREnterExitUIOptions {
  95405. /**
  95406. * Context to enter xr with
  95407. */
  95408. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95409. /**
  95410. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95411. */
  95412. customButtons?: Array<WebXREnterExitUIButton>;
  95413. }
  95414. /**
  95415. * UI to allow the user to enter/exit XR mode
  95416. */
  95417. export class WebXREnterExitUI implements IDisposable {
  95418. private scene;
  95419. private _overlay;
  95420. private _buttons;
  95421. private _activeButton;
  95422. /**
  95423. * Fired every time the active button is changed.
  95424. *
  95425. * When xr is entered via a button that launches xr that button will be the callback parameter
  95426. *
  95427. * When exiting xr the callback parameter will be null)
  95428. */
  95429. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95430. /**
  95431. * Creates UI to allow the user to enter/exit XR mode
  95432. * @param scene the scene to add the ui to
  95433. * @param helper the xr experience helper to enter/exit xr with
  95434. * @param options options to configure the UI
  95435. * @returns the created ui
  95436. */
  95437. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95438. private constructor();
  95439. private _updateButtons;
  95440. /**
  95441. * Disposes of the object
  95442. */
  95443. dispose(): void;
  95444. }
  95445. }
  95446. declare module BABYLON {
  95447. /**
  95448. * Represents an XR input
  95449. */
  95450. export class WebXRController {
  95451. /**
  95452. * 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
  95453. */
  95454. grip?: AbstractMesh;
  95455. /**
  95456. * Pointer which can be used to select objects or attach a visible laser to
  95457. */
  95458. pointer: AbstractMesh;
  95459. /**
  95460. * Creates the controller
  95461. * @see https://doc.babylonjs.com/how_to/webxr
  95462. * @param scene the scene which the controller should be associated to
  95463. */
  95464. constructor(scene: Scene);
  95465. /**
  95466. * Disposes of the object
  95467. */
  95468. dispose(): void;
  95469. }
  95470. /**
  95471. * XR input used to track XR inputs such as controllers/rays
  95472. */
  95473. export class WebXRInput implements IDisposable {
  95474. private helper;
  95475. /**
  95476. * XR controllers being tracked
  95477. */
  95478. controllers: Array<WebXRController>;
  95479. private _tmpMatrix;
  95480. private _frameObserver;
  95481. /**
  95482. * Initializes the WebXRInput
  95483. * @param helper experience helper which the input should be created for
  95484. */
  95485. constructor(helper: WebXRExperienceHelper);
  95486. /**
  95487. * Disposes of the object
  95488. */
  95489. dispose(): void;
  95490. }
  95491. }
  95492. declare module BABYLON {
  95493. /**
  95494. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95495. */
  95496. export class WebXRManagedOutputCanvas implements IDisposable {
  95497. private _canvas;
  95498. /**
  95499. * xrpresent context of the canvas which can be used to display/mirror xr content
  95500. */
  95501. canvasContext: Nullable<WebGLRenderingContext>;
  95502. /**
  95503. * Initializes the canvas to be added/removed upon entering/exiting xr
  95504. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95505. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95506. */
  95507. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95508. /**
  95509. * Disposes of the object
  95510. */
  95511. dispose(): void;
  95512. private _setManagedOutputCanvas;
  95513. private _addCanvas;
  95514. private _removeCanvas;
  95515. }
  95516. }
  95517. declare module BABYLON {
  95518. /**
  95519. * Contains an array of blocks representing the octree
  95520. */
  95521. export interface IOctreeContainer<T> {
  95522. /**
  95523. * Blocks within the octree
  95524. */
  95525. blocks: Array<OctreeBlock<T>>;
  95526. }
  95527. /**
  95528. * Class used to store a cell in an octree
  95529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95530. */
  95531. export class OctreeBlock<T> {
  95532. /**
  95533. * Gets the content of the current block
  95534. */
  95535. entries: T[];
  95536. /**
  95537. * Gets the list of block children
  95538. */
  95539. blocks: Array<OctreeBlock<T>>;
  95540. private _depth;
  95541. private _maxDepth;
  95542. private _capacity;
  95543. private _minPoint;
  95544. private _maxPoint;
  95545. private _boundingVectors;
  95546. private _creationFunc;
  95547. /**
  95548. * Creates a new block
  95549. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95550. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95551. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95552. * @param depth defines the current depth of this block in the octree
  95553. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95554. * @param creationFunc defines a callback to call when an element is added to the block
  95555. */
  95556. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95557. /**
  95558. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95559. */
  95560. readonly capacity: number;
  95561. /**
  95562. * Gets the minimum vector (in world space) of the block's bounding box
  95563. */
  95564. readonly minPoint: Vector3;
  95565. /**
  95566. * Gets the maximum vector (in world space) of the block's bounding box
  95567. */
  95568. readonly maxPoint: Vector3;
  95569. /**
  95570. * Add a new element to this block
  95571. * @param entry defines the element to add
  95572. */
  95573. addEntry(entry: T): void;
  95574. /**
  95575. * Remove an element from this block
  95576. * @param entry defines the element to remove
  95577. */
  95578. removeEntry(entry: T): void;
  95579. /**
  95580. * Add an array of elements to this block
  95581. * @param entries defines the array of elements to add
  95582. */
  95583. addEntries(entries: T[]): void;
  95584. /**
  95585. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95586. * @param frustumPlanes defines the frustum planes to test
  95587. * @param selection defines the array to store current content if selection is positive
  95588. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95589. */
  95590. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95591. /**
  95592. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95593. * @param sphereCenter defines the bounding sphere center
  95594. * @param sphereRadius defines the bounding sphere radius
  95595. * @param selection defines the array to store current content if selection is positive
  95596. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95597. */
  95598. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95599. /**
  95600. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95601. * @param ray defines the ray to test with
  95602. * @param selection defines the array to store current content if selection is positive
  95603. */
  95604. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95605. /**
  95606. * Subdivide the content into child blocks (this block will then be empty)
  95607. */
  95608. createInnerBlocks(): void;
  95609. /**
  95610. * @hidden
  95611. */
  95612. 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;
  95613. }
  95614. }
  95615. declare module BABYLON {
  95616. /**
  95617. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95618. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95619. */
  95620. export class Octree<T> {
  95621. /** 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.) */
  95622. maxDepth: number;
  95623. /**
  95624. * Blocks within the octree containing objects
  95625. */
  95626. blocks: Array<OctreeBlock<T>>;
  95627. /**
  95628. * Content stored in the octree
  95629. */
  95630. dynamicContent: T[];
  95631. private _maxBlockCapacity;
  95632. private _selectionContent;
  95633. private _creationFunc;
  95634. /**
  95635. * Creates a octree
  95636. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95637. * @param creationFunc function to be used to instatiate the octree
  95638. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95639. * @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.)
  95640. */
  95641. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95642. /** 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.) */
  95643. maxDepth?: number);
  95644. /**
  95645. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95646. * @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);
  95647. * @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);
  95648. * @param entries meshes to be added to the octree blocks
  95649. */
  95650. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95651. /**
  95652. * Adds a mesh to the octree
  95653. * @param entry Mesh to add to the octree
  95654. */
  95655. addMesh(entry: T): void;
  95656. /**
  95657. * Remove an element from the octree
  95658. * @param entry defines the element to remove
  95659. */
  95660. removeMesh(entry: T): void;
  95661. /**
  95662. * Selects an array of meshes within the frustum
  95663. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95664. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95665. * @returns array of meshes within the frustum
  95666. */
  95667. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95668. /**
  95669. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95670. * @param sphereCenter defines the bounding sphere center
  95671. * @param sphereRadius defines the bounding sphere radius
  95672. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95673. * @returns an array of objects that intersect the sphere
  95674. */
  95675. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95676. /**
  95677. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95678. * @param ray defines the ray to test with
  95679. * @returns array of intersected objects
  95680. */
  95681. intersectsRay(ray: Ray): SmartArray<T>;
  95682. /**
  95683. * Adds a mesh into the octree block if it intersects the block
  95684. */
  95685. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95686. /**
  95687. * Adds a submesh into the octree block if it intersects the block
  95688. */
  95689. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95690. }
  95691. }
  95692. declare module BABYLON {
  95693. interface Scene {
  95694. /**
  95695. * @hidden
  95696. * Backing Filed
  95697. */
  95698. _selectionOctree: Octree<AbstractMesh>;
  95699. /**
  95700. * Gets the octree used to boost mesh selection (picking)
  95701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95702. */
  95703. selectionOctree: Octree<AbstractMesh>;
  95704. /**
  95705. * Creates or updates the octree used to boost selection (picking)
  95706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95707. * @param maxCapacity defines the maximum capacity per leaf
  95708. * @param maxDepth defines the maximum depth of the octree
  95709. * @returns an octree of AbstractMesh
  95710. */
  95711. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95712. }
  95713. interface AbstractMesh {
  95714. /**
  95715. * @hidden
  95716. * Backing Field
  95717. */
  95718. _submeshesOctree: Octree<SubMesh>;
  95719. /**
  95720. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95721. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95722. * @param maxCapacity defines the maximum size of each block (64 by default)
  95723. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95724. * @returns the new octree
  95725. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95727. */
  95728. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95729. }
  95730. /**
  95731. * Defines the octree scene component responsible to manage any octrees
  95732. * in a given scene.
  95733. */
  95734. export class OctreeSceneComponent {
  95735. /**
  95736. * The component name helpfull to identify the component in the list of scene components.
  95737. */
  95738. readonly name: string;
  95739. /**
  95740. * The scene the component belongs to.
  95741. */
  95742. scene: Scene;
  95743. /**
  95744. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95745. */
  95746. readonly checksIsEnabled: boolean;
  95747. /**
  95748. * Creates a new instance of the component for the given scene
  95749. * @param scene Defines the scene to register the component in
  95750. */
  95751. constructor(scene: Scene);
  95752. /**
  95753. * Registers the component in a given scene
  95754. */
  95755. register(): void;
  95756. /**
  95757. * Return the list of active meshes
  95758. * @returns the list of active meshes
  95759. */
  95760. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95761. /**
  95762. * Return the list of active sub meshes
  95763. * @param mesh The mesh to get the candidates sub meshes from
  95764. * @returns the list of active sub meshes
  95765. */
  95766. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95767. private _tempRay;
  95768. /**
  95769. * Return the list of sub meshes intersecting with a given local ray
  95770. * @param mesh defines the mesh to find the submesh for
  95771. * @param localRay defines the ray in local space
  95772. * @returns the list of intersecting sub meshes
  95773. */
  95774. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95775. /**
  95776. * Return the list of sub meshes colliding with a collider
  95777. * @param mesh defines the mesh to find the submesh for
  95778. * @param collider defines the collider to evaluate the collision against
  95779. * @returns the list of colliding sub meshes
  95780. */
  95781. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  95782. /**
  95783. * Rebuilds the elements related to this component in case of
  95784. * context lost for instance.
  95785. */
  95786. rebuild(): void;
  95787. /**
  95788. * Disposes the component and the associated ressources.
  95789. */
  95790. dispose(): void;
  95791. }
  95792. }
  95793. declare module BABYLON {
  95794. /**
  95795. * Class containing static functions to help procedurally build meshes
  95796. */
  95797. export class LinesBuilder {
  95798. /**
  95799. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  95800. * * 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
  95801. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  95802. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  95803. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  95804. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  95805. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  95806. * * 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
  95807. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  95808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  95810. * @param name defines the name of the new line system
  95811. * @param options defines the options used to create the line system
  95812. * @param scene defines the hosting scene
  95813. * @returns a new line system mesh
  95814. */
  95815. static CreateLineSystem(name: string, options: {
  95816. lines: Vector3[][];
  95817. updatable?: boolean;
  95818. instance?: Nullable<LinesMesh>;
  95819. colors?: Nullable<Color4[][]>;
  95820. useVertexAlpha?: boolean;
  95821. }, scene: Nullable<Scene>): LinesMesh;
  95822. /**
  95823. * Creates a line mesh
  95824. * 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
  95825. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95826. * * The parameter `points` is an array successive Vector3
  95827. * * 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
  95828. * * The optional parameter `colors` is an array of successive Color4, one per line point
  95829. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  95830. * * When updating an instance, remember that only point positions can change, not the number of points
  95831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  95833. * @param name defines the name of the new line system
  95834. * @param options defines the options used to create the line system
  95835. * @param scene defines the hosting scene
  95836. * @returns a new line mesh
  95837. */
  95838. static CreateLines(name: string, options: {
  95839. points: Vector3[];
  95840. updatable?: boolean;
  95841. instance?: Nullable<LinesMesh>;
  95842. colors?: Color4[];
  95843. useVertexAlpha?: boolean;
  95844. }, scene?: Nullable<Scene>): LinesMesh;
  95845. /**
  95846. * Creates a dashed line mesh
  95847. * * 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
  95848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95849. * * The parameter `points` is an array successive Vector3
  95850. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  95851. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  95852. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95853. * * 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
  95854. * * When updating an instance, remember that only point positions can change, not the number of points
  95855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95856. * @param name defines the name of the mesh
  95857. * @param options defines the options used to create the mesh
  95858. * @param scene defines the hosting scene
  95859. * @returns the dashed line mesh
  95860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  95861. */
  95862. static CreateDashedLines(name: string, options: {
  95863. points: Vector3[];
  95864. dashSize?: number;
  95865. gapSize?: number;
  95866. dashNb?: number;
  95867. updatable?: boolean;
  95868. instance?: LinesMesh;
  95869. }, scene?: Nullable<Scene>): LinesMesh;
  95870. }
  95871. }
  95872. declare module BABYLON {
  95873. /**
  95874. * Renders a layer on top of an existing scene
  95875. */
  95876. export class UtilityLayerRenderer implements IDisposable {
  95877. /** the original scene that will be rendered on top of */
  95878. originalScene: Scene;
  95879. private _pointerCaptures;
  95880. private _lastPointerEvents;
  95881. private static _DefaultUtilityLayer;
  95882. private static _DefaultKeepDepthUtilityLayer;
  95883. /**
  95884. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  95885. */
  95886. pickUtilitySceneFirst: boolean;
  95887. /**
  95888. * 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)
  95889. */
  95890. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  95891. /**
  95892. * 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)
  95893. */
  95894. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  95895. /**
  95896. * The scene that is rendered on top of the original scene
  95897. */
  95898. utilityLayerScene: Scene;
  95899. /**
  95900. * If the utility layer should automatically be rendered on top of existing scene
  95901. */
  95902. shouldRender: boolean;
  95903. /**
  95904. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  95905. */
  95906. onlyCheckPointerDownEvents: boolean;
  95907. /**
  95908. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  95909. */
  95910. processAllEvents: boolean;
  95911. /**
  95912. * Observable raised when the pointer move from the utility layer scene to the main scene
  95913. */
  95914. onPointerOutObservable: Observable<number>;
  95915. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  95916. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  95917. private _afterRenderObserver;
  95918. private _sceneDisposeObserver;
  95919. private _originalPointerObserver;
  95920. /**
  95921. * Instantiates a UtilityLayerRenderer
  95922. * @param originalScene the original scene that will be rendered on top of
  95923. * @param handleEvents boolean indicating if the utility layer should handle events
  95924. */
  95925. constructor(
  95926. /** the original scene that will be rendered on top of */
  95927. originalScene: Scene, handleEvents?: boolean);
  95928. private _notifyObservers;
  95929. /**
  95930. * Renders the utility layers scene on top of the original scene
  95931. */
  95932. render(): void;
  95933. /**
  95934. * Disposes of the renderer
  95935. */
  95936. dispose(): void;
  95937. private _updateCamera;
  95938. }
  95939. }
  95940. declare module BABYLON {
  95941. /**
  95942. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  95943. */
  95944. export class Gizmo implements IDisposable {
  95945. /** The utility layer the gizmo will be added to */
  95946. gizmoLayer: UtilityLayerRenderer;
  95947. /**
  95948. * The root mesh of the gizmo
  95949. */
  95950. _rootMesh: Mesh;
  95951. private _attachedMesh;
  95952. /**
  95953. * Ratio for the scale of the gizmo (Default: 1)
  95954. */
  95955. scaleRatio: number;
  95956. private _tmpMatrix;
  95957. /**
  95958. * If a custom mesh has been set (Default: false)
  95959. */
  95960. protected _customMeshSet: boolean;
  95961. /**
  95962. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  95963. * * When set, interactions will be enabled
  95964. */
  95965. attachedMesh: Nullable<AbstractMesh>;
  95966. /**
  95967. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  95968. * @param mesh The mesh to replace the default mesh of the gizmo
  95969. */
  95970. setCustomMesh(mesh: Mesh): void;
  95971. /**
  95972. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  95973. */
  95974. updateGizmoRotationToMatchAttachedMesh: boolean;
  95975. /**
  95976. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  95977. */
  95978. updateGizmoPositionToMatchAttachedMesh: boolean;
  95979. /**
  95980. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  95981. */
  95982. protected _updateScale: boolean;
  95983. protected _interactionsEnabled: boolean;
  95984. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95985. private _beforeRenderObserver;
  95986. /**
  95987. * Creates a gizmo
  95988. * @param gizmoLayer The utility layer the gizmo will be added to
  95989. */
  95990. constructor(
  95991. /** The utility layer the gizmo will be added to */
  95992. gizmoLayer?: UtilityLayerRenderer);
  95993. private _tempVector;
  95994. /**
  95995. * @hidden
  95996. * Updates the gizmo to match the attached mesh's position/rotation
  95997. */
  95998. protected _update(): void;
  95999. /**
  96000. * Disposes of the gizmo
  96001. */
  96002. dispose(): void;
  96003. }
  96004. }
  96005. declare module BABYLON {
  96006. /**
  96007. * Single axis drag gizmo
  96008. */
  96009. export class AxisDragGizmo extends Gizmo {
  96010. /**
  96011. * Drag behavior responsible for the gizmos dragging interactions
  96012. */
  96013. dragBehavior: PointerDragBehavior;
  96014. private _pointerObserver;
  96015. /**
  96016. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  96017. */
  96018. snapDistance: number;
  96019. /**
  96020. * Event that fires each time the gizmo snaps to a new location.
  96021. * * snapDistance is the the change in distance
  96022. */
  96023. onSnapObservable: Observable<{
  96024. snapDistance: number;
  96025. }>;
  96026. /** @hidden */
  96027. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  96028. /** @hidden */
  96029. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  96030. /**
  96031. * Creates an AxisDragGizmo
  96032. * @param gizmoLayer The utility layer the gizmo will be added to
  96033. * @param dragAxis The axis which the gizmo will be able to drag on
  96034. * @param color The color of the gizmo
  96035. */
  96036. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  96037. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96038. /**
  96039. * Disposes of the gizmo
  96040. */
  96041. dispose(): void;
  96042. }
  96043. }
  96044. declare module BABYLON.Debug {
  96045. /**
  96046. * The Axes viewer will show 3 axes in a specific point in space
  96047. */
  96048. export class AxesViewer {
  96049. private _xAxis;
  96050. private _yAxis;
  96051. private _zAxis;
  96052. private _scaleLinesFactor;
  96053. private _instanced;
  96054. /**
  96055. * Gets the hosting scene
  96056. */
  96057. scene: Scene;
  96058. /**
  96059. * Gets or sets a number used to scale line length
  96060. */
  96061. scaleLines: number;
  96062. /** Gets the node hierarchy used to render x-axis */
  96063. readonly xAxis: TransformNode;
  96064. /** Gets the node hierarchy used to render y-axis */
  96065. readonly yAxis: TransformNode;
  96066. /** Gets the node hierarchy used to render z-axis */
  96067. readonly zAxis: TransformNode;
  96068. /**
  96069. * Creates a new AxesViewer
  96070. * @param scene defines the hosting scene
  96071. * @param scaleLines defines a number used to scale line length (1 by default)
  96072. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  96073. * @param xAxis defines the node hierarchy used to render the x-axis
  96074. * @param yAxis defines the node hierarchy used to render the y-axis
  96075. * @param zAxis defines the node hierarchy used to render the z-axis
  96076. */
  96077. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  96078. /**
  96079. * Force the viewer to update
  96080. * @param position defines the position of the viewer
  96081. * @param xaxis defines the x axis of the viewer
  96082. * @param yaxis defines the y axis of the viewer
  96083. * @param zaxis defines the z axis of the viewer
  96084. */
  96085. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96086. /**
  96087. * Creates an instance of this axes viewer.
  96088. * @returns a new axes viewer with instanced meshes
  96089. */
  96090. createInstance(): AxesViewer;
  96091. /** Releases resources */
  96092. dispose(): void;
  96093. private static _SetRenderingGroupId;
  96094. }
  96095. }
  96096. declare module BABYLON.Debug {
  96097. /**
  96098. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96099. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96100. */
  96101. export class BoneAxesViewer extends AxesViewer {
  96102. /**
  96103. * Gets or sets the target mesh where to display the axes viewer
  96104. */
  96105. mesh: Nullable<Mesh>;
  96106. /**
  96107. * Gets or sets the target bone where to display the axes viewer
  96108. */
  96109. bone: Nullable<Bone>;
  96110. /** Gets current position */
  96111. pos: Vector3;
  96112. /** Gets direction of X axis */
  96113. xaxis: Vector3;
  96114. /** Gets direction of Y axis */
  96115. yaxis: Vector3;
  96116. /** Gets direction of Z axis */
  96117. zaxis: Vector3;
  96118. /**
  96119. * Creates a new BoneAxesViewer
  96120. * @param scene defines the hosting scene
  96121. * @param bone defines the target bone
  96122. * @param mesh defines the target mesh
  96123. * @param scaleLines defines a scaling factor for line length (1 by default)
  96124. */
  96125. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96126. /**
  96127. * Force the viewer to update
  96128. */
  96129. update(): void;
  96130. /** Releases resources */
  96131. dispose(): void;
  96132. }
  96133. }
  96134. declare module BABYLON {
  96135. /**
  96136. * Interface used to define scene explorer extensibility option
  96137. */
  96138. export interface IExplorerExtensibilityOption {
  96139. /**
  96140. * Define the option label
  96141. */
  96142. label: string;
  96143. /**
  96144. * Defines the action to execute on click
  96145. */
  96146. action: (entity: any) => void;
  96147. }
  96148. /**
  96149. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96150. */
  96151. export interface IExplorerExtensibilityGroup {
  96152. /**
  96153. * Defines a predicate to test if a given type mut be extended
  96154. */
  96155. predicate: (entity: any) => boolean;
  96156. /**
  96157. * Gets the list of options added to a type
  96158. */
  96159. entries: IExplorerExtensibilityOption[];
  96160. }
  96161. /**
  96162. * Interface used to define the options to use to create the Inspector
  96163. */
  96164. export interface IInspectorOptions {
  96165. /**
  96166. * Display in overlay mode (default: false)
  96167. */
  96168. overlay?: boolean;
  96169. /**
  96170. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96171. */
  96172. globalRoot?: HTMLElement;
  96173. /**
  96174. * Display the Scene explorer
  96175. */
  96176. showExplorer?: boolean;
  96177. /**
  96178. * Display the property inspector
  96179. */
  96180. showInspector?: boolean;
  96181. /**
  96182. * Display in embed mode (both panes on the right)
  96183. */
  96184. embedMode?: boolean;
  96185. /**
  96186. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96187. */
  96188. handleResize?: boolean;
  96189. /**
  96190. * Allow the panes to popup (default: true)
  96191. */
  96192. enablePopup?: boolean;
  96193. /**
  96194. * Allow the panes to be closed by users (default: true)
  96195. */
  96196. enableClose?: boolean;
  96197. /**
  96198. * Optional list of extensibility entries
  96199. */
  96200. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96201. }
  96202. interface Scene {
  96203. /**
  96204. * @hidden
  96205. * Backing field
  96206. */
  96207. _debugLayer: DebugLayer;
  96208. /**
  96209. * Gets the debug layer (aka Inspector) associated with the scene
  96210. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96211. */
  96212. debugLayer: DebugLayer;
  96213. }
  96214. /**
  96215. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96216. * what is happening in your scene
  96217. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96218. */
  96219. export class DebugLayer {
  96220. /**
  96221. * Define the url to get the inspector script from.
  96222. * By default it uses the babylonjs CDN.
  96223. * @ignoreNaming
  96224. */
  96225. static InspectorURL: string;
  96226. private _scene;
  96227. private BJSINSPECTOR;
  96228. /**
  96229. * Observable triggered when a property is changed through the inspector.
  96230. */
  96231. onPropertyChangedObservable: Observable<{
  96232. object: any;
  96233. property: string;
  96234. value: any;
  96235. initialValue: any;
  96236. }>;
  96237. /**
  96238. * Instantiates a new debug layer.
  96239. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96240. * what is happening in your scene
  96241. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96242. * @param scene Defines the scene to inspect
  96243. */
  96244. constructor(scene: Scene);
  96245. /** Creates the inspector window. */
  96246. private _createInspector;
  96247. /** Get the inspector from bundle or global */
  96248. private _getGlobalInspector;
  96249. /**
  96250. * Get if the inspector is visible or not.
  96251. * @returns true if visible otherwise, false
  96252. */
  96253. isVisible(): boolean;
  96254. /**
  96255. * Hide the inspector and close its window.
  96256. */
  96257. hide(): void;
  96258. /**
  96259. * Launch the debugLayer.
  96260. * @param config Define the configuration of the inspector
  96261. */
  96262. show(config?: IInspectorOptions): void;
  96263. }
  96264. }
  96265. declare module BABYLON {
  96266. /**
  96267. * Class containing static functions to help procedurally build meshes
  96268. */
  96269. export class BoxBuilder {
  96270. /**
  96271. * Creates a box mesh
  96272. * * The parameter `size` sets the size (float) of each box side (default 1)
  96273. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96274. * * 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)
  96275. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96279. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96280. * @param name defines the name of the mesh
  96281. * @param options defines the options used to create the mesh
  96282. * @param scene defines the hosting scene
  96283. * @returns the box mesh
  96284. */
  96285. static CreateBox(name: string, options: {
  96286. size?: number;
  96287. width?: number;
  96288. height?: number;
  96289. depth?: number;
  96290. faceUV?: Vector4[];
  96291. faceColors?: Color4[];
  96292. sideOrientation?: number;
  96293. frontUVs?: Vector4;
  96294. backUVs?: Vector4;
  96295. updatable?: boolean;
  96296. }, scene?: Nullable<Scene>): Mesh;
  96297. }
  96298. }
  96299. declare module BABYLON {
  96300. /**
  96301. * Class containing static functions to help procedurally build meshes
  96302. */
  96303. export class SphereBuilder {
  96304. /**
  96305. * Creates a sphere mesh
  96306. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96307. * * 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`)
  96308. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96309. * * 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
  96310. * * 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)
  96311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96314. * @param name defines the name of the mesh
  96315. * @param options defines the options used to create the mesh
  96316. * @param scene defines the hosting scene
  96317. * @returns the sphere mesh
  96318. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96319. */
  96320. static CreateSphere(name: string, options: {
  96321. segments?: number;
  96322. diameter?: number;
  96323. diameterX?: number;
  96324. diameterY?: number;
  96325. diameterZ?: number;
  96326. arc?: number;
  96327. slice?: number;
  96328. sideOrientation?: number;
  96329. frontUVs?: Vector4;
  96330. backUVs?: Vector4;
  96331. updatable?: boolean;
  96332. }, scene: any): Mesh;
  96333. }
  96334. }
  96335. declare module BABYLON.Debug {
  96336. /**
  96337. * Used to show the physics impostor around the specific mesh
  96338. */
  96339. export class PhysicsViewer {
  96340. /** @hidden */
  96341. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96342. /** @hidden */
  96343. protected _meshes: Array<Nullable<AbstractMesh>>;
  96344. /** @hidden */
  96345. protected _scene: Nullable<Scene>;
  96346. /** @hidden */
  96347. protected _numMeshes: number;
  96348. /** @hidden */
  96349. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96350. private _renderFunction;
  96351. private _utilityLayer;
  96352. private _debugBoxMesh;
  96353. private _debugSphereMesh;
  96354. private _debugMaterial;
  96355. /**
  96356. * Creates a new PhysicsViewer
  96357. * @param scene defines the hosting scene
  96358. */
  96359. constructor(scene: Scene);
  96360. /** @hidden */
  96361. protected _updateDebugMeshes(): void;
  96362. /**
  96363. * Renders a specified physic impostor
  96364. * @param impostor defines the impostor to render
  96365. * @returns the new debug mesh used to render the impostor
  96366. */
  96367. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96368. /**
  96369. * Hides a specified physic impostor
  96370. * @param impostor defines the impostor to hide
  96371. */
  96372. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96373. private _getDebugMaterial;
  96374. private _getDebugBoxMesh;
  96375. private _getDebugSphereMesh;
  96376. private _getDebugMesh;
  96377. /** Releases all resources */
  96378. dispose(): void;
  96379. }
  96380. }
  96381. declare module BABYLON {
  96382. /**
  96383. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96384. * in order to better appreciate the issue one might have.
  96385. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96386. */
  96387. export class RayHelper {
  96388. /**
  96389. * Defines the ray we are currently tryin to visualize.
  96390. */
  96391. ray: Nullable<Ray>;
  96392. private _renderPoints;
  96393. private _renderLine;
  96394. private _renderFunction;
  96395. private _scene;
  96396. private _updateToMeshFunction;
  96397. private _attachedToMesh;
  96398. private _meshSpaceDirection;
  96399. private _meshSpaceOrigin;
  96400. /**
  96401. * Helper function to create a colored helper in a scene in one line.
  96402. * @param ray Defines the ray we are currently tryin to visualize
  96403. * @param scene Defines the scene the ray is used in
  96404. * @param color Defines the color we want to see the ray in
  96405. * @returns The newly created ray helper.
  96406. */
  96407. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96408. /**
  96409. * Instantiate a new ray helper.
  96410. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96411. * in order to better appreciate the issue one might have.
  96412. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96413. * @param ray Defines the ray we are currently tryin to visualize
  96414. */
  96415. constructor(ray: Ray);
  96416. /**
  96417. * Shows the ray we are willing to debug.
  96418. * @param scene Defines the scene the ray needs to be rendered in
  96419. * @param color Defines the color the ray needs to be rendered in
  96420. */
  96421. show(scene: Scene, color?: Color3): void;
  96422. /**
  96423. * Hides the ray we are debugging.
  96424. */
  96425. hide(): void;
  96426. private _render;
  96427. /**
  96428. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96429. * @param mesh Defines the mesh we want the helper attached to
  96430. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96431. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96432. * @param length Defines the length of the ray
  96433. */
  96434. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96435. /**
  96436. * Detach the ray helper from the mesh it has previously been attached to.
  96437. */
  96438. detachFromMesh(): void;
  96439. private _updateToMesh;
  96440. /**
  96441. * Dispose the helper and release its associated resources.
  96442. */
  96443. dispose(): void;
  96444. }
  96445. }
  96446. declare module BABYLON.Debug {
  96447. /**
  96448. * Class used to render a debug view of a given skeleton
  96449. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96450. */
  96451. export class SkeletonViewer {
  96452. /** defines the skeleton to render */
  96453. skeleton: Skeleton;
  96454. /** defines the mesh attached to the skeleton */
  96455. mesh: AbstractMesh;
  96456. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96457. autoUpdateBonesMatrices: boolean;
  96458. /** defines the rendering group id to use with the viewer */
  96459. renderingGroupId: number;
  96460. /** Gets or sets the color used to render the skeleton */
  96461. color: Color3;
  96462. private _scene;
  96463. private _debugLines;
  96464. private _debugMesh;
  96465. private _isEnabled;
  96466. private _renderFunction;
  96467. private _utilityLayer;
  96468. /**
  96469. * Returns the mesh used to render the bones
  96470. */
  96471. readonly debugMesh: Nullable<LinesMesh>;
  96472. /**
  96473. * Creates a new SkeletonViewer
  96474. * @param skeleton defines the skeleton to render
  96475. * @param mesh defines the mesh attached to the skeleton
  96476. * @param scene defines the hosting scene
  96477. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96478. * @param renderingGroupId defines the rendering group id to use with the viewer
  96479. */
  96480. constructor(
  96481. /** defines the skeleton to render */
  96482. skeleton: Skeleton,
  96483. /** defines the mesh attached to the skeleton */
  96484. mesh: AbstractMesh, scene: Scene,
  96485. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96486. autoUpdateBonesMatrices?: boolean,
  96487. /** defines the rendering group id to use with the viewer */
  96488. renderingGroupId?: number);
  96489. /** Gets or sets a boolean indicating if the viewer is enabled */
  96490. isEnabled: boolean;
  96491. private _getBonePosition;
  96492. private _getLinesForBonesWithLength;
  96493. private _getLinesForBonesNoLength;
  96494. /** Update the viewer to sync with current skeleton state */
  96495. update(): void;
  96496. /** Release associated resources */
  96497. dispose(): void;
  96498. }
  96499. }
  96500. declare module BABYLON {
  96501. /**
  96502. * Options to create the null engine
  96503. */
  96504. export class NullEngineOptions {
  96505. /**
  96506. * Render width (Default: 512)
  96507. */
  96508. renderWidth: number;
  96509. /**
  96510. * Render height (Default: 256)
  96511. */
  96512. renderHeight: number;
  96513. /**
  96514. * Texture size (Default: 512)
  96515. */
  96516. textureSize: number;
  96517. /**
  96518. * If delta time between frames should be constant
  96519. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96520. */
  96521. deterministicLockstep: boolean;
  96522. /**
  96523. * Maximum about of steps between frames (Default: 4)
  96524. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96525. */
  96526. lockstepMaxSteps: number;
  96527. }
  96528. /**
  96529. * The null engine class provides support for headless version of babylon.js.
  96530. * This can be used in server side scenario or for testing purposes
  96531. */
  96532. export class NullEngine extends Engine {
  96533. private _options;
  96534. /**
  96535. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96536. */
  96537. isDeterministicLockStep(): boolean;
  96538. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96539. getLockstepMaxSteps(): number;
  96540. /**
  96541. * Sets hardware scaling, used to save performance if needed
  96542. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96543. */
  96544. getHardwareScalingLevel(): number;
  96545. constructor(options?: NullEngineOptions);
  96546. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96547. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96548. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96549. getRenderWidth(useScreen?: boolean): number;
  96550. getRenderHeight(useScreen?: boolean): number;
  96551. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96552. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96553. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96554. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96555. bindSamplers(effect: Effect): void;
  96556. enableEffect(effect: Effect): void;
  96557. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96558. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96559. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96560. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96561. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96562. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96563. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96564. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96565. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96566. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96567. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96568. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96569. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96570. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96571. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96572. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96573. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96574. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96575. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96576. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96577. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96578. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96579. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96580. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96581. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96582. bindBuffers(vertexBuffers: {
  96583. [key: string]: VertexBuffer;
  96584. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96585. wipeCaches(bruteForce?: boolean): void;
  96586. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96587. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96588. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96589. /** @hidden */
  96590. _createTexture(): WebGLTexture;
  96591. /** @hidden */
  96592. _releaseTexture(texture: InternalTexture): void;
  96593. 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;
  96594. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96595. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96596. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96597. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96598. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96599. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96600. areAllEffectsReady(): boolean;
  96601. /**
  96602. * @hidden
  96603. * Get the current error code of the webGL context
  96604. * @returns the error code
  96605. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96606. */
  96607. getError(): number;
  96608. /** @hidden */
  96609. _getUnpackAlignement(): number;
  96610. /** @hidden */
  96611. _unpackFlipY(value: boolean): void;
  96612. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96613. /**
  96614. * Updates a dynamic vertex buffer.
  96615. * @param vertexBuffer the vertex buffer to update
  96616. * @param data the data used to update the vertex buffer
  96617. * @param byteOffset the byte offset of the data (optional)
  96618. * @param byteLength the byte length of the data (optional)
  96619. */
  96620. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96621. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96622. /** @hidden */
  96623. _bindTexture(channel: number, texture: InternalTexture): void;
  96624. /** @hidden */
  96625. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96626. releaseEffects(): void;
  96627. displayLoadingUI(): void;
  96628. hideLoadingUI(): void;
  96629. /** @hidden */
  96630. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96631. /** @hidden */
  96632. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96633. /** @hidden */
  96634. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96635. /** @hidden */
  96636. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96637. }
  96638. }
  96639. declare module BABYLON {
  96640. /** @hidden */
  96641. export class _OcclusionDataStorage {
  96642. /** @hidden */
  96643. occlusionInternalRetryCounter: number;
  96644. /** @hidden */
  96645. isOcclusionQueryInProgress: boolean;
  96646. /** @hidden */
  96647. isOccluded: boolean;
  96648. /** @hidden */
  96649. occlusionRetryCount: number;
  96650. /** @hidden */
  96651. occlusionType: number;
  96652. /** @hidden */
  96653. occlusionQueryAlgorithmType: number;
  96654. }
  96655. interface Engine {
  96656. /**
  96657. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96658. * @return the new query
  96659. */
  96660. createQuery(): WebGLQuery;
  96661. /**
  96662. * Delete and release a webGL query
  96663. * @param query defines the query to delete
  96664. * @return the current engine
  96665. */
  96666. deleteQuery(query: WebGLQuery): Engine;
  96667. /**
  96668. * Check if a given query has resolved and got its value
  96669. * @param query defines the query to check
  96670. * @returns true if the query got its value
  96671. */
  96672. isQueryResultAvailable(query: WebGLQuery): boolean;
  96673. /**
  96674. * Gets the value of a given query
  96675. * @param query defines the query to check
  96676. * @returns the value of the query
  96677. */
  96678. getQueryResult(query: WebGLQuery): number;
  96679. /**
  96680. * Initiates an occlusion query
  96681. * @param algorithmType defines the algorithm to use
  96682. * @param query defines the query to use
  96683. * @returns the current engine
  96684. * @see http://doc.babylonjs.com/features/occlusionquery
  96685. */
  96686. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96687. /**
  96688. * Ends an occlusion query
  96689. * @see http://doc.babylonjs.com/features/occlusionquery
  96690. * @param algorithmType defines the algorithm to use
  96691. * @returns the current engine
  96692. */
  96693. endOcclusionQuery(algorithmType: number): Engine;
  96694. /**
  96695. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96696. * Please note that only one query can be issued at a time
  96697. * @returns a time token used to track the time span
  96698. */
  96699. startTimeQuery(): Nullable<_TimeToken>;
  96700. /**
  96701. * Ends a time query
  96702. * @param token defines the token used to measure the time span
  96703. * @returns the time spent (in ns)
  96704. */
  96705. endTimeQuery(token: _TimeToken): int;
  96706. /** @hidden */
  96707. _currentNonTimestampToken: Nullable<_TimeToken>;
  96708. /** @hidden */
  96709. _createTimeQuery(): WebGLQuery;
  96710. /** @hidden */
  96711. _deleteTimeQuery(query: WebGLQuery): void;
  96712. /** @hidden */
  96713. _getGlAlgorithmType(algorithmType: number): number;
  96714. /** @hidden */
  96715. _getTimeQueryResult(query: WebGLQuery): any;
  96716. /** @hidden */
  96717. _getTimeQueryAvailability(query: WebGLQuery): any;
  96718. }
  96719. interface AbstractMesh {
  96720. /**
  96721. * Backing filed
  96722. * @hidden
  96723. */
  96724. __occlusionDataStorage: _OcclusionDataStorage;
  96725. /**
  96726. * Access property
  96727. * @hidden
  96728. */
  96729. _occlusionDataStorage: _OcclusionDataStorage;
  96730. /**
  96731. * 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.
  96732. * The default value is -1 which means don't break the query and wait till the result
  96733. * @see http://doc.babylonjs.com/features/occlusionquery
  96734. */
  96735. occlusionRetryCount: number;
  96736. /**
  96737. * 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:
  96738. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96739. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96740. * * 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.
  96741. * @see http://doc.babylonjs.com/features/occlusionquery
  96742. */
  96743. occlusionType: number;
  96744. /**
  96745. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96746. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96747. * * 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.
  96748. * @see http://doc.babylonjs.com/features/occlusionquery
  96749. */
  96750. occlusionQueryAlgorithmType: number;
  96751. /**
  96752. * 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
  96753. * @see http://doc.babylonjs.com/features/occlusionquery
  96754. */
  96755. isOccluded: boolean;
  96756. /**
  96757. * Flag to check the progress status of the query
  96758. * @see http://doc.babylonjs.com/features/occlusionquery
  96759. */
  96760. isOcclusionQueryInProgress: boolean;
  96761. }
  96762. }
  96763. declare module BABYLON {
  96764. /** @hidden */
  96765. export var _forceTransformFeedbackToBundle: boolean;
  96766. interface Engine {
  96767. /**
  96768. * Creates a webGL transform feedback object
  96769. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96770. * @returns the webGL transform feedback object
  96771. */
  96772. createTransformFeedback(): WebGLTransformFeedback;
  96773. /**
  96774. * Delete a webGL transform feedback object
  96775. * @param value defines the webGL transform feedback object to delete
  96776. */
  96777. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96778. /**
  96779. * Bind a webGL transform feedback object to the webgl context
  96780. * @param value defines the webGL transform feedback object to bind
  96781. */
  96782. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96783. /**
  96784. * Begins a transform feedback operation
  96785. * @param usePoints defines if points or triangles must be used
  96786. */
  96787. beginTransformFeedback(usePoints: boolean): void;
  96788. /**
  96789. * Ends a transform feedback operation
  96790. */
  96791. endTransformFeedback(): void;
  96792. /**
  96793. * Specify the varyings to use with transform feedback
  96794. * @param program defines the associated webGL program
  96795. * @param value defines the list of strings representing the varying names
  96796. */
  96797. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96798. /**
  96799. * Bind a webGL buffer for a transform feedback operation
  96800. * @param value defines the webGL buffer to bind
  96801. */
  96802. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96803. }
  96804. }
  96805. declare module BABYLON {
  96806. /**
  96807. * Gather the list of clipboard event types as constants.
  96808. */
  96809. export class ClipboardEventTypes {
  96810. /**
  96811. * The clipboard event is fired when a copy command is active (pressed).
  96812. */
  96813. static readonly COPY: number;
  96814. /**
  96815. * The clipboard event is fired when a cut command is active (pressed).
  96816. */
  96817. static readonly CUT: number;
  96818. /**
  96819. * The clipboard event is fired when a paste command is active (pressed).
  96820. */
  96821. static readonly PASTE: number;
  96822. }
  96823. /**
  96824. * This class is used to store clipboard related info for the onClipboardObservable event.
  96825. */
  96826. export class ClipboardInfo {
  96827. /**
  96828. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96829. */
  96830. type: number;
  96831. /**
  96832. * Defines the related dom event
  96833. */
  96834. event: ClipboardEvent;
  96835. /**
  96836. *Creates an instance of ClipboardInfo.
  96837. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  96838. * @param event Defines the related dom event
  96839. */
  96840. constructor(
  96841. /**
  96842. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96843. */
  96844. type: number,
  96845. /**
  96846. * Defines the related dom event
  96847. */
  96848. event: ClipboardEvent);
  96849. /**
  96850. * Get the clipboard event's type from the keycode.
  96851. * @param keyCode Defines the keyCode for the current keyboard event.
  96852. * @return {number}
  96853. */
  96854. static GetTypeFromCharacter(keyCode: number): number;
  96855. }
  96856. }
  96857. declare module BABYLON {
  96858. /**
  96859. * Class used to represent data loading progression
  96860. */
  96861. export class SceneLoaderProgressEvent {
  96862. /** defines if data length to load can be evaluated */
  96863. readonly lengthComputable: boolean;
  96864. /** defines the loaded data length */
  96865. readonly loaded: number;
  96866. /** defines the data length to load */
  96867. readonly total: number;
  96868. /**
  96869. * Create a new progress event
  96870. * @param lengthComputable defines if data length to load can be evaluated
  96871. * @param loaded defines the loaded data length
  96872. * @param total defines the data length to load
  96873. */
  96874. constructor(
  96875. /** defines if data length to load can be evaluated */
  96876. lengthComputable: boolean,
  96877. /** defines the loaded data length */
  96878. loaded: number,
  96879. /** defines the data length to load */
  96880. total: number);
  96881. /**
  96882. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96883. * @param event defines the source event
  96884. * @returns a new SceneLoaderProgressEvent
  96885. */
  96886. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96887. }
  96888. /**
  96889. * Interface used by SceneLoader plugins to define supported file extensions
  96890. */
  96891. export interface ISceneLoaderPluginExtensions {
  96892. /**
  96893. * Defines the list of supported extensions
  96894. */
  96895. [extension: string]: {
  96896. isBinary: boolean;
  96897. };
  96898. }
  96899. /**
  96900. * Interface used by SceneLoader plugin factory
  96901. */
  96902. export interface ISceneLoaderPluginFactory {
  96903. /**
  96904. * Defines the name of the factory
  96905. */
  96906. name: string;
  96907. /**
  96908. * Function called to create a new plugin
  96909. * @return the new plugin
  96910. */
  96911. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96912. /**
  96913. * Boolean indicating if the plugin can direct load specific data
  96914. */
  96915. canDirectLoad?: (data: string) => boolean;
  96916. }
  96917. /**
  96918. * Interface used to define a SceneLoader plugin
  96919. */
  96920. export interface ISceneLoaderPlugin {
  96921. /**
  96922. * The friendly name of this plugin.
  96923. */
  96924. name: string;
  96925. /**
  96926. * The file extensions supported by this plugin.
  96927. */
  96928. extensions: string | ISceneLoaderPluginExtensions;
  96929. /**
  96930. * Import meshes into a scene.
  96931. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96932. * @param scene The scene to import into
  96933. * @param data The data to import
  96934. * @param rootUrl The root url for scene and resources
  96935. * @param meshes The meshes array to import into
  96936. * @param particleSystems The particle systems array to import into
  96937. * @param skeletons The skeletons array to import into
  96938. * @param onError The callback when import fails
  96939. * @returns True if successful or false otherwise
  96940. */
  96941. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  96942. /**
  96943. * Load into a scene.
  96944. * @param scene The scene to load into
  96945. * @param data The data to import
  96946. * @param rootUrl The root url for scene and resources
  96947. * @param onError The callback when import fails
  96948. * @returns true if successful or false otherwise
  96949. */
  96950. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  96951. /**
  96952. * The callback that returns true if the data can be directly loaded.
  96953. */
  96954. canDirectLoad?: (data: string) => boolean;
  96955. /**
  96956. * The callback that allows custom handling of the root url based on the response url.
  96957. */
  96958. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96959. /**
  96960. * Load into an asset container.
  96961. * @param scene The scene to load into
  96962. * @param data The data to import
  96963. * @param rootUrl The root url for scene and resources
  96964. * @param onError The callback when import fails
  96965. * @returns The loaded asset container
  96966. */
  96967. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  96968. }
  96969. /**
  96970. * Interface used to define an async SceneLoader plugin
  96971. */
  96972. export interface ISceneLoaderPluginAsync {
  96973. /**
  96974. * The friendly name of this plugin.
  96975. */
  96976. name: string;
  96977. /**
  96978. * The file extensions supported by this plugin.
  96979. */
  96980. extensions: string | ISceneLoaderPluginExtensions;
  96981. /**
  96982. * Import meshes into a scene.
  96983. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96984. * @param scene The scene to import into
  96985. * @param data The data to import
  96986. * @param rootUrl The root url for scene and resources
  96987. * @param onProgress The callback when the load progresses
  96988. * @param fileName Defines the name of the file to load
  96989. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  96990. */
  96991. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  96992. meshes: AbstractMesh[];
  96993. particleSystems: IParticleSystem[];
  96994. skeletons: Skeleton[];
  96995. animationGroups: AnimationGroup[];
  96996. }>;
  96997. /**
  96998. * Load into a scene.
  96999. * @param scene The scene to load into
  97000. * @param data The data to import
  97001. * @param rootUrl The root url for scene and resources
  97002. * @param onProgress The callback when the load progresses
  97003. * @param fileName Defines the name of the file to load
  97004. * @returns Nothing
  97005. */
  97006. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  97007. /**
  97008. * The callback that returns true if the data can be directly loaded.
  97009. */
  97010. canDirectLoad?: (data: string) => boolean;
  97011. /**
  97012. * The callback that allows custom handling of the root url based on the response url.
  97013. */
  97014. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97015. /**
  97016. * Load into an asset container.
  97017. * @param scene The scene to load into
  97018. * @param data The data to import
  97019. * @param rootUrl The root url for scene and resources
  97020. * @param onProgress The callback when the load progresses
  97021. * @param fileName Defines the name of the file to load
  97022. * @returns The loaded asset container
  97023. */
  97024. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  97025. }
  97026. /**
  97027. * Class used to load scene from various file formats using registered plugins
  97028. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  97029. */
  97030. export class SceneLoader {
  97031. /**
  97032. * No logging while loading
  97033. */
  97034. static readonly NO_LOGGING: number;
  97035. /**
  97036. * Minimal logging while loading
  97037. */
  97038. static readonly MINIMAL_LOGGING: number;
  97039. /**
  97040. * Summary logging while loading
  97041. */
  97042. static readonly SUMMARY_LOGGING: number;
  97043. /**
  97044. * Detailled logging while loading
  97045. */
  97046. static readonly DETAILED_LOGGING: number;
  97047. /**
  97048. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97049. */
  97050. static ForceFullSceneLoadingForIncremental: boolean;
  97051. /**
  97052. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97053. */
  97054. static ShowLoadingScreen: boolean;
  97055. /**
  97056. * Defines the current logging level (while loading the scene)
  97057. * @ignorenaming
  97058. */
  97059. static loggingLevel: number;
  97060. /**
  97061. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97062. */
  97063. static CleanBoneMatrixWeights: boolean;
  97064. /**
  97065. * Event raised when a plugin is used to load a scene
  97066. */
  97067. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  97068. private static _registeredPlugins;
  97069. private static _getDefaultPlugin;
  97070. private static _getPluginForExtension;
  97071. private static _getPluginForDirectLoad;
  97072. private static _getPluginForFilename;
  97073. private static _getDirectLoad;
  97074. private static _loadData;
  97075. private static _getFileInfo;
  97076. /**
  97077. * Gets a plugin that can load the given extension
  97078. * @param extension defines the extension to load
  97079. * @returns a plugin or null if none works
  97080. */
  97081. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97082. /**
  97083. * Gets a boolean indicating that the given extension can be loaded
  97084. * @param extension defines the extension to load
  97085. * @returns true if the extension is supported
  97086. */
  97087. static IsPluginForExtensionAvailable(extension: string): boolean;
  97088. /**
  97089. * Adds a new plugin to the list of registered plugins
  97090. * @param plugin defines the plugin to add
  97091. */
  97092. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97093. /**
  97094. * Import meshes into a scene
  97095. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97096. * @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)
  97097. * @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)
  97098. * @param scene the instance of BABYLON.Scene to append to
  97099. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97100. * @param onProgress a callback with a progress event for each file being loaded
  97101. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97102. * @param pluginExtension the extension used to determine the plugin
  97103. * @returns The loaded plugin
  97104. */
  97105. 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>;
  97106. /**
  97107. * Import meshes into a scene
  97108. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97109. * @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)
  97110. * @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)
  97111. * @param scene the instance of BABYLON.Scene to append to
  97112. * @param onProgress a callback with a progress event for each file being loaded
  97113. * @param pluginExtension the extension used to determine the plugin
  97114. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97115. */
  97116. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97117. meshes: AbstractMesh[];
  97118. particleSystems: IParticleSystem[];
  97119. skeletons: Skeleton[];
  97120. animationGroups: AnimationGroup[];
  97121. }>;
  97122. /**
  97123. * Load a scene
  97124. * @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)
  97125. * @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)
  97126. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97127. * @param onSuccess a callback with the scene when import succeeds
  97128. * @param onProgress a callback with a progress event for each file being loaded
  97129. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97130. * @param pluginExtension the extension used to determine the plugin
  97131. * @returns The loaded plugin
  97132. */
  97133. 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>;
  97134. /**
  97135. * Load a scene
  97136. * @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)
  97137. * @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)
  97138. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97139. * @param onProgress a callback with a progress event for each file being loaded
  97140. * @param pluginExtension the extension used to determine the plugin
  97141. * @returns The loaded scene
  97142. */
  97143. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97144. /**
  97145. * Append a scene
  97146. * @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)
  97147. * @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)
  97148. * @param scene is the instance of BABYLON.Scene to append to
  97149. * @param onSuccess a callback with the scene when import succeeds
  97150. * @param onProgress a callback with a progress event for each file being loaded
  97151. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97152. * @param pluginExtension the extension used to determine the plugin
  97153. * @returns The loaded plugin
  97154. */
  97155. 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>;
  97156. /**
  97157. * Append a scene
  97158. * @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)
  97159. * @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)
  97160. * @param scene is the instance of BABYLON.Scene to append to
  97161. * @param onProgress a callback with a progress event for each file being loaded
  97162. * @param pluginExtension the extension used to determine the plugin
  97163. * @returns The given scene
  97164. */
  97165. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97166. /**
  97167. * Load a scene into an asset container
  97168. * @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)
  97169. * @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)
  97170. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97171. * @param onSuccess a callback with the scene when import succeeds
  97172. * @param onProgress a callback with a progress event for each file being loaded
  97173. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97174. * @param pluginExtension the extension used to determine the plugin
  97175. * @returns The loaded plugin
  97176. */
  97177. 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>;
  97178. /**
  97179. * Load a scene into an asset container
  97180. * @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)
  97181. * @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)
  97182. * @param scene is the instance of Scene to append to
  97183. * @param onProgress a callback with a progress event for each file being loaded
  97184. * @param pluginExtension the extension used to determine the plugin
  97185. * @returns The loaded asset container
  97186. */
  97187. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97188. }
  97189. }
  97190. declare module BABYLON {
  97191. /**
  97192. * Google Daydream controller
  97193. */
  97194. export class DaydreamController extends WebVRController {
  97195. /**
  97196. * Base Url for the controller model.
  97197. */
  97198. static MODEL_BASE_URL: string;
  97199. /**
  97200. * File name for the controller model.
  97201. */
  97202. static MODEL_FILENAME: string;
  97203. /**
  97204. * Gamepad Id prefix used to identify Daydream Controller.
  97205. */
  97206. static readonly GAMEPAD_ID_PREFIX: string;
  97207. /**
  97208. * Creates a new DaydreamController from a gamepad
  97209. * @param vrGamepad the gamepad that the controller should be created from
  97210. */
  97211. constructor(vrGamepad: any);
  97212. /**
  97213. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97214. * @param scene scene in which to add meshes
  97215. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97216. */
  97217. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97218. /**
  97219. * Called once for each button that changed state since the last frame
  97220. * @param buttonIdx Which button index changed
  97221. * @param state New state of the button
  97222. * @param changes Which properties on the state changed since last frame
  97223. */
  97224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97225. }
  97226. }
  97227. declare module BABYLON {
  97228. /**
  97229. * Gear VR Controller
  97230. */
  97231. export class GearVRController extends WebVRController {
  97232. /**
  97233. * Base Url for the controller model.
  97234. */
  97235. static MODEL_BASE_URL: string;
  97236. /**
  97237. * File name for the controller model.
  97238. */
  97239. static MODEL_FILENAME: string;
  97240. /**
  97241. * Gamepad Id prefix used to identify this controller.
  97242. */
  97243. static readonly GAMEPAD_ID_PREFIX: string;
  97244. private readonly _buttonIndexToObservableNameMap;
  97245. /**
  97246. * Creates a new GearVRController from a gamepad
  97247. * @param vrGamepad the gamepad that the controller should be created from
  97248. */
  97249. constructor(vrGamepad: any);
  97250. /**
  97251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97252. * @param scene scene in which to add meshes
  97253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97254. */
  97255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97256. /**
  97257. * Called once for each button that changed state since the last frame
  97258. * @param buttonIdx Which button index changed
  97259. * @param state New state of the button
  97260. * @param changes Which properties on the state changed since last frame
  97261. */
  97262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97263. }
  97264. }
  97265. declare module BABYLON {
  97266. /**
  97267. * Generic Controller
  97268. */
  97269. export class GenericController extends WebVRController {
  97270. /**
  97271. * Base Url for the controller model.
  97272. */
  97273. static readonly MODEL_BASE_URL: string;
  97274. /**
  97275. * File name for the controller model.
  97276. */
  97277. static readonly MODEL_FILENAME: string;
  97278. /**
  97279. * Creates a new GenericController from a gamepad
  97280. * @param vrGamepad the gamepad that the controller should be created from
  97281. */
  97282. constructor(vrGamepad: any);
  97283. /**
  97284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97285. * @param scene scene in which to add meshes
  97286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97287. */
  97288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97289. /**
  97290. * Called once for each button that changed state since the last frame
  97291. * @param buttonIdx Which button index changed
  97292. * @param state New state of the button
  97293. * @param changes Which properties on the state changed since last frame
  97294. */
  97295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97296. }
  97297. }
  97298. declare module BABYLON {
  97299. /**
  97300. * Oculus Touch Controller
  97301. */
  97302. export class OculusTouchController extends WebVRController {
  97303. /**
  97304. * Base Url for the controller model.
  97305. */
  97306. static MODEL_BASE_URL: string;
  97307. /**
  97308. * File name for the left controller model.
  97309. */
  97310. static MODEL_LEFT_FILENAME: string;
  97311. /**
  97312. * File name for the right controller model.
  97313. */
  97314. static MODEL_RIGHT_FILENAME: string;
  97315. /**
  97316. * Fired when the secondary trigger on this controller is modified
  97317. */
  97318. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97319. /**
  97320. * Fired when the thumb rest on this controller is modified
  97321. */
  97322. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97323. /**
  97324. * Creates a new OculusTouchController from a gamepad
  97325. * @param vrGamepad the gamepad that the controller should be created from
  97326. */
  97327. constructor(vrGamepad: any);
  97328. /**
  97329. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97330. * @param scene scene in which to add meshes
  97331. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97332. */
  97333. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97334. /**
  97335. * Fired when the A button on this controller is modified
  97336. */
  97337. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97338. /**
  97339. * Fired when the B button on this controller is modified
  97340. */
  97341. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97342. /**
  97343. * Fired when the X button on this controller is modified
  97344. */
  97345. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97346. /**
  97347. * Fired when the Y button on this controller is modified
  97348. */
  97349. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97350. /**
  97351. * Called once for each button that changed state since the last frame
  97352. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97353. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97354. * 2) secondary trigger (same)
  97355. * 3) A (right) X (left), touch, pressed = value
  97356. * 4) B / Y
  97357. * 5) thumb rest
  97358. * @param buttonIdx Which button index changed
  97359. * @param state New state of the button
  97360. * @param changes Which properties on the state changed since last frame
  97361. */
  97362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97363. }
  97364. }
  97365. declare module BABYLON {
  97366. /**
  97367. * Vive Controller
  97368. */
  97369. export class ViveController extends WebVRController {
  97370. /**
  97371. * Base Url for the controller model.
  97372. */
  97373. static MODEL_BASE_URL: string;
  97374. /**
  97375. * File name for the controller model.
  97376. */
  97377. static MODEL_FILENAME: string;
  97378. /**
  97379. * Creates a new ViveController from a gamepad
  97380. * @param vrGamepad the gamepad that the controller should be created from
  97381. */
  97382. constructor(vrGamepad: any);
  97383. /**
  97384. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97385. * @param scene scene in which to add meshes
  97386. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97387. */
  97388. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97389. /**
  97390. * Fired when the left button on this controller is modified
  97391. */
  97392. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97393. /**
  97394. * Fired when the right button on this controller is modified
  97395. */
  97396. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97397. /**
  97398. * Fired when the menu button on this controller is modified
  97399. */
  97400. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97401. /**
  97402. * Called once for each button that changed state since the last frame
  97403. * Vive mapping:
  97404. * 0: touchpad
  97405. * 1: trigger
  97406. * 2: left AND right buttons
  97407. * 3: menu button
  97408. * @param buttonIdx Which button index changed
  97409. * @param state New state of the button
  97410. * @param changes Which properties on the state changed since last frame
  97411. */
  97412. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97413. }
  97414. }
  97415. declare module BABYLON {
  97416. /**
  97417. * Defines the WindowsMotionController object that the state of the windows motion controller
  97418. */
  97419. export class WindowsMotionController extends WebVRController {
  97420. /**
  97421. * The base url used to load the left and right controller models
  97422. */
  97423. static MODEL_BASE_URL: string;
  97424. /**
  97425. * The name of the left controller model file
  97426. */
  97427. static MODEL_LEFT_FILENAME: string;
  97428. /**
  97429. * The name of the right controller model file
  97430. */
  97431. static MODEL_RIGHT_FILENAME: string;
  97432. /**
  97433. * The controller name prefix for this controller type
  97434. */
  97435. static readonly GAMEPAD_ID_PREFIX: string;
  97436. /**
  97437. * The controller id pattern for this controller type
  97438. */
  97439. private static readonly GAMEPAD_ID_PATTERN;
  97440. private _loadedMeshInfo;
  97441. private readonly _mapping;
  97442. /**
  97443. * Fired when the trackpad on this controller is clicked
  97444. */
  97445. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97446. /**
  97447. * Fired when the trackpad on this controller is modified
  97448. */
  97449. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97450. /**
  97451. * The current x and y values of this controller's trackpad
  97452. */
  97453. trackpad: StickValues;
  97454. /**
  97455. * Creates a new WindowsMotionController from a gamepad
  97456. * @param vrGamepad the gamepad that the controller should be created from
  97457. */
  97458. constructor(vrGamepad: any);
  97459. /**
  97460. * Fired when the trigger on this controller is modified
  97461. */
  97462. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97463. /**
  97464. * Fired when the menu button on this controller is modified
  97465. */
  97466. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97467. /**
  97468. * Fired when the grip button on this controller is modified
  97469. */
  97470. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97471. /**
  97472. * Fired when the thumbstick button on this controller is modified
  97473. */
  97474. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97475. /**
  97476. * Fired when the touchpad button on this controller is modified
  97477. */
  97478. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97479. /**
  97480. * Fired when the touchpad values on this controller are modified
  97481. */
  97482. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97483. private _updateTrackpad;
  97484. /**
  97485. * Called once per frame by the engine.
  97486. */
  97487. update(): void;
  97488. /**
  97489. * Called once for each button that changed state since the last frame
  97490. * @param buttonIdx Which button index changed
  97491. * @param state New state of the button
  97492. * @param changes Which properties on the state changed since last frame
  97493. */
  97494. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97495. /**
  97496. * Moves the buttons on the controller mesh based on their current state
  97497. * @param buttonName the name of the button to move
  97498. * @param buttonValue the value of the button which determines the buttons new position
  97499. */
  97500. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97501. /**
  97502. * Moves the axis on the controller mesh based on its current state
  97503. * @param axis the index of the axis
  97504. * @param axisValue the value of the axis which determines the meshes new position
  97505. * @hidden
  97506. */
  97507. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97508. /**
  97509. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97510. * @param scene scene in which to add meshes
  97511. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97512. */
  97513. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97514. /**
  97515. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97516. * can be transformed by button presses and axes values, based on this._mapping.
  97517. *
  97518. * @param scene scene in which the meshes exist
  97519. * @param meshes list of meshes that make up the controller model to process
  97520. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97521. */
  97522. private processModel;
  97523. private createMeshInfo;
  97524. /**
  97525. * Gets the ray of the controller in the direction the controller is pointing
  97526. * @param length the length the resulting ray should be
  97527. * @returns a ray in the direction the controller is pointing
  97528. */
  97529. getForwardRay(length?: number): Ray;
  97530. /**
  97531. * Disposes of the controller
  97532. */
  97533. dispose(): void;
  97534. }
  97535. }
  97536. declare module BABYLON {
  97537. /**
  97538. * Single axis scale gizmo
  97539. */
  97540. export class AxisScaleGizmo extends Gizmo {
  97541. private _coloredMaterial;
  97542. /**
  97543. * Drag behavior responsible for the gizmos dragging interactions
  97544. */
  97545. dragBehavior: PointerDragBehavior;
  97546. private _pointerObserver;
  97547. /**
  97548. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97549. */
  97550. snapDistance: number;
  97551. /**
  97552. * Event that fires each time the gizmo snaps to a new location.
  97553. * * snapDistance is the the change in distance
  97554. */
  97555. onSnapObservable: Observable<{
  97556. snapDistance: number;
  97557. }>;
  97558. /**
  97559. * If the scaling operation should be done on all axis (default: false)
  97560. */
  97561. uniformScaling: boolean;
  97562. /**
  97563. * Creates an AxisScaleGizmo
  97564. * @param gizmoLayer The utility layer the gizmo will be added to
  97565. * @param dragAxis The axis which the gizmo will be able to scale on
  97566. * @param color The color of the gizmo
  97567. */
  97568. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97569. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97570. /**
  97571. * Disposes of the gizmo
  97572. */
  97573. dispose(): void;
  97574. /**
  97575. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97576. * @param mesh The mesh to replace the default mesh of the gizmo
  97577. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97578. */
  97579. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97580. }
  97581. }
  97582. declare module BABYLON {
  97583. /**
  97584. * Bounding box gizmo
  97585. */
  97586. export class BoundingBoxGizmo extends Gizmo {
  97587. private _lineBoundingBox;
  97588. private _rotateSpheresParent;
  97589. private _scaleBoxesParent;
  97590. private _boundingDimensions;
  97591. private _renderObserver;
  97592. private _pointerObserver;
  97593. private _scaleDragSpeed;
  97594. private _tmpQuaternion;
  97595. private _tmpVector;
  97596. private _tmpRotationMatrix;
  97597. /**
  97598. * 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)
  97599. */
  97600. ignoreChildren: boolean;
  97601. /**
  97602. * 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)
  97603. */
  97604. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97605. /**
  97606. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97607. */
  97608. rotationSphereSize: number;
  97609. /**
  97610. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97611. */
  97612. scaleBoxSize: number;
  97613. /**
  97614. * 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)
  97615. */
  97616. fixedDragMeshScreenSize: boolean;
  97617. /**
  97618. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97619. */
  97620. fixedDragMeshScreenSizeDistanceFactor: number;
  97621. /**
  97622. * Fired when a rotation sphere or scale box is dragged
  97623. */
  97624. onDragStartObservable: Observable<{}>;
  97625. /**
  97626. * Fired when a scale box is dragged
  97627. */
  97628. onScaleBoxDragObservable: Observable<{}>;
  97629. /**
  97630. * Fired when a scale box drag is ended
  97631. */
  97632. onScaleBoxDragEndObservable: Observable<{}>;
  97633. /**
  97634. * Fired when a rotation sphere is dragged
  97635. */
  97636. onRotationSphereDragObservable: Observable<{}>;
  97637. /**
  97638. * Fired when a rotation sphere drag is ended
  97639. */
  97640. onRotationSphereDragEndObservable: Observable<{}>;
  97641. /**
  97642. * 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)
  97643. */
  97644. scalePivot: Nullable<Vector3>;
  97645. private _anchorMesh;
  97646. private _existingMeshScale;
  97647. private _dragMesh;
  97648. private pointerDragBehavior;
  97649. /**
  97650. * Creates an BoundingBoxGizmo
  97651. * @param gizmoLayer The utility layer the gizmo will be added to
  97652. * @param color The color of the gizmo
  97653. */
  97654. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97655. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97656. private _selectNode;
  97657. /**
  97658. * Updates the bounding box information for the Gizmo
  97659. */
  97660. updateBoundingBox(): void;
  97661. private _updateRotationSpheres;
  97662. private _updateScaleBoxes;
  97663. /**
  97664. * Enables rotation on the specified axis and disables rotation on the others
  97665. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97666. */
  97667. setEnabledRotationAxis(axis: string): void;
  97668. /**
  97669. * Enables/disables scaling
  97670. * @param enable if scaling should be enabled
  97671. */
  97672. setEnabledScaling(enable: boolean): void;
  97673. private _updateDummy;
  97674. /**
  97675. * Enables a pointer drag behavior on the bounding box of the gizmo
  97676. */
  97677. enableDragBehavior(): void;
  97678. /**
  97679. * Disposes of the gizmo
  97680. */
  97681. dispose(): void;
  97682. /**
  97683. * 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)
  97684. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97685. * @returns the bounding box mesh with the passed in mesh as a child
  97686. */
  97687. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97688. /**
  97689. * CustomMeshes are not supported by this gizmo
  97690. * @param mesh The mesh to replace the default mesh of the gizmo
  97691. */
  97692. setCustomMesh(mesh: Mesh): void;
  97693. }
  97694. }
  97695. declare module BABYLON {
  97696. /**
  97697. * Single plane rotation gizmo
  97698. */
  97699. export class PlaneRotationGizmo extends Gizmo {
  97700. /**
  97701. * Drag behavior responsible for the gizmos dragging interactions
  97702. */
  97703. dragBehavior: PointerDragBehavior;
  97704. private _pointerObserver;
  97705. /**
  97706. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97707. */
  97708. snapDistance: number;
  97709. /**
  97710. * Event that fires each time the gizmo snaps to a new location.
  97711. * * snapDistance is the the change in distance
  97712. */
  97713. onSnapObservable: Observable<{
  97714. snapDistance: number;
  97715. }>;
  97716. /**
  97717. * Creates a PlaneRotationGizmo
  97718. * @param gizmoLayer The utility layer the gizmo will be added to
  97719. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97720. * @param color The color of the gizmo
  97721. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97722. */
  97723. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97724. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97725. /**
  97726. * Disposes of the gizmo
  97727. */
  97728. dispose(): void;
  97729. }
  97730. }
  97731. declare module BABYLON {
  97732. /**
  97733. * Gizmo that enables rotating a mesh along 3 axis
  97734. */
  97735. export class RotationGizmo extends Gizmo {
  97736. /**
  97737. * Internal gizmo used for interactions on the x axis
  97738. */
  97739. xGizmo: PlaneRotationGizmo;
  97740. /**
  97741. * Internal gizmo used for interactions on the y axis
  97742. */
  97743. yGizmo: PlaneRotationGizmo;
  97744. /**
  97745. * Internal gizmo used for interactions on the z axis
  97746. */
  97747. zGizmo: PlaneRotationGizmo;
  97748. /** Fires an event when any of it's sub gizmos are dragged */
  97749. onDragStartObservable: Observable<{}>;
  97750. /** Fires an event when any of it's sub gizmos are released from dragging */
  97751. onDragEndObservable: Observable<{}>;
  97752. attachedMesh: Nullable<AbstractMesh>;
  97753. /**
  97754. * Creates a RotationGizmo
  97755. * @param gizmoLayer The utility layer the gizmo will be added to
  97756. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97757. */
  97758. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97759. updateGizmoRotationToMatchAttachedMesh: boolean;
  97760. /**
  97761. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97762. */
  97763. snapDistance: number;
  97764. /**
  97765. * Ratio for the scale of the gizmo (Default: 1)
  97766. */
  97767. scaleRatio: number;
  97768. /**
  97769. * Disposes of the gizmo
  97770. */
  97771. dispose(): void;
  97772. /**
  97773. * CustomMeshes are not supported by this gizmo
  97774. * @param mesh The mesh to replace the default mesh of the gizmo
  97775. */
  97776. setCustomMesh(mesh: Mesh): void;
  97777. }
  97778. }
  97779. declare module BABYLON {
  97780. /**
  97781. * Gizmo that enables dragging a mesh along 3 axis
  97782. */
  97783. export class PositionGizmo extends Gizmo {
  97784. /**
  97785. * Internal gizmo used for interactions on the x axis
  97786. */
  97787. xGizmo: AxisDragGizmo;
  97788. /**
  97789. * Internal gizmo used for interactions on the y axis
  97790. */
  97791. yGizmo: AxisDragGizmo;
  97792. /**
  97793. * Internal gizmo used for interactions on the z axis
  97794. */
  97795. zGizmo: AxisDragGizmo;
  97796. /** Fires an event when any of it's sub gizmos are dragged */
  97797. onDragStartObservable: Observable<{}>;
  97798. /** Fires an event when any of it's sub gizmos are released from dragging */
  97799. onDragEndObservable: Observable<{}>;
  97800. attachedMesh: Nullable<AbstractMesh>;
  97801. /**
  97802. * Creates a PositionGizmo
  97803. * @param gizmoLayer The utility layer the gizmo will be added to
  97804. */
  97805. constructor(gizmoLayer?: UtilityLayerRenderer);
  97806. updateGizmoRotationToMatchAttachedMesh: boolean;
  97807. /**
  97808. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97809. */
  97810. snapDistance: number;
  97811. /**
  97812. * Ratio for the scale of the gizmo (Default: 1)
  97813. */
  97814. scaleRatio: number;
  97815. /**
  97816. * Disposes of the gizmo
  97817. */
  97818. dispose(): void;
  97819. /**
  97820. * CustomMeshes are not supported by this gizmo
  97821. * @param mesh The mesh to replace the default mesh of the gizmo
  97822. */
  97823. setCustomMesh(mesh: Mesh): void;
  97824. }
  97825. }
  97826. declare module BABYLON {
  97827. /**
  97828. * Class containing static functions to help procedurally build meshes
  97829. */
  97830. export class PolyhedronBuilder {
  97831. /**
  97832. * Creates a polyhedron mesh
  97833. * * 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
  97834. * * The parameter `size` (positive float, default 1) sets the polygon size
  97835. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97836. * * 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`
  97837. * * 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
  97838. * * 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)`)
  97839. * * 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
  97840. * * 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
  97841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97844. * @param name defines the name of the mesh
  97845. * @param options defines the options used to create the mesh
  97846. * @param scene defines the hosting scene
  97847. * @returns the polyhedron mesh
  97848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  97849. */
  97850. static CreatePolyhedron(name: string, options: {
  97851. type?: number;
  97852. size?: number;
  97853. sizeX?: number;
  97854. sizeY?: number;
  97855. sizeZ?: number;
  97856. custom?: any;
  97857. faceUV?: Vector4[];
  97858. faceColors?: Color4[];
  97859. flat?: boolean;
  97860. updatable?: boolean;
  97861. sideOrientation?: number;
  97862. frontUVs?: Vector4;
  97863. backUVs?: Vector4;
  97864. }, scene: Scene): Mesh;
  97865. }
  97866. }
  97867. declare module BABYLON {
  97868. /**
  97869. * Gizmo that enables scaling a mesh along 3 axis
  97870. */
  97871. export class ScaleGizmo extends Gizmo {
  97872. /**
  97873. * Internal gizmo used for interactions on the x axis
  97874. */
  97875. xGizmo: AxisScaleGizmo;
  97876. /**
  97877. * Internal gizmo used for interactions on the y axis
  97878. */
  97879. yGizmo: AxisScaleGizmo;
  97880. /**
  97881. * Internal gizmo used for interactions on the z axis
  97882. */
  97883. zGizmo: AxisScaleGizmo;
  97884. /**
  97885. * Internal gizmo used to scale all axis equally
  97886. */
  97887. uniformScaleGizmo: AxisScaleGizmo;
  97888. /** Fires an event when any of it's sub gizmos are dragged */
  97889. onDragStartObservable: Observable<{}>;
  97890. /** Fires an event when any of it's sub gizmos are released from dragging */
  97891. onDragEndObservable: Observable<{}>;
  97892. attachedMesh: Nullable<AbstractMesh>;
  97893. /**
  97894. * Creates a ScaleGizmo
  97895. * @param gizmoLayer The utility layer the gizmo will be added to
  97896. */
  97897. constructor(gizmoLayer?: UtilityLayerRenderer);
  97898. updateGizmoRotationToMatchAttachedMesh: boolean;
  97899. /**
  97900. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97901. */
  97902. snapDistance: number;
  97903. /**
  97904. * Ratio for the scale of the gizmo (Default: 1)
  97905. */
  97906. scaleRatio: number;
  97907. /**
  97908. * Disposes of the gizmo
  97909. */
  97910. dispose(): void;
  97911. }
  97912. }
  97913. declare module BABYLON {
  97914. /**
  97915. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  97916. */
  97917. export class GizmoManager implements IDisposable {
  97918. private scene;
  97919. /**
  97920. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  97921. */
  97922. gizmos: {
  97923. positionGizmo: Nullable<PositionGizmo>;
  97924. rotationGizmo: Nullable<RotationGizmo>;
  97925. scaleGizmo: Nullable<ScaleGizmo>;
  97926. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  97927. };
  97928. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  97929. clearGizmoOnEmptyPointerEvent: boolean;
  97930. /** Fires an event when the manager is attached to a mesh */
  97931. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  97932. private _gizmosEnabled;
  97933. private _pointerObserver;
  97934. private _attachedMesh;
  97935. private _boundingBoxColor;
  97936. private _defaultUtilityLayer;
  97937. private _defaultKeepDepthUtilityLayer;
  97938. /**
  97939. * When bounding box gizmo is enabled, this can be used to track drag/end events
  97940. */
  97941. boundingBoxDragBehavior: SixDofDragBehavior;
  97942. /**
  97943. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  97944. */
  97945. attachableMeshes: Nullable<Array<AbstractMesh>>;
  97946. /**
  97947. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  97948. */
  97949. usePointerToAttachGizmos: boolean;
  97950. /**
  97951. * Instatiates a gizmo manager
  97952. * @param scene the scene to overlay the gizmos on top of
  97953. */
  97954. constructor(scene: Scene);
  97955. /**
  97956. * Attaches a set of gizmos to the specified mesh
  97957. * @param mesh The mesh the gizmo's should be attached to
  97958. */
  97959. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  97960. /**
  97961. * If the position gizmo is enabled
  97962. */
  97963. positionGizmoEnabled: boolean;
  97964. /**
  97965. * If the rotation gizmo is enabled
  97966. */
  97967. rotationGizmoEnabled: boolean;
  97968. /**
  97969. * If the scale gizmo is enabled
  97970. */
  97971. scaleGizmoEnabled: boolean;
  97972. /**
  97973. * If the boundingBox gizmo is enabled
  97974. */
  97975. boundingBoxGizmoEnabled: boolean;
  97976. /**
  97977. * Disposes of the gizmo manager
  97978. */
  97979. dispose(): void;
  97980. }
  97981. }
  97982. declare module BABYLON {
  97983. /**
  97984. * Gizmo that enables viewing a light
  97985. */
  97986. export class LightGizmo extends Gizmo {
  97987. private _box;
  97988. /**
  97989. * Creates a LightGizmo
  97990. * @param gizmoLayer The utility layer the gizmo will be added to
  97991. */
  97992. constructor(gizmoLayer?: UtilityLayerRenderer);
  97993. private _light;
  97994. /**
  97995. * The light that the gizmo is attached to
  97996. */
  97997. light: Nullable<Light>;
  97998. /**
  97999. * @hidden
  98000. * Updates the gizmo to match the attached mesh's position/rotation
  98001. */
  98002. protected _update(): void;
  98003. }
  98004. }
  98005. declare module BABYLON {
  98006. /** @hidden */
  98007. export var backgroundFragmentDeclaration: {
  98008. name: string;
  98009. shader: string;
  98010. };
  98011. }
  98012. declare module BABYLON {
  98013. /** @hidden */
  98014. export var backgroundUboDeclaration: {
  98015. name: string;
  98016. shader: string;
  98017. };
  98018. }
  98019. declare module BABYLON {
  98020. /** @hidden */
  98021. export var backgroundPixelShader: {
  98022. name: string;
  98023. shader: string;
  98024. };
  98025. }
  98026. declare module BABYLON {
  98027. /** @hidden */
  98028. export var backgroundVertexDeclaration: {
  98029. name: string;
  98030. shader: string;
  98031. };
  98032. }
  98033. declare module BABYLON {
  98034. /** @hidden */
  98035. export var backgroundVertexShader: {
  98036. name: string;
  98037. shader: string;
  98038. };
  98039. }
  98040. declare module BABYLON {
  98041. /**
  98042. * Background material used to create an efficient environement around your scene.
  98043. */
  98044. export class BackgroundMaterial extends PushMaterial {
  98045. /**
  98046. * Standard reflectance value at parallel view angle.
  98047. */
  98048. static StandardReflectance0: number;
  98049. /**
  98050. * Standard reflectance value at grazing angle.
  98051. */
  98052. static StandardReflectance90: number;
  98053. protected _primaryColor: Color3;
  98054. /**
  98055. * Key light Color (multiply against the environement texture)
  98056. */
  98057. primaryColor: Color3;
  98058. protected __perceptualColor: Nullable<Color3>;
  98059. /**
  98060. * Experimental Internal Use Only.
  98061. *
  98062. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  98063. * This acts as a helper to set the primary color to a more "human friendly" value.
  98064. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  98065. * output color as close as possible from the chosen value.
  98066. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  98067. * part of lighting setup.)
  98068. */
  98069. _perceptualColor: Nullable<Color3>;
  98070. protected _primaryColorShadowLevel: float;
  98071. /**
  98072. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  98073. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  98074. */
  98075. primaryColorShadowLevel: float;
  98076. protected _primaryColorHighlightLevel: float;
  98077. /**
  98078. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  98079. * The primary color is used at the level chosen to define what the white area would look.
  98080. */
  98081. primaryColorHighlightLevel: float;
  98082. protected _reflectionTexture: Nullable<BaseTexture>;
  98083. /**
  98084. * Reflection Texture used in the material.
  98085. * Should be author in a specific way for the best result (refer to the documentation).
  98086. */
  98087. reflectionTexture: Nullable<BaseTexture>;
  98088. protected _reflectionBlur: float;
  98089. /**
  98090. * Reflection Texture level of blur.
  98091. *
  98092. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  98093. * texture twice.
  98094. */
  98095. reflectionBlur: float;
  98096. protected _diffuseTexture: Nullable<BaseTexture>;
  98097. /**
  98098. * Diffuse Texture used in the material.
  98099. * Should be author in a specific way for the best result (refer to the documentation).
  98100. */
  98101. diffuseTexture: Nullable<BaseTexture>;
  98102. protected _shadowLights: Nullable<IShadowLight[]>;
  98103. /**
  98104. * Specify the list of lights casting shadow on the material.
  98105. * All scene shadow lights will be included if null.
  98106. */
  98107. shadowLights: Nullable<IShadowLight[]>;
  98108. protected _shadowLevel: float;
  98109. /**
  98110. * Helps adjusting the shadow to a softer level if required.
  98111. * 0 means black shadows and 1 means no shadows.
  98112. */
  98113. shadowLevel: float;
  98114. protected _sceneCenter: Vector3;
  98115. /**
  98116. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98117. * It is usually zero but might be interesting to modify according to your setup.
  98118. */
  98119. sceneCenter: Vector3;
  98120. protected _opacityFresnel: boolean;
  98121. /**
  98122. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98123. * This helps ensuring a nice transition when the camera goes under the ground.
  98124. */
  98125. opacityFresnel: boolean;
  98126. protected _reflectionFresnel: boolean;
  98127. /**
  98128. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98129. * This helps adding a mirror texture on the ground.
  98130. */
  98131. reflectionFresnel: boolean;
  98132. protected _reflectionFalloffDistance: number;
  98133. /**
  98134. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98135. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98136. */
  98137. reflectionFalloffDistance: number;
  98138. protected _reflectionAmount: number;
  98139. /**
  98140. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98141. */
  98142. reflectionAmount: number;
  98143. protected _reflectionReflectance0: number;
  98144. /**
  98145. * This specifies the weight of the reflection at grazing angle.
  98146. */
  98147. reflectionReflectance0: number;
  98148. protected _reflectionReflectance90: number;
  98149. /**
  98150. * This specifies the weight of the reflection at a perpendicular point of view.
  98151. */
  98152. reflectionReflectance90: number;
  98153. /**
  98154. * Sets the reflection reflectance fresnel values according to the default standard
  98155. * empirically know to work well :-)
  98156. */
  98157. reflectionStandardFresnelWeight: number;
  98158. protected _useRGBColor: boolean;
  98159. /**
  98160. * Helps to directly use the maps channels instead of their level.
  98161. */
  98162. useRGBColor: boolean;
  98163. protected _enableNoise: boolean;
  98164. /**
  98165. * This helps reducing the banding effect that could occur on the background.
  98166. */
  98167. enableNoise: boolean;
  98168. /**
  98169. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98170. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98171. * Recommended to be keep at 1.0 except for special cases.
  98172. */
  98173. fovMultiplier: number;
  98174. private _fovMultiplier;
  98175. /**
  98176. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98177. */
  98178. useEquirectangularFOV: boolean;
  98179. private _maxSimultaneousLights;
  98180. /**
  98181. * Number of Simultaneous lights allowed on the material.
  98182. */
  98183. maxSimultaneousLights: int;
  98184. /**
  98185. * Default configuration related to image processing available in the Background Material.
  98186. */
  98187. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98188. /**
  98189. * Keep track of the image processing observer to allow dispose and replace.
  98190. */
  98191. private _imageProcessingObserver;
  98192. /**
  98193. * Attaches a new image processing configuration to the PBR Material.
  98194. * @param configuration (if null the scene configuration will be use)
  98195. */
  98196. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98197. /**
  98198. * Gets the image processing configuration used either in this material.
  98199. */
  98200. /**
  98201. * Sets the Default image processing configuration used either in the this material.
  98202. *
  98203. * If sets to null, the scene one is in use.
  98204. */
  98205. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98206. /**
  98207. * Gets wether the color curves effect is enabled.
  98208. */
  98209. /**
  98210. * Sets wether the color curves effect is enabled.
  98211. */
  98212. cameraColorCurvesEnabled: boolean;
  98213. /**
  98214. * Gets wether the color grading effect is enabled.
  98215. */
  98216. /**
  98217. * Gets wether the color grading effect is enabled.
  98218. */
  98219. cameraColorGradingEnabled: boolean;
  98220. /**
  98221. * Gets wether tonemapping is enabled or not.
  98222. */
  98223. /**
  98224. * Sets wether tonemapping is enabled or not
  98225. */
  98226. cameraToneMappingEnabled: boolean;
  98227. /**
  98228. * The camera exposure used on this material.
  98229. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98230. * This corresponds to a photographic exposure.
  98231. */
  98232. /**
  98233. * The camera exposure used on this material.
  98234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98235. * This corresponds to a photographic exposure.
  98236. */
  98237. cameraExposure: float;
  98238. /**
  98239. * Gets The camera contrast used on this material.
  98240. */
  98241. /**
  98242. * Sets The camera contrast used on this material.
  98243. */
  98244. cameraContrast: float;
  98245. /**
  98246. * Gets the Color Grading 2D Lookup Texture.
  98247. */
  98248. /**
  98249. * Sets the Color Grading 2D Lookup Texture.
  98250. */
  98251. cameraColorGradingTexture: Nullable<BaseTexture>;
  98252. /**
  98253. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98254. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98255. * 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;
  98256. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98257. */
  98258. /**
  98259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98261. * 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;
  98262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98263. */
  98264. cameraColorCurves: Nullable<ColorCurves>;
  98265. /**
  98266. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98267. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98268. */
  98269. switchToBGR: boolean;
  98270. private _renderTargets;
  98271. private _reflectionControls;
  98272. private _white;
  98273. private _primaryShadowColor;
  98274. private _primaryHighlightColor;
  98275. /**
  98276. * Instantiates a Background Material in the given scene
  98277. * @param name The friendly name of the material
  98278. * @param scene The scene to add the material to
  98279. */
  98280. constructor(name: string, scene: Scene);
  98281. /**
  98282. * Gets a boolean indicating that current material needs to register RTT
  98283. */
  98284. readonly hasRenderTargetTextures: boolean;
  98285. /**
  98286. * The entire material has been created in order to prevent overdraw.
  98287. * @returns false
  98288. */
  98289. needAlphaTesting(): boolean;
  98290. /**
  98291. * The entire material has been created in order to prevent overdraw.
  98292. * @returns true if blending is enable
  98293. */
  98294. needAlphaBlending(): boolean;
  98295. /**
  98296. * Checks wether the material is ready to be rendered for a given mesh.
  98297. * @param mesh The mesh to render
  98298. * @param subMesh The submesh to check against
  98299. * @param useInstances Specify wether or not the material is used with instances
  98300. * @returns true if all the dependencies are ready (Textures, Effects...)
  98301. */
  98302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98303. /**
  98304. * Compute the primary color according to the chosen perceptual color.
  98305. */
  98306. private _computePrimaryColorFromPerceptualColor;
  98307. /**
  98308. * Compute the highlights and shadow colors according to their chosen levels.
  98309. */
  98310. private _computePrimaryColors;
  98311. /**
  98312. * Build the uniform buffer used in the material.
  98313. */
  98314. buildUniformLayout(): void;
  98315. /**
  98316. * Unbind the material.
  98317. */
  98318. unbind(): void;
  98319. /**
  98320. * Bind only the world matrix to the material.
  98321. * @param world The world matrix to bind.
  98322. */
  98323. bindOnlyWorldMatrix(world: Matrix): void;
  98324. /**
  98325. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98326. * @param world The world matrix to bind.
  98327. * @param subMesh The submesh to bind for.
  98328. */
  98329. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98330. /**
  98331. * Dispose the material.
  98332. * @param forceDisposeEffect Force disposal of the associated effect.
  98333. * @param forceDisposeTextures Force disposal of the associated textures.
  98334. */
  98335. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98336. /**
  98337. * Clones the material.
  98338. * @param name The cloned name.
  98339. * @returns The cloned material.
  98340. */
  98341. clone(name: string): BackgroundMaterial;
  98342. /**
  98343. * Serializes the current material to its JSON representation.
  98344. * @returns The JSON representation.
  98345. */
  98346. serialize(): any;
  98347. /**
  98348. * Gets the class name of the material
  98349. * @returns "BackgroundMaterial"
  98350. */
  98351. getClassName(): string;
  98352. /**
  98353. * Parse a JSON input to create back a background material.
  98354. * @param source The JSON data to parse
  98355. * @param scene The scene to create the parsed material in
  98356. * @param rootUrl The root url of the assets the material depends upon
  98357. * @returns the instantiated BackgroundMaterial.
  98358. */
  98359. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98360. }
  98361. }
  98362. declare module BABYLON {
  98363. /**
  98364. * Represents the different options available during the creation of
  98365. * a Environment helper.
  98366. *
  98367. * This can control the default ground, skybox and image processing setup of your scene.
  98368. */
  98369. export interface IEnvironmentHelperOptions {
  98370. /**
  98371. * Specifies wether or not to create a ground.
  98372. * True by default.
  98373. */
  98374. createGround: boolean;
  98375. /**
  98376. * Specifies the ground size.
  98377. * 15 by default.
  98378. */
  98379. groundSize: number;
  98380. /**
  98381. * The texture used on the ground for the main color.
  98382. * Comes from the BabylonJS CDN by default.
  98383. *
  98384. * Remarks: Can be either a texture or a url.
  98385. */
  98386. groundTexture: string | BaseTexture;
  98387. /**
  98388. * The color mixed in the ground texture by default.
  98389. * BabylonJS clearColor by default.
  98390. */
  98391. groundColor: Color3;
  98392. /**
  98393. * Specifies the ground opacity.
  98394. * 1 by default.
  98395. */
  98396. groundOpacity: number;
  98397. /**
  98398. * Enables the ground to receive shadows.
  98399. * True by default.
  98400. */
  98401. enableGroundShadow: boolean;
  98402. /**
  98403. * Helps preventing the shadow to be fully black on the ground.
  98404. * 0.5 by default.
  98405. */
  98406. groundShadowLevel: number;
  98407. /**
  98408. * Creates a mirror texture attach to the ground.
  98409. * false by default.
  98410. */
  98411. enableGroundMirror: boolean;
  98412. /**
  98413. * Specifies the ground mirror size ratio.
  98414. * 0.3 by default as the default kernel is 64.
  98415. */
  98416. groundMirrorSizeRatio: number;
  98417. /**
  98418. * Specifies the ground mirror blur kernel size.
  98419. * 64 by default.
  98420. */
  98421. groundMirrorBlurKernel: number;
  98422. /**
  98423. * Specifies the ground mirror visibility amount.
  98424. * 1 by default
  98425. */
  98426. groundMirrorAmount: number;
  98427. /**
  98428. * Specifies the ground mirror reflectance weight.
  98429. * This uses the standard weight of the background material to setup the fresnel effect
  98430. * of the mirror.
  98431. * 1 by default.
  98432. */
  98433. groundMirrorFresnelWeight: number;
  98434. /**
  98435. * Specifies the ground mirror Falloff distance.
  98436. * This can helps reducing the size of the reflection.
  98437. * 0 by Default.
  98438. */
  98439. groundMirrorFallOffDistance: number;
  98440. /**
  98441. * Specifies the ground mirror texture type.
  98442. * Unsigned Int by Default.
  98443. */
  98444. groundMirrorTextureType: number;
  98445. /**
  98446. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98447. * the shown objects.
  98448. */
  98449. groundYBias: number;
  98450. /**
  98451. * Specifies wether or not to create a skybox.
  98452. * True by default.
  98453. */
  98454. createSkybox: boolean;
  98455. /**
  98456. * Specifies the skybox size.
  98457. * 20 by default.
  98458. */
  98459. skyboxSize: number;
  98460. /**
  98461. * The texture used on the skybox for the main color.
  98462. * Comes from the BabylonJS CDN by default.
  98463. *
  98464. * Remarks: Can be either a texture or a url.
  98465. */
  98466. skyboxTexture: string | BaseTexture;
  98467. /**
  98468. * The color mixed in the skybox texture by default.
  98469. * BabylonJS clearColor by default.
  98470. */
  98471. skyboxColor: Color3;
  98472. /**
  98473. * The background rotation around the Y axis of the scene.
  98474. * This helps aligning the key lights of your scene with the background.
  98475. * 0 by default.
  98476. */
  98477. backgroundYRotation: number;
  98478. /**
  98479. * Compute automatically the size of the elements to best fit with the scene.
  98480. */
  98481. sizeAuto: boolean;
  98482. /**
  98483. * Default position of the rootMesh if autoSize is not true.
  98484. */
  98485. rootPosition: Vector3;
  98486. /**
  98487. * Sets up the image processing in the scene.
  98488. * true by default.
  98489. */
  98490. setupImageProcessing: boolean;
  98491. /**
  98492. * The texture used as your environment texture in the scene.
  98493. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98494. *
  98495. * Remarks: Can be either a texture or a url.
  98496. */
  98497. environmentTexture: string | BaseTexture;
  98498. /**
  98499. * The value of the exposure to apply to the scene.
  98500. * 0.6 by default if setupImageProcessing is true.
  98501. */
  98502. cameraExposure: number;
  98503. /**
  98504. * The value of the contrast to apply to the scene.
  98505. * 1.6 by default if setupImageProcessing is true.
  98506. */
  98507. cameraContrast: number;
  98508. /**
  98509. * Specifies wether or not tonemapping should be enabled in the scene.
  98510. * true by default if setupImageProcessing is true.
  98511. */
  98512. toneMappingEnabled: boolean;
  98513. }
  98514. /**
  98515. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98516. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98517. * It also helps with the default setup of your imageProcessing configuration.
  98518. */
  98519. export class EnvironmentHelper {
  98520. /**
  98521. * Default ground texture URL.
  98522. */
  98523. private static _groundTextureCDNUrl;
  98524. /**
  98525. * Default skybox texture URL.
  98526. */
  98527. private static _skyboxTextureCDNUrl;
  98528. /**
  98529. * Default environment texture URL.
  98530. */
  98531. private static _environmentTextureCDNUrl;
  98532. /**
  98533. * Creates the default options for the helper.
  98534. */
  98535. private static _getDefaultOptions;
  98536. private _rootMesh;
  98537. /**
  98538. * Gets the root mesh created by the helper.
  98539. */
  98540. readonly rootMesh: Mesh;
  98541. private _skybox;
  98542. /**
  98543. * Gets the skybox created by the helper.
  98544. */
  98545. readonly skybox: Nullable<Mesh>;
  98546. private _skyboxTexture;
  98547. /**
  98548. * Gets the skybox texture created by the helper.
  98549. */
  98550. readonly skyboxTexture: Nullable<BaseTexture>;
  98551. private _skyboxMaterial;
  98552. /**
  98553. * Gets the skybox material created by the helper.
  98554. */
  98555. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98556. private _ground;
  98557. /**
  98558. * Gets the ground mesh created by the helper.
  98559. */
  98560. readonly ground: Nullable<Mesh>;
  98561. private _groundTexture;
  98562. /**
  98563. * Gets the ground texture created by the helper.
  98564. */
  98565. readonly groundTexture: Nullable<BaseTexture>;
  98566. private _groundMirror;
  98567. /**
  98568. * Gets the ground mirror created by the helper.
  98569. */
  98570. readonly groundMirror: Nullable<MirrorTexture>;
  98571. /**
  98572. * Gets the ground mirror render list to helps pushing the meshes
  98573. * you wish in the ground reflection.
  98574. */
  98575. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98576. private _groundMaterial;
  98577. /**
  98578. * Gets the ground material created by the helper.
  98579. */
  98580. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98581. /**
  98582. * Stores the creation options.
  98583. */
  98584. private readonly _scene;
  98585. private _options;
  98586. /**
  98587. * This observable will be notified with any error during the creation of the environment,
  98588. * mainly texture creation errors.
  98589. */
  98590. onErrorObservable: Observable<{
  98591. message?: string;
  98592. exception?: any;
  98593. }>;
  98594. /**
  98595. * constructor
  98596. * @param options Defines the options we want to customize the helper
  98597. * @param scene The scene to add the material to
  98598. */
  98599. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98600. /**
  98601. * Updates the background according to the new options
  98602. * @param options
  98603. */
  98604. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98605. /**
  98606. * Sets the primary color of all the available elements.
  98607. * @param color the main color to affect to the ground and the background
  98608. */
  98609. setMainColor(color: Color3): void;
  98610. /**
  98611. * Setup the image processing according to the specified options.
  98612. */
  98613. private _setupImageProcessing;
  98614. /**
  98615. * Setup the environment texture according to the specified options.
  98616. */
  98617. private _setupEnvironmentTexture;
  98618. /**
  98619. * Setup the background according to the specified options.
  98620. */
  98621. private _setupBackground;
  98622. /**
  98623. * Get the scene sizes according to the setup.
  98624. */
  98625. private _getSceneSize;
  98626. /**
  98627. * Setup the ground according to the specified options.
  98628. */
  98629. private _setupGround;
  98630. /**
  98631. * Setup the ground material according to the specified options.
  98632. */
  98633. private _setupGroundMaterial;
  98634. /**
  98635. * Setup the ground diffuse texture according to the specified options.
  98636. */
  98637. private _setupGroundDiffuseTexture;
  98638. /**
  98639. * Setup the ground mirror texture according to the specified options.
  98640. */
  98641. private _setupGroundMirrorTexture;
  98642. /**
  98643. * Setup the ground to receive the mirror texture.
  98644. */
  98645. private _setupMirrorInGroundMaterial;
  98646. /**
  98647. * Setup the skybox according to the specified options.
  98648. */
  98649. private _setupSkybox;
  98650. /**
  98651. * Setup the skybox material according to the specified options.
  98652. */
  98653. private _setupSkyboxMaterial;
  98654. /**
  98655. * Setup the skybox reflection texture according to the specified options.
  98656. */
  98657. private _setupSkyboxReflectionTexture;
  98658. private _errorHandler;
  98659. /**
  98660. * Dispose all the elements created by the Helper.
  98661. */
  98662. dispose(): void;
  98663. }
  98664. }
  98665. declare module BABYLON {
  98666. /**
  98667. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98668. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98669. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98670. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98671. */
  98672. export class PhotoDome extends TransformNode {
  98673. private _useDirectMapping;
  98674. /**
  98675. * The texture being displayed on the sphere
  98676. */
  98677. protected _photoTexture: Texture;
  98678. /**
  98679. * Gets or sets the texture being displayed on the sphere
  98680. */
  98681. photoTexture: Texture;
  98682. /**
  98683. * Observable raised when an error occured while loading the 360 image
  98684. */
  98685. onLoadErrorObservable: Observable<string>;
  98686. /**
  98687. * The skybox material
  98688. */
  98689. protected _material: BackgroundMaterial;
  98690. /**
  98691. * The surface used for the skybox
  98692. */
  98693. protected _mesh: Mesh;
  98694. /**
  98695. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98696. * Also see the options.resolution property.
  98697. */
  98698. fovMultiplier: number;
  98699. /**
  98700. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98701. * @param name Element's name, child elements will append suffixes for their own names.
  98702. * @param urlsOfPhoto defines the url of the photo to display
  98703. * @param options defines an object containing optional or exposed sub element properties
  98704. * @param onError defines a callback called when an error occured while loading the texture
  98705. */
  98706. constructor(name: string, urlOfPhoto: string, options: {
  98707. resolution?: number;
  98708. size?: number;
  98709. useDirectMapping?: boolean;
  98710. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98711. /**
  98712. * Releases resources associated with this node.
  98713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98715. */
  98716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98717. }
  98718. }
  98719. declare module BABYLON {
  98720. /**
  98721. * Class used to host texture specific utilities
  98722. */
  98723. export class TextureTools {
  98724. /**
  98725. * Uses the GPU to create a copy texture rescaled at a given size
  98726. * @param texture Texture to copy from
  98727. * @param width defines the desired width
  98728. * @param height defines the desired height
  98729. * @param useBilinearMode defines if bilinear mode has to be used
  98730. * @return the generated texture
  98731. */
  98732. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98733. /**
  98734. * Gets an environment BRDF texture for a given scene
  98735. * @param scene defines the hosting scene
  98736. * @returns the environment BRDF texture
  98737. */
  98738. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98739. private static _environmentBRDFBase64Texture;
  98740. }
  98741. }
  98742. declare module BABYLON {
  98743. /** @hidden */
  98744. export var pbrFragmentDeclaration: {
  98745. name: string;
  98746. shader: string;
  98747. };
  98748. }
  98749. declare module BABYLON {
  98750. /** @hidden */
  98751. export var pbrUboDeclaration: {
  98752. name: string;
  98753. shader: string;
  98754. };
  98755. }
  98756. declare module BABYLON {
  98757. /** @hidden */
  98758. export var pbrFunctions: {
  98759. name: string;
  98760. shader: string;
  98761. };
  98762. }
  98763. declare module BABYLON {
  98764. /** @hidden */
  98765. export var harmonicsFunctions: {
  98766. name: string;
  98767. shader: string;
  98768. };
  98769. }
  98770. declare module BABYLON {
  98771. /** @hidden */
  98772. export var pbrLightFunctions: {
  98773. name: string;
  98774. shader: string;
  98775. };
  98776. }
  98777. declare module BABYLON {
  98778. /** @hidden */
  98779. export var pbrPixelShader: {
  98780. name: string;
  98781. shader: string;
  98782. };
  98783. }
  98784. declare module BABYLON {
  98785. /** @hidden */
  98786. export var pbrVertexDeclaration: {
  98787. name: string;
  98788. shader: string;
  98789. };
  98790. }
  98791. declare module BABYLON {
  98792. /** @hidden */
  98793. export var pbrVertexShader: {
  98794. name: string;
  98795. shader: string;
  98796. };
  98797. }
  98798. declare module BABYLON {
  98799. /**
  98800. * The Physically based material base class of BJS.
  98801. *
  98802. * This offers the main features of a standard PBR material.
  98803. * For more information, please refer to the documentation :
  98804. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98805. */
  98806. export abstract class PBRBaseMaterial extends PushMaterial {
  98807. /**
  98808. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98809. */
  98810. static readonly PBRMATERIAL_OPAQUE: number;
  98811. /**
  98812. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98813. */
  98814. static readonly PBRMATERIAL_ALPHATEST: number;
  98815. /**
  98816. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98817. */
  98818. static readonly PBRMATERIAL_ALPHABLEND: number;
  98819. /**
  98820. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98821. * They are also discarded below the alpha cutoff threshold to improve performances.
  98822. */
  98823. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98824. /**
  98825. * Defines the default value of how much AO map is occluding the analytical lights
  98826. * (point spot...).
  98827. */
  98828. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98829. /**
  98830. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98831. */
  98832. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98833. /**
  98834. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98835. * to enhance interoperability with other engines.
  98836. */
  98837. static readonly LIGHTFALLOFF_GLTF: number;
  98838. /**
  98839. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98840. * to enhance interoperability with other materials.
  98841. */
  98842. static readonly LIGHTFALLOFF_STANDARD: number;
  98843. /**
  98844. * Intensity of the direct lights e.g. the four lights available in your scene.
  98845. * This impacts both the direct diffuse and specular highlights.
  98846. */
  98847. protected _directIntensity: number;
  98848. /**
  98849. * Intensity of the emissive part of the material.
  98850. * This helps controlling the emissive effect without modifying the emissive color.
  98851. */
  98852. protected _emissiveIntensity: number;
  98853. /**
  98854. * Intensity of the environment e.g. how much the environment will light the object
  98855. * either through harmonics for rough material or through the refelction for shiny ones.
  98856. */
  98857. protected _environmentIntensity: number;
  98858. /**
  98859. * This is a special control allowing the reduction of the specular highlights coming from the
  98860. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98861. */
  98862. protected _specularIntensity: number;
  98863. /**
  98864. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98865. */
  98866. private _lightingInfos;
  98867. /**
  98868. * Debug Control allowing disabling the bump map on this material.
  98869. */
  98870. protected _disableBumpMap: boolean;
  98871. /**
  98872. * AKA Diffuse Texture in standard nomenclature.
  98873. */
  98874. protected _albedoTexture: BaseTexture;
  98875. /**
  98876. * AKA Occlusion Texture in other nomenclature.
  98877. */
  98878. protected _ambientTexture: BaseTexture;
  98879. /**
  98880. * AKA Occlusion Texture Intensity in other nomenclature.
  98881. */
  98882. protected _ambientTextureStrength: number;
  98883. /**
  98884. * Defines how much the AO map is occluding the analytical lights (point spot...).
  98885. * 1 means it completely occludes it
  98886. * 0 mean it has no impact
  98887. */
  98888. protected _ambientTextureImpactOnAnalyticalLights: number;
  98889. /**
  98890. * Stores the alpha values in a texture.
  98891. */
  98892. protected _opacityTexture: BaseTexture;
  98893. /**
  98894. * Stores the reflection values in a texture.
  98895. */
  98896. protected _reflectionTexture: BaseTexture;
  98897. /**
  98898. * Stores the refraction values in a texture.
  98899. */
  98900. protected _refractionTexture: BaseTexture;
  98901. /**
  98902. * Stores the emissive values in a texture.
  98903. */
  98904. protected _emissiveTexture: BaseTexture;
  98905. /**
  98906. * AKA Specular texture in other nomenclature.
  98907. */
  98908. protected _reflectivityTexture: BaseTexture;
  98909. /**
  98910. * Used to switch from specular/glossiness to metallic/roughness workflow.
  98911. */
  98912. protected _metallicTexture: BaseTexture;
  98913. /**
  98914. * Specifies the metallic scalar of the metallic/roughness workflow.
  98915. * Can also be used to scale the metalness values of the metallic texture.
  98916. */
  98917. protected _metallic: Nullable<number>;
  98918. /**
  98919. * Specifies the roughness scalar of the metallic/roughness workflow.
  98920. * Can also be used to scale the roughness values of the metallic texture.
  98921. */
  98922. protected _roughness: Nullable<number>;
  98923. /**
  98924. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  98925. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  98926. */
  98927. protected _microSurfaceTexture: BaseTexture;
  98928. /**
  98929. * Stores surface normal data used to displace a mesh in a texture.
  98930. */
  98931. protected _bumpTexture: BaseTexture;
  98932. /**
  98933. * Stores the pre-calculated light information of a mesh in a texture.
  98934. */
  98935. protected _lightmapTexture: BaseTexture;
  98936. /**
  98937. * The color of a material in ambient lighting.
  98938. */
  98939. protected _ambientColor: Color3;
  98940. /**
  98941. * AKA Diffuse Color in other nomenclature.
  98942. */
  98943. protected _albedoColor: Color3;
  98944. /**
  98945. * AKA Specular Color in other nomenclature.
  98946. */
  98947. protected _reflectivityColor: Color3;
  98948. /**
  98949. * The color applied when light is reflected from a material.
  98950. */
  98951. protected _reflectionColor: Color3;
  98952. /**
  98953. * The color applied when light is emitted from a material.
  98954. */
  98955. protected _emissiveColor: Color3;
  98956. /**
  98957. * AKA Glossiness in other nomenclature.
  98958. */
  98959. protected _microSurface: number;
  98960. /**
  98961. * source material index of refraction (IOR)' / 'destination material IOR.
  98962. */
  98963. protected _indexOfRefraction: number;
  98964. /**
  98965. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98966. */
  98967. protected _invertRefractionY: boolean;
  98968. /**
  98969. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98970. * Materials half opaque for instance using refraction could benefit from this control.
  98971. */
  98972. protected _linkRefractionWithTransparency: boolean;
  98973. /**
  98974. * Specifies that the material will use the light map as a show map.
  98975. */
  98976. protected _useLightmapAsShadowmap: boolean;
  98977. /**
  98978. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  98979. * makes the reflect vector face the model (under horizon).
  98980. */
  98981. protected _useHorizonOcclusion: boolean;
  98982. /**
  98983. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  98984. * too much the area relying on ambient texture to define their ambient occlusion.
  98985. */
  98986. protected _useRadianceOcclusion: boolean;
  98987. /**
  98988. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  98989. */
  98990. protected _useAlphaFromAlbedoTexture: boolean;
  98991. /**
  98992. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  98993. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98994. */
  98995. protected _useSpecularOverAlpha: boolean;
  98996. /**
  98997. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  98998. */
  98999. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99000. /**
  99001. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99002. */
  99003. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  99004. /**
  99005. * Specifies if the metallic texture contains the roughness information in its green channel.
  99006. */
  99007. protected _useRoughnessFromMetallicTextureGreen: boolean;
  99008. /**
  99009. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99010. */
  99011. protected _useMetallnessFromMetallicTextureBlue: boolean;
  99012. /**
  99013. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99014. */
  99015. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  99016. /**
  99017. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99018. */
  99019. protected _useAmbientInGrayScale: boolean;
  99020. /**
  99021. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99022. * The material will try to infer what glossiness each pixel should be.
  99023. */
  99024. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  99025. /**
  99026. * Defines the falloff type used in this material.
  99027. * It by default is Physical.
  99028. */
  99029. protected _lightFalloff: number;
  99030. /**
  99031. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99032. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99033. */
  99034. protected _useRadianceOverAlpha: boolean;
  99035. /**
  99036. * Allows using an object space normal map (instead of tangent space).
  99037. */
  99038. protected _useObjectSpaceNormalMap: boolean;
  99039. /**
  99040. * Allows using the bump map in parallax mode.
  99041. */
  99042. protected _useParallax: boolean;
  99043. /**
  99044. * Allows using the bump map in parallax occlusion mode.
  99045. */
  99046. protected _useParallaxOcclusion: boolean;
  99047. /**
  99048. * Controls the scale bias of the parallax mode.
  99049. */
  99050. protected _parallaxScaleBias: number;
  99051. /**
  99052. * If sets to true, disables all the lights affecting the material.
  99053. */
  99054. protected _disableLighting: boolean;
  99055. /**
  99056. * Number of Simultaneous lights allowed on the material.
  99057. */
  99058. protected _maxSimultaneousLights: number;
  99059. /**
  99060. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99061. */
  99062. protected _invertNormalMapX: boolean;
  99063. /**
  99064. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99065. */
  99066. protected _invertNormalMapY: boolean;
  99067. /**
  99068. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99069. */
  99070. protected _twoSidedLighting: boolean;
  99071. /**
  99072. * Defines the alpha limits in alpha test mode.
  99073. */
  99074. protected _alphaCutOff: number;
  99075. /**
  99076. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99077. */
  99078. protected _forceAlphaTest: boolean;
  99079. /**
  99080. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99081. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99082. */
  99083. protected _useAlphaFresnel: boolean;
  99084. /**
  99085. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99086. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99087. */
  99088. protected _useLinearAlphaFresnel: boolean;
  99089. /**
  99090. * The transparency mode of the material.
  99091. */
  99092. protected _transparencyMode: Nullable<number>;
  99093. /**
  99094. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  99095. * from cos thetav and roughness:
  99096. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  99097. */
  99098. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  99099. /**
  99100. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99101. */
  99102. protected _forceIrradianceInFragment: boolean;
  99103. /**
  99104. * Force normal to face away from face.
  99105. */
  99106. protected _forceNormalForward: boolean;
  99107. /**
  99108. * Enables specular anti aliasing in the PBR shader.
  99109. * It will both interacts on the Geometry for analytical and IBL lighting.
  99110. * It also prefilter the roughness map based on the bump values.
  99111. */
  99112. protected _enableSpecularAntiAliasing: boolean;
  99113. /**
  99114. * Default configuration related to image processing available in the PBR Material.
  99115. */
  99116. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99117. /**
  99118. * Keep track of the image processing observer to allow dispose and replace.
  99119. */
  99120. private _imageProcessingObserver;
  99121. /**
  99122. * Attaches a new image processing configuration to the PBR Material.
  99123. * @param configuration
  99124. */
  99125. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99126. /**
  99127. * Stores the available render targets.
  99128. */
  99129. private _renderTargets;
  99130. /**
  99131. * Sets the global ambient color for the material used in lighting calculations.
  99132. */
  99133. private _globalAmbientColor;
  99134. /**
  99135. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99136. */
  99137. private _useLogarithmicDepth;
  99138. /**
  99139. * If set to true, no lighting calculations will be applied.
  99140. */
  99141. private _unlit;
  99142. /**
  99143. * Instantiates a new PBRMaterial instance.
  99144. *
  99145. * @param name The material name
  99146. * @param scene The scene the material will be use in.
  99147. */
  99148. constructor(name: string, scene: Scene);
  99149. /**
  99150. * Gets a boolean indicating that current material needs to register RTT
  99151. */
  99152. readonly hasRenderTargetTextures: boolean;
  99153. /**
  99154. * Gets the name of the material class.
  99155. */
  99156. getClassName(): string;
  99157. /**
  99158. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99159. */
  99160. /**
  99161. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99162. */
  99163. useLogarithmicDepth: boolean;
  99164. /**
  99165. * Gets the current transparency mode.
  99166. */
  99167. /**
  99168. * Sets the transparency mode of the material.
  99169. *
  99170. * | Value | Type | Description |
  99171. * | ----- | ----------------------------------- | ----------- |
  99172. * | 0 | OPAQUE | |
  99173. * | 1 | ALPHATEST | |
  99174. * | 2 | ALPHABLEND | |
  99175. * | 3 | ALPHATESTANDBLEND | |
  99176. *
  99177. */
  99178. transparencyMode: Nullable<number>;
  99179. /**
  99180. * Returns true if alpha blending should be disabled.
  99181. */
  99182. private readonly _disableAlphaBlending;
  99183. /**
  99184. * Specifies whether or not this material should be rendered in alpha blend mode.
  99185. */
  99186. needAlphaBlending(): boolean;
  99187. /**
  99188. * Specifies if the mesh will require alpha blending.
  99189. * @param mesh - BJS mesh.
  99190. */
  99191. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99192. /**
  99193. * Specifies whether or not this material should be rendered in alpha test mode.
  99194. */
  99195. needAlphaTesting(): boolean;
  99196. /**
  99197. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99198. */
  99199. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99200. /**
  99201. * Gets the texture used for the alpha test.
  99202. */
  99203. getAlphaTestTexture(): BaseTexture;
  99204. /**
  99205. * Specifies that the submesh is ready to be used.
  99206. * @param mesh - BJS mesh.
  99207. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99208. * @param useInstances - Specifies that instances should be used.
  99209. * @returns - boolean indicating that the submesh is ready or not.
  99210. */
  99211. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99212. /**
  99213. * Specifies if the material uses metallic roughness workflow.
  99214. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99215. */
  99216. isMetallicWorkflow(): boolean;
  99217. private _prepareEffect;
  99218. private _prepareDefines;
  99219. /**
  99220. * Force shader compilation
  99221. */
  99222. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99223. clipPlane: boolean;
  99224. }>): void;
  99225. /**
  99226. * Initializes the uniform buffer layout for the shader.
  99227. */
  99228. buildUniformLayout(): void;
  99229. /**
  99230. * Unbinds the textures.
  99231. */
  99232. unbind(): void;
  99233. /**
  99234. * Binds the submesh data.
  99235. * @param world - The world matrix.
  99236. * @param mesh - The BJS mesh.
  99237. * @param subMesh - A submesh of the BJS mesh.
  99238. */
  99239. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99240. /**
  99241. * Returns the animatable textures.
  99242. * @returns - Array of animatable textures.
  99243. */
  99244. getAnimatables(): IAnimatable[];
  99245. /**
  99246. * Returns the texture used for reflections.
  99247. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99248. */
  99249. private _getReflectionTexture;
  99250. /**
  99251. * Returns the texture used for refraction or null if none is used.
  99252. * @returns - Refection texture if present. If no refraction texture and refraction
  99253. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99254. */
  99255. private _getRefractionTexture;
  99256. /**
  99257. * Disposes the resources of the material.
  99258. * @param forceDisposeEffect - Forces the disposal of effects.
  99259. * @param forceDisposeTextures - Forces the disposal of all textures.
  99260. */
  99261. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99262. }
  99263. }
  99264. declare module BABYLON {
  99265. /**
  99266. * The Physically based material of BJS.
  99267. *
  99268. * This offers the main features of a standard PBR material.
  99269. * For more information, please refer to the documentation :
  99270. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99271. */
  99272. export class PBRMaterial extends PBRBaseMaterial {
  99273. /**
  99274. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99275. */
  99276. static readonly PBRMATERIAL_OPAQUE: number;
  99277. /**
  99278. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99279. */
  99280. static readonly PBRMATERIAL_ALPHATEST: number;
  99281. /**
  99282. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99283. */
  99284. static readonly PBRMATERIAL_ALPHABLEND: number;
  99285. /**
  99286. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99287. * They are also discarded below the alpha cutoff threshold to improve performances.
  99288. */
  99289. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99290. /**
  99291. * Defines the default value of how much AO map is occluding the analytical lights
  99292. * (point spot...).
  99293. */
  99294. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99295. /**
  99296. * Intensity of the direct lights e.g. the four lights available in your scene.
  99297. * This impacts both the direct diffuse and specular highlights.
  99298. */
  99299. directIntensity: number;
  99300. /**
  99301. * Intensity of the emissive part of the material.
  99302. * This helps controlling the emissive effect without modifying the emissive color.
  99303. */
  99304. emissiveIntensity: number;
  99305. /**
  99306. * Intensity of the environment e.g. how much the environment will light the object
  99307. * either through harmonics for rough material or through the refelction for shiny ones.
  99308. */
  99309. environmentIntensity: number;
  99310. /**
  99311. * This is a special control allowing the reduction of the specular highlights coming from the
  99312. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99313. */
  99314. specularIntensity: number;
  99315. /**
  99316. * Debug Control allowing disabling the bump map on this material.
  99317. */
  99318. disableBumpMap: boolean;
  99319. /**
  99320. * AKA Diffuse Texture in standard nomenclature.
  99321. */
  99322. albedoTexture: BaseTexture;
  99323. /**
  99324. * AKA Occlusion Texture in other nomenclature.
  99325. */
  99326. ambientTexture: BaseTexture;
  99327. /**
  99328. * AKA Occlusion Texture Intensity in other nomenclature.
  99329. */
  99330. ambientTextureStrength: number;
  99331. /**
  99332. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99333. * 1 means it completely occludes it
  99334. * 0 mean it has no impact
  99335. */
  99336. ambientTextureImpactOnAnalyticalLights: number;
  99337. /**
  99338. * Stores the alpha values in a texture.
  99339. */
  99340. opacityTexture: BaseTexture;
  99341. /**
  99342. * Stores the reflection values in a texture.
  99343. */
  99344. reflectionTexture: Nullable<BaseTexture>;
  99345. /**
  99346. * Stores the emissive values in a texture.
  99347. */
  99348. emissiveTexture: BaseTexture;
  99349. /**
  99350. * AKA Specular texture in other nomenclature.
  99351. */
  99352. reflectivityTexture: BaseTexture;
  99353. /**
  99354. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99355. */
  99356. metallicTexture: BaseTexture;
  99357. /**
  99358. * Specifies the metallic scalar of the metallic/roughness workflow.
  99359. * Can also be used to scale the metalness values of the metallic texture.
  99360. */
  99361. metallic: Nullable<number>;
  99362. /**
  99363. * Specifies the roughness scalar of the metallic/roughness workflow.
  99364. * Can also be used to scale the roughness values of the metallic texture.
  99365. */
  99366. roughness: Nullable<number>;
  99367. /**
  99368. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99369. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99370. */
  99371. microSurfaceTexture: BaseTexture;
  99372. /**
  99373. * Stores surface normal data used to displace a mesh in a texture.
  99374. */
  99375. bumpTexture: BaseTexture;
  99376. /**
  99377. * Stores the pre-calculated light information of a mesh in a texture.
  99378. */
  99379. lightmapTexture: BaseTexture;
  99380. /**
  99381. * Stores the refracted light information in a texture.
  99382. */
  99383. refractionTexture: BaseTexture;
  99384. /**
  99385. * The color of a material in ambient lighting.
  99386. */
  99387. ambientColor: Color3;
  99388. /**
  99389. * AKA Diffuse Color in other nomenclature.
  99390. */
  99391. albedoColor: Color3;
  99392. /**
  99393. * AKA Specular Color in other nomenclature.
  99394. */
  99395. reflectivityColor: Color3;
  99396. /**
  99397. * The color reflected from the material.
  99398. */
  99399. reflectionColor: Color3;
  99400. /**
  99401. * The color emitted from the material.
  99402. */
  99403. emissiveColor: Color3;
  99404. /**
  99405. * AKA Glossiness in other nomenclature.
  99406. */
  99407. microSurface: number;
  99408. /**
  99409. * source material index of refraction (IOR)' / 'destination material IOR.
  99410. */
  99411. indexOfRefraction: number;
  99412. /**
  99413. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99414. */
  99415. invertRefractionY: boolean;
  99416. /**
  99417. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99418. * Materials half opaque for instance using refraction could benefit from this control.
  99419. */
  99420. linkRefractionWithTransparency: boolean;
  99421. /**
  99422. * If true, the light map contains occlusion information instead of lighting info.
  99423. */
  99424. useLightmapAsShadowmap: boolean;
  99425. /**
  99426. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99427. */
  99428. useAlphaFromAlbedoTexture: boolean;
  99429. /**
  99430. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99431. */
  99432. forceAlphaTest: boolean;
  99433. /**
  99434. * Defines the alpha limits in alpha test mode.
  99435. */
  99436. alphaCutOff: number;
  99437. /**
  99438. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99439. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99440. */
  99441. useSpecularOverAlpha: boolean;
  99442. /**
  99443. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99444. */
  99445. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99446. /**
  99447. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99448. */
  99449. useRoughnessFromMetallicTextureAlpha: boolean;
  99450. /**
  99451. * Specifies if the metallic texture contains the roughness information in its green channel.
  99452. */
  99453. useRoughnessFromMetallicTextureGreen: boolean;
  99454. /**
  99455. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99456. */
  99457. useMetallnessFromMetallicTextureBlue: boolean;
  99458. /**
  99459. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99460. */
  99461. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99462. /**
  99463. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99464. */
  99465. useAmbientInGrayScale: boolean;
  99466. /**
  99467. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99468. * The material will try to infer what glossiness each pixel should be.
  99469. */
  99470. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99471. /**
  99472. * BJS is using an harcoded light falloff based on a manually sets up range.
  99473. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99474. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99475. */
  99476. /**
  99477. * BJS is using an harcoded light falloff based on a manually sets up range.
  99478. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99479. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99480. */
  99481. usePhysicalLightFalloff: boolean;
  99482. /**
  99483. * In order to support the falloff compatibility with gltf, a special mode has been added
  99484. * to reproduce the gltf light falloff.
  99485. */
  99486. /**
  99487. * In order to support the falloff compatibility with gltf, a special mode has been added
  99488. * to reproduce the gltf light falloff.
  99489. */
  99490. useGLTFLightFalloff: boolean;
  99491. /**
  99492. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99493. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99494. */
  99495. useRadianceOverAlpha: boolean;
  99496. /**
  99497. * Allows using an object space normal map (instead of tangent space).
  99498. */
  99499. useObjectSpaceNormalMap: boolean;
  99500. /**
  99501. * Allows using the bump map in parallax mode.
  99502. */
  99503. useParallax: boolean;
  99504. /**
  99505. * Allows using the bump map in parallax occlusion mode.
  99506. */
  99507. useParallaxOcclusion: boolean;
  99508. /**
  99509. * Controls the scale bias of the parallax mode.
  99510. */
  99511. parallaxScaleBias: number;
  99512. /**
  99513. * If sets to true, disables all the lights affecting the material.
  99514. */
  99515. disableLighting: boolean;
  99516. /**
  99517. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99518. */
  99519. forceIrradianceInFragment: boolean;
  99520. /**
  99521. * Number of Simultaneous lights allowed on the material.
  99522. */
  99523. maxSimultaneousLights: number;
  99524. /**
  99525. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99526. */
  99527. invertNormalMapX: boolean;
  99528. /**
  99529. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99530. */
  99531. invertNormalMapY: boolean;
  99532. /**
  99533. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99534. */
  99535. twoSidedLighting: boolean;
  99536. /**
  99537. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99538. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99539. */
  99540. useAlphaFresnel: boolean;
  99541. /**
  99542. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99543. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99544. */
  99545. useLinearAlphaFresnel: boolean;
  99546. /**
  99547. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99548. * And/Or occlude the blended part.
  99549. */
  99550. environmentBRDFTexture: Nullable<BaseTexture>;
  99551. /**
  99552. * Force normal to face away from face.
  99553. */
  99554. forceNormalForward: boolean;
  99555. /**
  99556. * Enables specular anti aliasing in the PBR shader.
  99557. * It will both interacts on the Geometry for analytical and IBL lighting.
  99558. * It also prefilter the roughness map based on the bump values.
  99559. */
  99560. enableSpecularAntiAliasing: boolean;
  99561. /**
  99562. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99563. * makes the reflect vector face the model (under horizon).
  99564. */
  99565. useHorizonOcclusion: boolean;
  99566. /**
  99567. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99568. * too much the area relying on ambient texture to define their ambient occlusion.
  99569. */
  99570. useRadianceOcclusion: boolean;
  99571. /**
  99572. * If set to true, no lighting calculations will be applied.
  99573. */
  99574. unlit: boolean;
  99575. /**
  99576. * Gets the image processing configuration used either in this material.
  99577. */
  99578. /**
  99579. * Sets the Default image processing configuration used either in the this material.
  99580. *
  99581. * If sets to null, the scene one is in use.
  99582. */
  99583. imageProcessingConfiguration: ImageProcessingConfiguration;
  99584. /**
  99585. * Gets wether the color curves effect is enabled.
  99586. */
  99587. /**
  99588. * Sets wether the color curves effect is enabled.
  99589. */
  99590. cameraColorCurvesEnabled: boolean;
  99591. /**
  99592. * Gets wether the color grading effect is enabled.
  99593. */
  99594. /**
  99595. * Gets wether the color grading effect is enabled.
  99596. */
  99597. cameraColorGradingEnabled: boolean;
  99598. /**
  99599. * Gets wether tonemapping is enabled or not.
  99600. */
  99601. /**
  99602. * Sets wether tonemapping is enabled or not
  99603. */
  99604. cameraToneMappingEnabled: boolean;
  99605. /**
  99606. * The camera exposure used on this material.
  99607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99608. * This corresponds to a photographic exposure.
  99609. */
  99610. /**
  99611. * The camera exposure used on this material.
  99612. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99613. * This corresponds to a photographic exposure.
  99614. */
  99615. cameraExposure: number;
  99616. /**
  99617. * Gets The camera contrast used on this material.
  99618. */
  99619. /**
  99620. * Sets The camera contrast used on this material.
  99621. */
  99622. cameraContrast: number;
  99623. /**
  99624. * Gets the Color Grading 2D Lookup Texture.
  99625. */
  99626. /**
  99627. * Sets the Color Grading 2D Lookup Texture.
  99628. */
  99629. cameraColorGradingTexture: Nullable<BaseTexture>;
  99630. /**
  99631. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99632. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99633. * 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;
  99634. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99635. */
  99636. /**
  99637. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99638. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99639. * 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;
  99640. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99641. */
  99642. cameraColorCurves: Nullable<ColorCurves>;
  99643. /**
  99644. * Instantiates a new PBRMaterial instance.
  99645. *
  99646. * @param name The material name
  99647. * @param scene The scene the material will be use in.
  99648. */
  99649. constructor(name: string, scene: Scene);
  99650. /**
  99651. * Returns the name of this material class.
  99652. */
  99653. getClassName(): string;
  99654. /**
  99655. * Returns an array of the actively used textures.
  99656. * @returns - Array of BaseTextures
  99657. */
  99658. getActiveTextures(): BaseTexture[];
  99659. /**
  99660. * Checks to see if a texture is used in the material.
  99661. * @param texture - Base texture to use.
  99662. * @returns - Boolean specifying if a texture is used in the material.
  99663. */
  99664. hasTexture(texture: BaseTexture): boolean;
  99665. /**
  99666. * Makes a duplicate of the current material.
  99667. * @param name - name to use for the new material.
  99668. */
  99669. clone(name: string): PBRMaterial;
  99670. /**
  99671. * Serializes this PBR Material.
  99672. * @returns - An object with the serialized material.
  99673. */
  99674. serialize(): any;
  99675. /**
  99676. * Parses a PBR Material from a serialized object.
  99677. * @param source - Serialized object.
  99678. * @param scene - BJS scene instance.
  99679. * @param rootUrl - url for the scene object
  99680. * @returns - PBRMaterial
  99681. */
  99682. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99683. }
  99684. }
  99685. declare module BABYLON {
  99686. /** @hidden */
  99687. export var _forceSceneHelpersToBundle: boolean;
  99688. interface Scene {
  99689. /**
  99690. * Creates a default light for the scene.
  99691. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99692. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99693. */
  99694. createDefaultLight(replace?: boolean): void;
  99695. /**
  99696. * Creates a default camera for the scene.
  99697. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99698. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99699. * @param replace has default false, when true replaces the active camera in the scene
  99700. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99701. */
  99702. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99703. /**
  99704. * Creates a default camera and a default light.
  99705. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99706. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99707. * @param replace has the default false, when true replaces the active camera/light in the scene
  99708. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99709. */
  99710. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99711. /**
  99712. * Creates a new sky box
  99713. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99714. * @param environmentTexture defines the texture to use as environment texture
  99715. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99716. * @param scale defines the overall scale of the skybox
  99717. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99718. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99719. * @returns a new mesh holding the sky box
  99720. */
  99721. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99722. /**
  99723. * Creates a new environment
  99724. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99725. * @param options defines the options you can use to configure the environment
  99726. * @returns the new EnvironmentHelper
  99727. */
  99728. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99729. /**
  99730. * Creates a new VREXperienceHelper
  99731. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99732. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99733. * @returns a new VREXperienceHelper
  99734. */
  99735. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99736. /**
  99737. * Creates a new XREXperienceHelper
  99738. * @see http://doc.babylonjs.com/how_to/webxr
  99739. * @returns a promise for a new XREXperienceHelper
  99740. */
  99741. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99742. }
  99743. }
  99744. declare module BABYLON {
  99745. /**
  99746. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99747. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99748. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99749. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99750. */
  99751. export class VideoDome extends TransformNode {
  99752. private _useDirectMapping;
  99753. /**
  99754. * The video texture being displayed on the sphere
  99755. */
  99756. protected _videoTexture: VideoTexture;
  99757. /**
  99758. * Gets the video texture being displayed on the sphere
  99759. */
  99760. readonly videoTexture: VideoTexture;
  99761. /**
  99762. * The skybox material
  99763. */
  99764. protected _material: BackgroundMaterial;
  99765. /**
  99766. * The surface used for the skybox
  99767. */
  99768. protected _mesh: Mesh;
  99769. /**
  99770. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99771. * Also see the options.resolution property.
  99772. */
  99773. fovMultiplier: number;
  99774. /**
  99775. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99776. * @param name Element's name, child elements will append suffixes for their own names.
  99777. * @param urlsOrVideo defines the url(s) or the video element to use
  99778. * @param options An object containing optional or exposed sub element properties
  99779. */
  99780. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99781. resolution?: number;
  99782. clickToPlay?: boolean;
  99783. autoPlay?: boolean;
  99784. loop?: boolean;
  99785. size?: number;
  99786. poster?: string;
  99787. useDirectMapping?: boolean;
  99788. }, scene: Scene);
  99789. /**
  99790. * Releases resources associated with this node.
  99791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99793. */
  99794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99795. }
  99796. }
  99797. declare module BABYLON {
  99798. /**
  99799. * This class can be used to get instrumentation data from a Babylon engine
  99800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99801. */
  99802. export class EngineInstrumentation implements IDisposable {
  99803. /**
  99804. * Define the instrumented engine.
  99805. */
  99806. engine: Engine;
  99807. private _captureGPUFrameTime;
  99808. private _gpuFrameTimeToken;
  99809. private _gpuFrameTime;
  99810. private _captureShaderCompilationTime;
  99811. private _shaderCompilationTime;
  99812. private _onBeginFrameObserver;
  99813. private _onEndFrameObserver;
  99814. private _onBeforeShaderCompilationObserver;
  99815. private _onAfterShaderCompilationObserver;
  99816. /**
  99817. * Gets the perf counter used for GPU frame time
  99818. */
  99819. readonly gpuFrameTimeCounter: PerfCounter;
  99820. /**
  99821. * Gets the GPU frame time capture status
  99822. */
  99823. /**
  99824. * Enable or disable the GPU frame time capture
  99825. */
  99826. captureGPUFrameTime: boolean;
  99827. /**
  99828. * Gets the perf counter used for shader compilation time
  99829. */
  99830. readonly shaderCompilationTimeCounter: PerfCounter;
  99831. /**
  99832. * Gets the shader compilation time capture status
  99833. */
  99834. /**
  99835. * Enable or disable the shader compilation time capture
  99836. */
  99837. captureShaderCompilationTime: boolean;
  99838. /**
  99839. * Instantiates a new engine instrumentation.
  99840. * This class can be used to get instrumentation data from a Babylon engine
  99841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99842. * @param engine Defines the engine to instrument
  99843. */
  99844. constructor(
  99845. /**
  99846. * Define the instrumented engine.
  99847. */
  99848. engine: Engine);
  99849. /**
  99850. * Dispose and release associated resources.
  99851. */
  99852. dispose(): void;
  99853. }
  99854. }
  99855. declare module BABYLON {
  99856. /**
  99857. * This class can be used to get instrumentation data from a Babylon engine
  99858. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99859. */
  99860. export class SceneInstrumentation implements IDisposable {
  99861. /**
  99862. * Defines the scene to instrument
  99863. */
  99864. scene: Scene;
  99865. private _captureActiveMeshesEvaluationTime;
  99866. private _activeMeshesEvaluationTime;
  99867. private _captureRenderTargetsRenderTime;
  99868. private _renderTargetsRenderTime;
  99869. private _captureFrameTime;
  99870. private _frameTime;
  99871. private _captureRenderTime;
  99872. private _renderTime;
  99873. private _captureInterFrameTime;
  99874. private _interFrameTime;
  99875. private _captureParticlesRenderTime;
  99876. private _particlesRenderTime;
  99877. private _captureSpritesRenderTime;
  99878. private _spritesRenderTime;
  99879. private _capturePhysicsTime;
  99880. private _physicsTime;
  99881. private _captureAnimationsTime;
  99882. private _animationsTime;
  99883. private _captureCameraRenderTime;
  99884. private _cameraRenderTime;
  99885. private _onBeforeActiveMeshesEvaluationObserver;
  99886. private _onAfterActiveMeshesEvaluationObserver;
  99887. private _onBeforeRenderTargetsRenderObserver;
  99888. private _onAfterRenderTargetsRenderObserver;
  99889. private _onAfterRenderObserver;
  99890. private _onBeforeDrawPhaseObserver;
  99891. private _onAfterDrawPhaseObserver;
  99892. private _onBeforeAnimationsObserver;
  99893. private _onBeforeParticlesRenderingObserver;
  99894. private _onAfterParticlesRenderingObserver;
  99895. private _onBeforeSpritesRenderingObserver;
  99896. private _onAfterSpritesRenderingObserver;
  99897. private _onBeforePhysicsObserver;
  99898. private _onAfterPhysicsObserver;
  99899. private _onAfterAnimationsObserver;
  99900. private _onBeforeCameraRenderObserver;
  99901. private _onAfterCameraRenderObserver;
  99902. /**
  99903. * Gets the perf counter used for active meshes evaluation time
  99904. */
  99905. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  99906. /**
  99907. * Gets the active meshes evaluation time capture status
  99908. */
  99909. /**
  99910. * Enable or disable the active meshes evaluation time capture
  99911. */
  99912. captureActiveMeshesEvaluationTime: boolean;
  99913. /**
  99914. * Gets the perf counter used for render targets render time
  99915. */
  99916. readonly renderTargetsRenderTimeCounter: PerfCounter;
  99917. /**
  99918. * Gets the render targets render time capture status
  99919. */
  99920. /**
  99921. * Enable or disable the render targets render time capture
  99922. */
  99923. captureRenderTargetsRenderTime: boolean;
  99924. /**
  99925. * Gets the perf counter used for particles render time
  99926. */
  99927. readonly particlesRenderTimeCounter: PerfCounter;
  99928. /**
  99929. * Gets the particles render time capture status
  99930. */
  99931. /**
  99932. * Enable or disable the particles render time capture
  99933. */
  99934. captureParticlesRenderTime: boolean;
  99935. /**
  99936. * Gets the perf counter used for sprites render time
  99937. */
  99938. readonly spritesRenderTimeCounter: PerfCounter;
  99939. /**
  99940. * Gets the sprites render time capture status
  99941. */
  99942. /**
  99943. * Enable or disable the sprites render time capture
  99944. */
  99945. captureSpritesRenderTime: boolean;
  99946. /**
  99947. * Gets the perf counter used for physics time
  99948. */
  99949. readonly physicsTimeCounter: PerfCounter;
  99950. /**
  99951. * Gets the physics time capture status
  99952. */
  99953. /**
  99954. * Enable or disable the physics time capture
  99955. */
  99956. capturePhysicsTime: boolean;
  99957. /**
  99958. * Gets the perf counter used for animations time
  99959. */
  99960. readonly animationsTimeCounter: PerfCounter;
  99961. /**
  99962. * Gets the animations time capture status
  99963. */
  99964. /**
  99965. * Enable or disable the animations time capture
  99966. */
  99967. captureAnimationsTime: boolean;
  99968. /**
  99969. * Gets the perf counter used for frame time capture
  99970. */
  99971. readonly frameTimeCounter: PerfCounter;
  99972. /**
  99973. * Gets the frame time capture status
  99974. */
  99975. /**
  99976. * Enable or disable the frame time capture
  99977. */
  99978. captureFrameTime: boolean;
  99979. /**
  99980. * Gets the perf counter used for inter-frames time capture
  99981. */
  99982. readonly interFrameTimeCounter: PerfCounter;
  99983. /**
  99984. * Gets the inter-frames time capture status
  99985. */
  99986. /**
  99987. * Enable or disable the inter-frames time capture
  99988. */
  99989. captureInterFrameTime: boolean;
  99990. /**
  99991. * Gets the perf counter used for render time capture
  99992. */
  99993. readonly renderTimeCounter: PerfCounter;
  99994. /**
  99995. * Gets the render time capture status
  99996. */
  99997. /**
  99998. * Enable or disable the render time capture
  99999. */
  100000. captureRenderTime: boolean;
  100001. /**
  100002. * Gets the perf counter used for camera render time capture
  100003. */
  100004. readonly cameraRenderTimeCounter: PerfCounter;
  100005. /**
  100006. * Gets the camera render time capture status
  100007. */
  100008. /**
  100009. * Enable or disable the camera render time capture
  100010. */
  100011. captureCameraRenderTime: boolean;
  100012. /**
  100013. * Gets the perf counter used for draw calls
  100014. */
  100015. readonly drawCallsCounter: PerfCounter;
  100016. /**
  100017. * Gets the perf counter used for texture collisions
  100018. */
  100019. readonly textureCollisionsCounter: PerfCounter;
  100020. /**
  100021. * Instantiates a new scene instrumentation.
  100022. * This class can be used to get instrumentation data from a Babylon engine
  100023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100024. * @param scene Defines the scene to instrument
  100025. */
  100026. constructor(
  100027. /**
  100028. * Defines the scene to instrument
  100029. */
  100030. scene: Scene);
  100031. /**
  100032. * Dispose and release associated resources.
  100033. */
  100034. dispose(): void;
  100035. }
  100036. }
  100037. declare module BABYLON {
  100038. /** @hidden */
  100039. export var glowMapGenerationPixelShader: {
  100040. name: string;
  100041. shader: string;
  100042. };
  100043. }
  100044. declare module BABYLON {
  100045. /** @hidden */
  100046. export var glowMapGenerationVertexShader: {
  100047. name: string;
  100048. shader: string;
  100049. };
  100050. }
  100051. declare module BABYLON {
  100052. /**
  100053. * Effect layer options. This helps customizing the behaviour
  100054. * of the effect layer.
  100055. */
  100056. export interface IEffectLayerOptions {
  100057. /**
  100058. * Multiplication factor apply to the canvas size to compute the render target size
  100059. * used to generated the objects (the smaller the faster).
  100060. */
  100061. mainTextureRatio: number;
  100062. /**
  100063. * Enforces a fixed size texture to ensure effect stability across devices.
  100064. */
  100065. mainTextureFixedSize?: number;
  100066. /**
  100067. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  100068. */
  100069. alphaBlendingMode: number;
  100070. /**
  100071. * The camera attached to the layer.
  100072. */
  100073. camera: Nullable<Camera>;
  100074. /**
  100075. * The rendering group to draw the layer in.
  100076. */
  100077. renderingGroupId: number;
  100078. }
  100079. /**
  100080. * The effect layer Helps adding post process effect blended with the main pass.
  100081. *
  100082. * This can be for instance use to generate glow or higlight effects on the scene.
  100083. *
  100084. * The effect layer class can not be used directly and is intented to inherited from to be
  100085. * customized per effects.
  100086. */
  100087. export abstract class EffectLayer {
  100088. private _vertexBuffers;
  100089. private _indexBuffer;
  100090. private _cachedDefines;
  100091. private _effectLayerMapGenerationEffect;
  100092. private _effectLayerOptions;
  100093. private _mergeEffect;
  100094. protected _scene: Scene;
  100095. protected _engine: Engine;
  100096. protected _maxSize: number;
  100097. protected _mainTextureDesiredSize: ISize;
  100098. protected _mainTexture: RenderTargetTexture;
  100099. protected _shouldRender: boolean;
  100100. protected _postProcesses: PostProcess[];
  100101. protected _textures: BaseTexture[];
  100102. protected _emissiveTextureAndColor: {
  100103. texture: Nullable<BaseTexture>;
  100104. color: Color4;
  100105. };
  100106. /**
  100107. * The name of the layer
  100108. */
  100109. name: string;
  100110. /**
  100111. * The clear color of the texture used to generate the glow map.
  100112. */
  100113. neutralColor: Color4;
  100114. /**
  100115. * Specifies wether the highlight layer is enabled or not.
  100116. */
  100117. isEnabled: boolean;
  100118. /**
  100119. * Gets the camera attached to the layer.
  100120. */
  100121. readonly camera: Nullable<Camera>;
  100122. /**
  100123. * Gets the rendering group id the layer should render in.
  100124. */
  100125. readonly renderingGroupId: number;
  100126. /**
  100127. * An event triggered when the effect layer has been disposed.
  100128. */
  100129. onDisposeObservable: Observable<EffectLayer>;
  100130. /**
  100131. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100132. */
  100133. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100134. /**
  100135. * An event triggered when the generated texture is being merged in the scene.
  100136. */
  100137. onBeforeComposeObservable: Observable<EffectLayer>;
  100138. /**
  100139. * An event triggered when the generated texture has been merged in the scene.
  100140. */
  100141. onAfterComposeObservable: Observable<EffectLayer>;
  100142. /**
  100143. * An event triggered when the efffect layer changes its size.
  100144. */
  100145. onSizeChangedObservable: Observable<EffectLayer>;
  100146. /** @hidden */
  100147. static _SceneComponentInitialization: (scene: Scene) => void;
  100148. /**
  100149. * Instantiates a new effect Layer and references it in the scene.
  100150. * @param name The name of the layer
  100151. * @param scene The scene to use the layer in
  100152. */
  100153. constructor(
  100154. /** The Friendly of the effect in the scene */
  100155. name: string, scene: Scene);
  100156. /**
  100157. * Get the effect name of the layer.
  100158. * @return The effect name
  100159. */
  100160. abstract getEffectName(): string;
  100161. /**
  100162. * Checks for the readiness of the element composing the layer.
  100163. * @param subMesh the mesh to check for
  100164. * @param useInstances specify wether or not to use instances to render the mesh
  100165. * @return true if ready otherwise, false
  100166. */
  100167. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100168. /**
  100169. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100170. * @returns true if the effect requires stencil during the main canvas render pass.
  100171. */
  100172. abstract needStencil(): boolean;
  100173. /**
  100174. * Create the merge effect. This is the shader use to blit the information back
  100175. * to the main canvas at the end of the scene rendering.
  100176. * @returns The effect containing the shader used to merge the effect on the main canvas
  100177. */
  100178. protected abstract _createMergeEffect(): Effect;
  100179. /**
  100180. * Creates the render target textures and post processes used in the effect layer.
  100181. */
  100182. protected abstract _createTextureAndPostProcesses(): void;
  100183. /**
  100184. * Implementation specific of rendering the generating effect on the main canvas.
  100185. * @param effect The effect used to render through
  100186. */
  100187. protected abstract _internalRender(effect: Effect): void;
  100188. /**
  100189. * Sets the required values for both the emissive texture and and the main color.
  100190. */
  100191. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100192. /**
  100193. * Free any resources and references associated to a mesh.
  100194. * Internal use
  100195. * @param mesh The mesh to free.
  100196. */
  100197. abstract _disposeMesh(mesh: Mesh): void;
  100198. /**
  100199. * Serializes this layer (Glow or Highlight for example)
  100200. * @returns a serialized layer object
  100201. */
  100202. abstract serialize?(): any;
  100203. /**
  100204. * Initializes the effect layer with the required options.
  100205. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100206. */
  100207. protected _init(options: Partial<IEffectLayerOptions>): void;
  100208. /**
  100209. * Generates the index buffer of the full screen quad blending to the main canvas.
  100210. */
  100211. private _generateIndexBuffer;
  100212. /**
  100213. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100214. */
  100215. private _genrateVertexBuffer;
  100216. /**
  100217. * Sets the main texture desired size which is the closest power of two
  100218. * of the engine canvas size.
  100219. */
  100220. private _setMainTextureSize;
  100221. /**
  100222. * Creates the main texture for the effect layer.
  100223. */
  100224. protected _createMainTexture(): void;
  100225. /**
  100226. * Adds specific effects defines.
  100227. * @param defines The defines to add specifics to.
  100228. */
  100229. protected _addCustomEffectDefines(defines: string[]): void;
  100230. /**
  100231. * Checks for the readiness of the element composing the layer.
  100232. * @param subMesh the mesh to check for
  100233. * @param useInstances specify wether or not to use instances to render the mesh
  100234. * @param emissiveTexture the associated emissive texture used to generate the glow
  100235. * @return true if ready otherwise, false
  100236. */
  100237. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100238. /**
  100239. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100240. */
  100241. render(): void;
  100242. /**
  100243. * Determine if a given mesh will be used in the current effect.
  100244. * @param mesh mesh to test
  100245. * @returns true if the mesh will be used
  100246. */
  100247. hasMesh(mesh: AbstractMesh): boolean;
  100248. /**
  100249. * Returns true if the layer contains information to display, otherwise false.
  100250. * @returns true if the glow layer should be rendered
  100251. */
  100252. shouldRender(): boolean;
  100253. /**
  100254. * Returns true if the mesh should render, otherwise false.
  100255. * @param mesh The mesh to render
  100256. * @returns true if it should render otherwise false
  100257. */
  100258. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100259. /**
  100260. * Returns true if the mesh can be rendered, otherwise false.
  100261. * @param mesh The mesh to render
  100262. * @param material The material used on the mesh
  100263. * @returns true if it can be rendered otherwise false
  100264. */
  100265. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100266. /**
  100267. * Returns true if the mesh should render, otherwise false.
  100268. * @param mesh The mesh to render
  100269. * @returns true if it should render otherwise false
  100270. */
  100271. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100272. /**
  100273. * Renders the submesh passed in parameter to the generation map.
  100274. */
  100275. protected _renderSubMesh(subMesh: SubMesh): void;
  100276. /**
  100277. * Rebuild the required buffers.
  100278. * @hidden Internal use only.
  100279. */
  100280. _rebuild(): void;
  100281. /**
  100282. * Dispose only the render target textures and post process.
  100283. */
  100284. private _disposeTextureAndPostProcesses;
  100285. /**
  100286. * Dispose the highlight layer and free resources.
  100287. */
  100288. dispose(): void;
  100289. /**
  100290. * Gets the class name of the effect layer
  100291. * @returns the string with the class name of the effect layer
  100292. */
  100293. getClassName(): string;
  100294. /**
  100295. * Creates an effect layer from parsed effect layer data
  100296. * @param parsedEffectLayer defines effect layer data
  100297. * @param scene defines the current scene
  100298. * @param rootUrl defines the root URL containing the effect layer information
  100299. * @returns a parsed effect Layer
  100300. */
  100301. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100302. }
  100303. }
  100304. declare module BABYLON {
  100305. interface AbstractScene {
  100306. /**
  100307. * The list of effect layers (highlights/glow) added to the scene
  100308. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100309. * @see http://doc.babylonjs.com/how_to/glow_layer
  100310. */
  100311. effectLayers: Array<EffectLayer>;
  100312. /**
  100313. * Removes the given effect layer from this scene.
  100314. * @param toRemove defines the effect layer to remove
  100315. * @returns the index of the removed effect layer
  100316. */
  100317. removeEffectLayer(toRemove: EffectLayer): number;
  100318. /**
  100319. * Adds the given effect layer to this scene
  100320. * @param newEffectLayer defines the effect layer to add
  100321. */
  100322. addEffectLayer(newEffectLayer: EffectLayer): void;
  100323. }
  100324. /**
  100325. * Defines the layer scene component responsible to manage any effect layers
  100326. * in a given scene.
  100327. */
  100328. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100329. /**
  100330. * The component name helpfull to identify the component in the list of scene components.
  100331. */
  100332. readonly name: string;
  100333. /**
  100334. * The scene the component belongs to.
  100335. */
  100336. scene: Scene;
  100337. private _engine;
  100338. private _renderEffects;
  100339. private _needStencil;
  100340. private _previousStencilState;
  100341. /**
  100342. * Creates a new instance of the component for the given scene
  100343. * @param scene Defines the scene to register the component in
  100344. */
  100345. constructor(scene: Scene);
  100346. /**
  100347. * Registers the component in a given scene
  100348. */
  100349. register(): void;
  100350. /**
  100351. * Rebuilds the elements related to this component in case of
  100352. * context lost for instance.
  100353. */
  100354. rebuild(): void;
  100355. /**
  100356. * Serializes the component data to the specified json object
  100357. * @param serializationObject The object to serialize to
  100358. */
  100359. serialize(serializationObject: any): void;
  100360. /**
  100361. * Adds all the element from the container to the scene
  100362. * @param container the container holding the elements
  100363. */
  100364. addFromContainer(container: AbstractScene): void;
  100365. /**
  100366. * Removes all the elements in the container from the scene
  100367. * @param container contains the elements to remove
  100368. */
  100369. removeFromContainer(container: AbstractScene): void;
  100370. /**
  100371. * Disposes the component and the associated ressources.
  100372. */
  100373. dispose(): void;
  100374. private _isReadyForMesh;
  100375. private _renderMainTexture;
  100376. private _setStencil;
  100377. private _setStencilBack;
  100378. private _draw;
  100379. private _drawCamera;
  100380. private _drawRenderingGroup;
  100381. }
  100382. }
  100383. declare module BABYLON {
  100384. /** @hidden */
  100385. export var glowMapMergePixelShader: {
  100386. name: string;
  100387. shader: string;
  100388. };
  100389. }
  100390. declare module BABYLON {
  100391. /** @hidden */
  100392. export var glowMapMergeVertexShader: {
  100393. name: string;
  100394. shader: string;
  100395. };
  100396. }
  100397. declare module BABYLON {
  100398. interface AbstractScene {
  100399. /**
  100400. * Return a the first highlight layer of the scene with a given name.
  100401. * @param name The name of the highlight layer to look for.
  100402. * @return The highlight layer if found otherwise null.
  100403. */
  100404. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100405. }
  100406. /**
  100407. * Glow layer options. This helps customizing the behaviour
  100408. * of the glow layer.
  100409. */
  100410. export interface IGlowLayerOptions {
  100411. /**
  100412. * Multiplication factor apply to the canvas size to compute the render target size
  100413. * used to generated the glowing objects (the smaller the faster).
  100414. */
  100415. mainTextureRatio: number;
  100416. /**
  100417. * Enforces a fixed size texture to ensure resize independant blur.
  100418. */
  100419. mainTextureFixedSize?: number;
  100420. /**
  100421. * How big is the kernel of the blur texture.
  100422. */
  100423. blurKernelSize: number;
  100424. /**
  100425. * The camera attached to the layer.
  100426. */
  100427. camera: Nullable<Camera>;
  100428. /**
  100429. * Enable MSAA by chosing the number of samples.
  100430. */
  100431. mainTextureSamples?: number;
  100432. /**
  100433. * The rendering group to draw the layer in.
  100434. */
  100435. renderingGroupId: number;
  100436. }
  100437. /**
  100438. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100439. *
  100440. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100441. * glowy meshes to your scene.
  100442. *
  100443. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100444. */
  100445. export class GlowLayer extends EffectLayer {
  100446. /**
  100447. * Effect Name of the layer.
  100448. */
  100449. static readonly EffectName: string;
  100450. /**
  100451. * The default blur kernel size used for the glow.
  100452. */
  100453. static DefaultBlurKernelSize: number;
  100454. /**
  100455. * The default texture size ratio used for the glow.
  100456. */
  100457. static DefaultTextureRatio: number;
  100458. /**
  100459. * Sets the kernel size of the blur.
  100460. */
  100461. /**
  100462. * Gets the kernel size of the blur.
  100463. */
  100464. blurKernelSize: number;
  100465. /**
  100466. * Sets the glow intensity.
  100467. */
  100468. /**
  100469. * Gets the glow intensity.
  100470. */
  100471. intensity: number;
  100472. private _options;
  100473. private _intensity;
  100474. private _horizontalBlurPostprocess1;
  100475. private _verticalBlurPostprocess1;
  100476. private _horizontalBlurPostprocess2;
  100477. private _verticalBlurPostprocess2;
  100478. private _blurTexture1;
  100479. private _blurTexture2;
  100480. private _postProcesses1;
  100481. private _postProcesses2;
  100482. private _includedOnlyMeshes;
  100483. private _excludedMeshes;
  100484. /**
  100485. * Callback used to let the user override the color selection on a per mesh basis
  100486. */
  100487. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100488. /**
  100489. * Callback used to let the user override the texture selection on a per mesh basis
  100490. */
  100491. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100492. /**
  100493. * Instantiates a new glow Layer and references it to the scene.
  100494. * @param name The name of the layer
  100495. * @param scene The scene to use the layer in
  100496. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100497. */
  100498. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100499. /**
  100500. * Get the effect name of the layer.
  100501. * @return The effect name
  100502. */
  100503. getEffectName(): string;
  100504. /**
  100505. * Create the merge effect. This is the shader use to blit the information back
  100506. * to the main canvas at the end of the scene rendering.
  100507. */
  100508. protected _createMergeEffect(): Effect;
  100509. /**
  100510. * Creates the render target textures and post processes used in the glow layer.
  100511. */
  100512. protected _createTextureAndPostProcesses(): void;
  100513. /**
  100514. * Checks for the readiness of the element composing the layer.
  100515. * @param subMesh the mesh to check for
  100516. * @param useInstances specify wether or not to use instances to render the mesh
  100517. * @param emissiveTexture the associated emissive texture used to generate the glow
  100518. * @return true if ready otherwise, false
  100519. */
  100520. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100521. /**
  100522. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100523. */
  100524. needStencil(): boolean;
  100525. /**
  100526. * Returns true if the mesh can be rendered, otherwise false.
  100527. * @param mesh The mesh to render
  100528. * @param material The material used on the mesh
  100529. * @returns true if it can be rendered otherwise false
  100530. */
  100531. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100532. /**
  100533. * Implementation specific of rendering the generating effect on the main canvas.
  100534. * @param effect The effect used to render through
  100535. */
  100536. protected _internalRender(effect: Effect): void;
  100537. /**
  100538. * Sets the required values for both the emissive texture and and the main color.
  100539. */
  100540. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100541. /**
  100542. * Returns true if the mesh should render, otherwise false.
  100543. * @param mesh The mesh to render
  100544. * @returns true if it should render otherwise false
  100545. */
  100546. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100547. /**
  100548. * Adds specific effects defines.
  100549. * @param defines The defines to add specifics to.
  100550. */
  100551. protected _addCustomEffectDefines(defines: string[]): void;
  100552. /**
  100553. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100554. * @param mesh The mesh to exclude from the glow layer
  100555. */
  100556. addExcludedMesh(mesh: Mesh): void;
  100557. /**
  100558. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100559. * @param mesh The mesh to remove
  100560. */
  100561. removeExcludedMesh(mesh: Mesh): void;
  100562. /**
  100563. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100564. * @param mesh The mesh to include in the glow layer
  100565. */
  100566. addIncludedOnlyMesh(mesh: Mesh): void;
  100567. /**
  100568. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100569. * @param mesh The mesh to remove
  100570. */
  100571. removeIncludedOnlyMesh(mesh: Mesh): void;
  100572. /**
  100573. * Determine if a given mesh will be used in the glow layer
  100574. * @param mesh The mesh to test
  100575. * @returns true if the mesh will be highlighted by the current glow layer
  100576. */
  100577. hasMesh(mesh: AbstractMesh): boolean;
  100578. /**
  100579. * Free any resources and references associated to a mesh.
  100580. * Internal use
  100581. * @param mesh The mesh to free.
  100582. * @hidden
  100583. */
  100584. _disposeMesh(mesh: Mesh): void;
  100585. /**
  100586. * Gets the class name of the effect layer
  100587. * @returns the string with the class name of the effect layer
  100588. */
  100589. getClassName(): string;
  100590. /**
  100591. * Serializes this glow layer
  100592. * @returns a serialized glow layer object
  100593. */
  100594. serialize(): any;
  100595. /**
  100596. * Creates a Glow Layer from parsed glow layer data
  100597. * @param parsedGlowLayer defines glow layer data
  100598. * @param scene defines the current scene
  100599. * @param rootUrl defines the root URL containing the glow layer information
  100600. * @returns a parsed Glow Layer
  100601. */
  100602. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100603. }
  100604. }
  100605. declare module BABYLON {
  100606. /** @hidden */
  100607. export var glowBlurPostProcessPixelShader: {
  100608. name: string;
  100609. shader: string;
  100610. };
  100611. }
  100612. declare module BABYLON {
  100613. interface AbstractScene {
  100614. /**
  100615. * Return a the first highlight layer of the scene with a given name.
  100616. * @param name The name of the highlight layer to look for.
  100617. * @return The highlight layer if found otherwise null.
  100618. */
  100619. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100620. }
  100621. /**
  100622. * Highlight layer options. This helps customizing the behaviour
  100623. * of the highlight layer.
  100624. */
  100625. export interface IHighlightLayerOptions {
  100626. /**
  100627. * Multiplication factor apply to the canvas size to compute the render target size
  100628. * used to generated the glowing objects (the smaller the faster).
  100629. */
  100630. mainTextureRatio: number;
  100631. /**
  100632. * Enforces a fixed size texture to ensure resize independant blur.
  100633. */
  100634. mainTextureFixedSize?: number;
  100635. /**
  100636. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100637. * of the picture to blur (the smaller the faster).
  100638. */
  100639. blurTextureSizeRatio: number;
  100640. /**
  100641. * How big in texel of the blur texture is the vertical blur.
  100642. */
  100643. blurVerticalSize: number;
  100644. /**
  100645. * How big in texel of the blur texture is the horizontal blur.
  100646. */
  100647. blurHorizontalSize: number;
  100648. /**
  100649. * Alpha blending mode used to apply the blur. Default is combine.
  100650. */
  100651. alphaBlendingMode: number;
  100652. /**
  100653. * The camera attached to the layer.
  100654. */
  100655. camera: Nullable<Camera>;
  100656. /**
  100657. * Should we display highlight as a solid stroke?
  100658. */
  100659. isStroke?: boolean;
  100660. /**
  100661. * The rendering group to draw the layer in.
  100662. */
  100663. renderingGroupId: number;
  100664. }
  100665. /**
  100666. * The highlight layer Helps adding a glow effect around a mesh.
  100667. *
  100668. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100669. * glowy meshes to your scene.
  100670. *
  100671. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100672. */
  100673. export class HighlightLayer extends EffectLayer {
  100674. name: string;
  100675. /**
  100676. * Effect Name of the highlight layer.
  100677. */
  100678. static readonly EffectName: string;
  100679. /**
  100680. * The neutral color used during the preparation of the glow effect.
  100681. * This is black by default as the blend operation is a blend operation.
  100682. */
  100683. static NeutralColor: Color4;
  100684. /**
  100685. * Stencil value used for glowing meshes.
  100686. */
  100687. static GlowingMeshStencilReference: number;
  100688. /**
  100689. * Stencil value used for the other meshes in the scene.
  100690. */
  100691. static NormalMeshStencilReference: number;
  100692. /**
  100693. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100694. */
  100695. innerGlow: boolean;
  100696. /**
  100697. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100698. */
  100699. outerGlow: boolean;
  100700. /**
  100701. * Specifies the horizontal size of the blur.
  100702. */
  100703. /**
  100704. * Gets the horizontal size of the blur.
  100705. */
  100706. blurHorizontalSize: number;
  100707. /**
  100708. * Specifies the vertical size of the blur.
  100709. */
  100710. /**
  100711. * Gets the vertical size of the blur.
  100712. */
  100713. blurVerticalSize: number;
  100714. /**
  100715. * An event triggered when the highlight layer is being blurred.
  100716. */
  100717. onBeforeBlurObservable: Observable<HighlightLayer>;
  100718. /**
  100719. * An event triggered when the highlight layer has been blurred.
  100720. */
  100721. onAfterBlurObservable: Observable<HighlightLayer>;
  100722. private _instanceGlowingMeshStencilReference;
  100723. private _options;
  100724. private _downSamplePostprocess;
  100725. private _horizontalBlurPostprocess;
  100726. private _verticalBlurPostprocess;
  100727. private _blurTexture;
  100728. private _meshes;
  100729. private _excludedMeshes;
  100730. /**
  100731. * Instantiates a new highlight Layer and references it to the scene..
  100732. * @param name The name of the layer
  100733. * @param scene The scene to use the layer in
  100734. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100735. */
  100736. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100737. /**
  100738. * Get the effect name of the layer.
  100739. * @return The effect name
  100740. */
  100741. getEffectName(): string;
  100742. /**
  100743. * Create the merge effect. This is the shader use to blit the information back
  100744. * to the main canvas at the end of the scene rendering.
  100745. */
  100746. protected _createMergeEffect(): Effect;
  100747. /**
  100748. * Creates the render target textures and post processes used in the highlight layer.
  100749. */
  100750. protected _createTextureAndPostProcesses(): void;
  100751. /**
  100752. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100753. */
  100754. needStencil(): boolean;
  100755. /**
  100756. * Checks for the readiness of the element composing the layer.
  100757. * @param subMesh the mesh to check for
  100758. * @param useInstances specify wether or not to use instances to render the mesh
  100759. * @param emissiveTexture the associated emissive texture used to generate the glow
  100760. * @return true if ready otherwise, false
  100761. */
  100762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100763. /**
  100764. * Implementation specific of rendering the generating effect on the main canvas.
  100765. * @param effect The effect used to render through
  100766. */
  100767. protected _internalRender(effect: Effect): void;
  100768. /**
  100769. * Returns true if the layer contains information to display, otherwise false.
  100770. */
  100771. shouldRender(): boolean;
  100772. /**
  100773. * Returns true if the mesh should render, otherwise false.
  100774. * @param mesh The mesh to render
  100775. * @returns true if it should render otherwise false
  100776. */
  100777. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100778. /**
  100779. * Sets the required values for both the emissive texture and and the main color.
  100780. */
  100781. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100782. /**
  100783. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100784. * @param mesh The mesh to exclude from the highlight layer
  100785. */
  100786. addExcludedMesh(mesh: Mesh): void;
  100787. /**
  100788. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100789. * @param mesh The mesh to highlight
  100790. */
  100791. removeExcludedMesh(mesh: Mesh): void;
  100792. /**
  100793. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100794. * @param mesh mesh to test
  100795. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100796. */
  100797. hasMesh(mesh: AbstractMesh): boolean;
  100798. /**
  100799. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100800. * @param mesh The mesh to highlight
  100801. * @param color The color of the highlight
  100802. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100803. */
  100804. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100805. /**
  100806. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100807. * @param mesh The mesh to highlight
  100808. */
  100809. removeMesh(mesh: Mesh): void;
  100810. /**
  100811. * Force the stencil to the normal expected value for none glowing parts
  100812. */
  100813. private _defaultStencilReference;
  100814. /**
  100815. * Free any resources and references associated to a mesh.
  100816. * Internal use
  100817. * @param mesh The mesh to free.
  100818. * @hidden
  100819. */
  100820. _disposeMesh(mesh: Mesh): void;
  100821. /**
  100822. * Dispose the highlight layer and free resources.
  100823. */
  100824. dispose(): void;
  100825. /**
  100826. * Gets the class name of the effect layer
  100827. * @returns the string with the class name of the effect layer
  100828. */
  100829. getClassName(): string;
  100830. /**
  100831. * Serializes this Highlight layer
  100832. * @returns a serialized Highlight layer object
  100833. */
  100834. serialize(): any;
  100835. /**
  100836. * Creates a Highlight layer from parsed Highlight layer data
  100837. * @param parsedHightlightLayer defines the Highlight layer data
  100838. * @param scene defines the current scene
  100839. * @param rootUrl defines the root URL containing the Highlight layer information
  100840. * @returns a parsed Highlight layer
  100841. */
  100842. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100843. }
  100844. }
  100845. declare module BABYLON {
  100846. /** @hidden */
  100847. export var lensFlarePixelShader: {
  100848. name: string;
  100849. shader: string;
  100850. };
  100851. }
  100852. declare module BABYLON {
  100853. /** @hidden */
  100854. export var lensFlareVertexShader: {
  100855. name: string;
  100856. shader: string;
  100857. };
  100858. }
  100859. declare module BABYLON {
  100860. /**
  100861. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100862. * It is usually composed of several `lensFlare`.
  100863. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100864. */
  100865. export class LensFlareSystem {
  100866. /**
  100867. * Define the name of the lens flare system
  100868. */
  100869. name: string;
  100870. /**
  100871. * List of lens flares used in this system.
  100872. */
  100873. lensFlares: LensFlare[];
  100874. /**
  100875. * Define a limit from the border the lens flare can be visible.
  100876. */
  100877. borderLimit: number;
  100878. /**
  100879. * Define a viewport border we do not want to see the lens flare in.
  100880. */
  100881. viewportBorder: number;
  100882. /**
  100883. * Define a predicate which could limit the list of meshes able to occlude the effect.
  100884. */
  100885. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  100886. /**
  100887. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  100888. */
  100889. layerMask: number;
  100890. /**
  100891. * Define the id of the lens flare system in the scene.
  100892. * (equal to name by default)
  100893. */
  100894. id: string;
  100895. private _scene;
  100896. private _emitter;
  100897. private _vertexBuffers;
  100898. private _indexBuffer;
  100899. private _effect;
  100900. private _positionX;
  100901. private _positionY;
  100902. private _isEnabled;
  100903. /** @hidden */
  100904. static _SceneComponentInitialization: (scene: Scene) => void;
  100905. /**
  100906. * Instantiates a lens flare system.
  100907. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100908. * It is usually composed of several `lensFlare`.
  100909. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100910. * @param name Define the name of the lens flare system in the scene
  100911. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  100912. * @param scene Define the scene the lens flare system belongs to
  100913. */
  100914. constructor(
  100915. /**
  100916. * Define the name of the lens flare system
  100917. */
  100918. name: string, emitter: any, scene: Scene);
  100919. /**
  100920. * Define if the lens flare system is enabled.
  100921. */
  100922. isEnabled: boolean;
  100923. /**
  100924. * Get the scene the effects belongs to.
  100925. * @returns the scene holding the lens flare system
  100926. */
  100927. getScene(): Scene;
  100928. /**
  100929. * Get the emitter of the lens flare system.
  100930. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100931. * @returns the emitter of the lens flare system
  100932. */
  100933. getEmitter(): any;
  100934. /**
  100935. * Set the emitter of the lens flare system.
  100936. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100937. * @param newEmitter Define the new emitter of the system
  100938. */
  100939. setEmitter(newEmitter: any): void;
  100940. /**
  100941. * Get the lens flare system emitter position.
  100942. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  100943. * @returns the position
  100944. */
  100945. getEmitterPosition(): Vector3;
  100946. /**
  100947. * @hidden
  100948. */
  100949. computeEffectivePosition(globalViewport: Viewport): boolean;
  100950. /** @hidden */
  100951. _isVisible(): boolean;
  100952. /**
  100953. * @hidden
  100954. */
  100955. render(): boolean;
  100956. /**
  100957. * Dispose and release the lens flare with its associated resources.
  100958. */
  100959. dispose(): void;
  100960. /**
  100961. * Parse a lens flare system from a JSON repressentation
  100962. * @param parsedLensFlareSystem Define the JSON to parse
  100963. * @param scene Define the scene the parsed system should be instantiated in
  100964. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  100965. * @returns the parsed system
  100966. */
  100967. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  100968. /**
  100969. * Serialize the current Lens Flare System into a JSON representation.
  100970. * @returns the serialized JSON
  100971. */
  100972. serialize(): any;
  100973. }
  100974. }
  100975. declare module BABYLON {
  100976. /**
  100977. * This represents one of the lens effect in a `lensFlareSystem`.
  100978. * It controls one of the indiviual texture used in the effect.
  100979. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100980. */
  100981. export class LensFlare {
  100982. /**
  100983. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100984. */
  100985. size: number;
  100986. /**
  100987. * 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.
  100988. */
  100989. position: number;
  100990. /**
  100991. * Define the lens color.
  100992. */
  100993. color: Color3;
  100994. /**
  100995. * Define the lens texture.
  100996. */
  100997. texture: Nullable<Texture>;
  100998. /**
  100999. * Define the alpha mode to render this particular lens.
  101000. */
  101001. alphaMode: number;
  101002. private _system;
  101003. /**
  101004. * Creates a new Lens Flare.
  101005. * This represents one of the lens effect in a `lensFlareSystem`.
  101006. * It controls one of the indiviual texture used in the effect.
  101007. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101008. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  101009. * @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.
  101010. * @param color Define the lens color
  101011. * @param imgUrl Define the lens texture url
  101012. * @param system Define the `lensFlareSystem` this flare is part of
  101013. * @returns The newly created Lens Flare
  101014. */
  101015. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  101016. /**
  101017. * Instantiates a new Lens Flare.
  101018. * This represents one of the lens effect in a `lensFlareSystem`.
  101019. * It controls one of the indiviual texture used in the effect.
  101020. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101021. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  101022. * @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.
  101023. * @param color Define the lens color
  101024. * @param imgUrl Define the lens texture url
  101025. * @param system Define the `lensFlareSystem` this flare is part of
  101026. */
  101027. constructor(
  101028. /**
  101029. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101030. */
  101031. size: number,
  101032. /**
  101033. * 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.
  101034. */
  101035. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  101036. /**
  101037. * Dispose and release the lens flare with its associated resources.
  101038. */
  101039. dispose(): void;
  101040. }
  101041. }
  101042. declare module BABYLON {
  101043. interface AbstractScene {
  101044. /**
  101045. * The list of lens flare system added to the scene
  101046. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101047. */
  101048. lensFlareSystems: Array<LensFlareSystem>;
  101049. /**
  101050. * Removes the given lens flare system from this scene.
  101051. * @param toRemove The lens flare system to remove
  101052. * @returns The index of the removed lens flare system
  101053. */
  101054. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  101055. /**
  101056. * Adds the given lens flare system to this scene
  101057. * @param newLensFlareSystem The lens flare system to add
  101058. */
  101059. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  101060. /**
  101061. * Gets a lens flare system using its name
  101062. * @param name defines the name to look for
  101063. * @returns the lens flare system or null if not found
  101064. */
  101065. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  101066. /**
  101067. * Gets a lens flare system using its id
  101068. * @param id defines the id to look for
  101069. * @returns the lens flare system or null if not found
  101070. */
  101071. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  101072. }
  101073. /**
  101074. * Defines the lens flare scene component responsible to manage any lens flares
  101075. * in a given scene.
  101076. */
  101077. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  101078. /**
  101079. * The component name helpfull to identify the component in the list of scene components.
  101080. */
  101081. readonly name: string;
  101082. /**
  101083. * The scene the component belongs to.
  101084. */
  101085. scene: Scene;
  101086. /**
  101087. * Creates a new instance of the component for the given scene
  101088. * @param scene Defines the scene to register the component in
  101089. */
  101090. constructor(scene: Scene);
  101091. /**
  101092. * Registers the component in a given scene
  101093. */
  101094. register(): void;
  101095. /**
  101096. * Rebuilds the elements related to this component in case of
  101097. * context lost for instance.
  101098. */
  101099. rebuild(): void;
  101100. /**
  101101. * Adds all the element from the container to the scene
  101102. * @param container the container holding the elements
  101103. */
  101104. addFromContainer(container: AbstractScene): void;
  101105. /**
  101106. * Removes all the elements in the container from the scene
  101107. * @param container contains the elements to remove
  101108. */
  101109. removeFromContainer(container: AbstractScene): void;
  101110. /**
  101111. * Serializes the component data to the specified json object
  101112. * @param serializationObject The object to serialize to
  101113. */
  101114. serialize(serializationObject: any): void;
  101115. /**
  101116. * Disposes the component and the associated ressources.
  101117. */
  101118. dispose(): void;
  101119. private _draw;
  101120. }
  101121. }
  101122. declare module BABYLON {
  101123. /**
  101124. * Defines the shadow generator component responsible to manage any shadow generators
  101125. * in a given scene.
  101126. */
  101127. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101128. /**
  101129. * The component name helpfull to identify the component in the list of scene components.
  101130. */
  101131. readonly name: string;
  101132. /**
  101133. * The scene the component belongs to.
  101134. */
  101135. scene: Scene;
  101136. /**
  101137. * Creates a new instance of the component for the given scene
  101138. * @param scene Defines the scene to register the component in
  101139. */
  101140. constructor(scene: Scene);
  101141. /**
  101142. * Registers the component in a given scene
  101143. */
  101144. register(): void;
  101145. /**
  101146. * Rebuilds the elements related to this component in case of
  101147. * context lost for instance.
  101148. */
  101149. rebuild(): void;
  101150. /**
  101151. * Serializes the component data to the specified json object
  101152. * @param serializationObject The object to serialize to
  101153. */
  101154. serialize(serializationObject: any): void;
  101155. /**
  101156. * Adds all the element from the container to the scene
  101157. * @param container the container holding the elements
  101158. */
  101159. addFromContainer(container: AbstractScene): void;
  101160. /**
  101161. * Removes all the elements in the container from the scene
  101162. * @param container contains the elements to remove
  101163. */
  101164. removeFromContainer(container: AbstractScene): void;
  101165. /**
  101166. * Rebuilds the elements related to this component in case of
  101167. * context lost for instance.
  101168. */
  101169. dispose(): void;
  101170. private _gatherRenderTargets;
  101171. }
  101172. }
  101173. declare module BABYLON {
  101174. /**
  101175. * A directional light is defined by a direction (what a surprise!).
  101176. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101177. * 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.
  101178. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101179. */
  101180. export class DirectionalLight extends ShadowLight {
  101181. private _shadowFrustumSize;
  101182. /**
  101183. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101184. */
  101185. /**
  101186. * Specifies a fix frustum size for the shadow generation.
  101187. */
  101188. shadowFrustumSize: number;
  101189. private _shadowOrthoScale;
  101190. /**
  101191. * Gets the shadow projection scale against the optimal computed one.
  101192. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101193. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101194. */
  101195. /**
  101196. * Sets the shadow projection scale against the optimal computed one.
  101197. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101198. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101199. */
  101200. shadowOrthoScale: number;
  101201. /**
  101202. * Automatically compute the projection matrix to best fit (including all the casters)
  101203. * on each frame.
  101204. */
  101205. autoUpdateExtends: boolean;
  101206. private _orthoLeft;
  101207. private _orthoRight;
  101208. private _orthoTop;
  101209. private _orthoBottom;
  101210. /**
  101211. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101212. * The directional light is emitted from everywhere in the given direction.
  101213. * It can cast shadows.
  101214. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101215. * @param name The friendly name of the light
  101216. * @param direction The direction of the light
  101217. * @param scene The scene the light belongs to
  101218. */
  101219. constructor(name: string, direction: Vector3, scene: Scene);
  101220. /**
  101221. * Returns the string "DirectionalLight".
  101222. * @return The class name
  101223. */
  101224. getClassName(): string;
  101225. /**
  101226. * Returns the integer 1.
  101227. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101228. */
  101229. getTypeID(): number;
  101230. /**
  101231. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101232. * Returns the DirectionalLight Shadow projection matrix.
  101233. */
  101234. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101235. /**
  101236. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101237. * Returns the DirectionalLight Shadow projection matrix.
  101238. */
  101239. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101240. /**
  101241. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101242. * Returns the DirectionalLight Shadow projection matrix.
  101243. */
  101244. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101245. protected _buildUniformLayout(): void;
  101246. /**
  101247. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101248. * @param effect The effect to update
  101249. * @param lightIndex The index of the light in the effect to update
  101250. * @returns The directional light
  101251. */
  101252. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101253. /**
  101254. * Gets the minZ used for shadow according to both the scene and the light.
  101255. *
  101256. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101257. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101258. * @param activeCamera The camera we are returning the min for
  101259. * @returns the depth min z
  101260. */
  101261. getDepthMinZ(activeCamera: Camera): number;
  101262. /**
  101263. * Gets the maxZ used for shadow according to both the scene and the light.
  101264. *
  101265. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101266. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101267. * @param activeCamera The camera we are returning the max for
  101268. * @returns the depth max z
  101269. */
  101270. getDepthMaxZ(activeCamera: Camera): number;
  101271. /**
  101272. * Prepares the list of defines specific to the light type.
  101273. * @param defines the list of defines
  101274. * @param lightIndex defines the index of the light for the effect
  101275. */
  101276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101277. }
  101278. }
  101279. declare module BABYLON {
  101280. /**
  101281. * A point light is a light defined by an unique point in world space.
  101282. * The light is emitted in every direction from this point.
  101283. * A good example of a point light is a standard light bulb.
  101284. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101285. */
  101286. export class PointLight extends ShadowLight {
  101287. private _shadowAngle;
  101288. /**
  101289. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101290. * This specifies what angle the shadow will use to be created.
  101291. *
  101292. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101293. */
  101294. /**
  101295. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101296. * This specifies what angle the shadow will use to be created.
  101297. *
  101298. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101299. */
  101300. shadowAngle: number;
  101301. /**
  101302. * Gets the direction if it has been set.
  101303. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101304. */
  101305. /**
  101306. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101307. */
  101308. direction: Vector3;
  101309. /**
  101310. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101311. * A PointLight emits the light in every direction.
  101312. * It can cast shadows.
  101313. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101314. * ```javascript
  101315. * var pointLight = new PointLight("pl", camera.position, scene);
  101316. * ```
  101317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101318. * @param name The light friendly name
  101319. * @param position The position of the point light in the scene
  101320. * @param scene The scene the lights belongs to
  101321. */
  101322. constructor(name: string, position: Vector3, scene: Scene);
  101323. /**
  101324. * Returns the string "PointLight"
  101325. * @returns the class name
  101326. */
  101327. getClassName(): string;
  101328. /**
  101329. * Returns the integer 0.
  101330. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101331. */
  101332. getTypeID(): number;
  101333. /**
  101334. * Specifies wether or not the shadowmap should be a cube texture.
  101335. * @returns true if the shadowmap needs to be a cube texture.
  101336. */
  101337. needCube(): boolean;
  101338. /**
  101339. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101340. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101341. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101342. */
  101343. getShadowDirection(faceIndex?: number): Vector3;
  101344. /**
  101345. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101346. * - fov = PI / 2
  101347. * - aspect ratio : 1.0
  101348. * - z-near and far equal to the active camera minZ and maxZ.
  101349. * Returns the PointLight.
  101350. */
  101351. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101352. protected _buildUniformLayout(): void;
  101353. /**
  101354. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101355. * @param effect The effect to update
  101356. * @param lightIndex The index of the light in the effect to update
  101357. * @returns The point light
  101358. */
  101359. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101360. /**
  101361. * Prepares the list of defines specific to the light type.
  101362. * @param defines the list of defines
  101363. * @param lightIndex defines the index of the light for the effect
  101364. */
  101365. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101366. }
  101367. }
  101368. declare module BABYLON {
  101369. /**
  101370. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101371. * These values define a cone of light starting from the position, emitting toward the direction.
  101372. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101373. * and the exponent defines the speed of the decay of the light with distance (reach).
  101374. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101375. */
  101376. export class SpotLight extends ShadowLight {
  101377. private _angle;
  101378. private _innerAngle;
  101379. private _cosHalfAngle;
  101380. private _lightAngleScale;
  101381. private _lightAngleOffset;
  101382. /**
  101383. * Gets the cone angle of the spot light in Radians.
  101384. */
  101385. /**
  101386. * Sets the cone angle of the spot light in Radians.
  101387. */
  101388. angle: number;
  101389. /**
  101390. * Only used in gltf falloff mode, this defines the angle where
  101391. * the directional falloff will start before cutting at angle which could be seen
  101392. * as outer angle.
  101393. */
  101394. /**
  101395. * Only used in gltf falloff mode, this defines the angle where
  101396. * the directional falloff will start before cutting at angle which could be seen
  101397. * as outer angle.
  101398. */
  101399. innerAngle: number;
  101400. private _shadowAngleScale;
  101401. /**
  101402. * Allows scaling the angle of the light for shadow generation only.
  101403. */
  101404. /**
  101405. * Allows scaling the angle of the light for shadow generation only.
  101406. */
  101407. shadowAngleScale: number;
  101408. /**
  101409. * The light decay speed with the distance from the emission spot.
  101410. */
  101411. exponent: number;
  101412. private _projectionTextureMatrix;
  101413. /**
  101414. * Allows reading the projecton texture
  101415. */
  101416. readonly projectionTextureMatrix: Matrix;
  101417. protected _projectionTextureLightNear: number;
  101418. /**
  101419. * Gets the near clip of the Spotlight for texture projection.
  101420. */
  101421. /**
  101422. * Sets the near clip of the Spotlight for texture projection.
  101423. */
  101424. projectionTextureLightNear: number;
  101425. protected _projectionTextureLightFar: number;
  101426. /**
  101427. * Gets the far clip of the Spotlight for texture projection.
  101428. */
  101429. /**
  101430. * Sets the far clip of the Spotlight for texture projection.
  101431. */
  101432. projectionTextureLightFar: number;
  101433. protected _projectionTextureUpDirection: Vector3;
  101434. /**
  101435. * Gets the Up vector of the Spotlight for texture projection.
  101436. */
  101437. /**
  101438. * Sets the Up vector of the Spotlight for texture projection.
  101439. */
  101440. projectionTextureUpDirection: Vector3;
  101441. private _projectionTexture;
  101442. /**
  101443. * Gets the projection texture of the light.
  101444. */
  101445. /**
  101446. * Sets the projection texture of the light.
  101447. */
  101448. projectionTexture: Nullable<BaseTexture>;
  101449. private _projectionTextureViewLightDirty;
  101450. private _projectionTextureProjectionLightDirty;
  101451. private _projectionTextureDirty;
  101452. private _projectionTextureViewTargetVector;
  101453. private _projectionTextureViewLightMatrix;
  101454. private _projectionTextureProjectionLightMatrix;
  101455. private _projectionTextureScalingMatrix;
  101456. /**
  101457. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101458. * It can cast shadows.
  101459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101460. * @param name The light friendly name
  101461. * @param position The position of the spot light in the scene
  101462. * @param direction The direction of the light in the scene
  101463. * @param angle The cone angle of the light in Radians
  101464. * @param exponent The light decay speed with the distance from the emission spot
  101465. * @param scene The scene the lights belongs to
  101466. */
  101467. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101468. /**
  101469. * Returns the string "SpotLight".
  101470. * @returns the class name
  101471. */
  101472. getClassName(): string;
  101473. /**
  101474. * Returns the integer 2.
  101475. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101476. */
  101477. getTypeID(): number;
  101478. /**
  101479. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101480. */
  101481. protected _setDirection(value: Vector3): void;
  101482. /**
  101483. * Overrides the position setter to recompute the projection texture view light Matrix.
  101484. */
  101485. protected _setPosition(value: Vector3): void;
  101486. /**
  101487. * 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.
  101488. * Returns the SpotLight.
  101489. */
  101490. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101491. protected _computeProjectionTextureViewLightMatrix(): void;
  101492. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101493. /**
  101494. * Main function for light texture projection matrix computing.
  101495. */
  101496. protected _computeProjectionTextureMatrix(): void;
  101497. protected _buildUniformLayout(): void;
  101498. private _computeAngleValues;
  101499. /**
  101500. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101501. * @param effect The effect to update
  101502. * @param lightIndex The index of the light in the effect to update
  101503. * @returns The spot light
  101504. */
  101505. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101506. /**
  101507. * Disposes the light and the associated resources.
  101508. */
  101509. dispose(): void;
  101510. /**
  101511. * Prepares the list of defines specific to the light type.
  101512. * @param defines the list of defines
  101513. * @param lightIndex defines the index of the light for the effect
  101514. */
  101515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101516. }
  101517. }
  101518. declare module BABYLON {
  101519. /**
  101520. * Header information of HDR texture files.
  101521. */
  101522. export interface HDRInfo {
  101523. /**
  101524. * The height of the texture in pixels.
  101525. */
  101526. height: number;
  101527. /**
  101528. * The width of the texture in pixels.
  101529. */
  101530. width: number;
  101531. /**
  101532. * The index of the beginning of the data in the binary file.
  101533. */
  101534. dataPosition: number;
  101535. }
  101536. /**
  101537. * This groups tools to convert HDR texture to native colors array.
  101538. */
  101539. export class HDRTools {
  101540. private static Ldexp;
  101541. private static Rgbe2float;
  101542. private static readStringLine;
  101543. /**
  101544. * Reads header information from an RGBE texture stored in a native array.
  101545. * More information on this format are available here:
  101546. * https://en.wikipedia.org/wiki/RGBE_image_format
  101547. *
  101548. * @param uint8array The binary file stored in native array.
  101549. * @return The header information.
  101550. */
  101551. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101552. /**
  101553. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101554. * This RGBE texture needs to store the information as a panorama.
  101555. *
  101556. * More information on this format are available here:
  101557. * https://en.wikipedia.org/wiki/RGBE_image_format
  101558. *
  101559. * @param buffer The binary file stored in an array buffer.
  101560. * @param size The expected size of the extracted cubemap.
  101561. * @return The Cube Map information.
  101562. */
  101563. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101564. /**
  101565. * Returns the pixels data extracted from an RGBE texture.
  101566. * This pixels will be stored left to right up to down in the R G B order in one array.
  101567. *
  101568. * More information on this format are available here:
  101569. * https://en.wikipedia.org/wiki/RGBE_image_format
  101570. *
  101571. * @param uint8array The binary file stored in an array buffer.
  101572. * @param hdrInfo The header information of the file.
  101573. * @return The pixels data in RGB right to left up to down order.
  101574. */
  101575. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101576. private static RGBE_ReadPixels_RLE;
  101577. }
  101578. }
  101579. declare module BABYLON {
  101580. /**
  101581. * This represents a texture coming from an HDR input.
  101582. *
  101583. * The only supported format is currently panorama picture stored in RGBE format.
  101584. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101585. */
  101586. export class HDRCubeTexture extends BaseTexture {
  101587. private static _facesMapping;
  101588. private _generateHarmonics;
  101589. private _noMipmap;
  101590. private _textureMatrix;
  101591. private _size;
  101592. private _onLoad;
  101593. private _onError;
  101594. /**
  101595. * The texture URL.
  101596. */
  101597. url: string;
  101598. /**
  101599. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101600. */
  101601. coordinatesMode: number;
  101602. protected _isBlocking: boolean;
  101603. /**
  101604. * Sets wether or not the texture is blocking during loading.
  101605. */
  101606. /**
  101607. * Gets wether or not the texture is blocking during loading.
  101608. */
  101609. isBlocking: boolean;
  101610. protected _rotationY: number;
  101611. /**
  101612. * Sets texture matrix rotation angle around Y axis in radians.
  101613. */
  101614. /**
  101615. * Gets texture matrix rotation angle around Y axis radians.
  101616. */
  101617. rotationY: number;
  101618. /**
  101619. * Gets or sets the center of the bounding box associated with the cube texture
  101620. * It must define where the camera used to render the texture was set
  101621. */
  101622. boundingBoxPosition: Vector3;
  101623. private _boundingBoxSize;
  101624. /**
  101625. * Gets or sets the size of the bounding box associated with the cube texture
  101626. * When defined, the cubemap will switch to local mode
  101627. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101628. * @example https://www.babylonjs-playground.com/#RNASML
  101629. */
  101630. boundingBoxSize: Vector3;
  101631. /**
  101632. * Instantiates an HDRTexture from the following parameters.
  101633. *
  101634. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101635. * @param scene The scene the texture will be used in
  101636. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101637. * @param noMipmap Forces to not generate the mipmap if true
  101638. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101639. * @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)
  101640. * @param reserved Reserved flag for internal use.
  101641. */
  101642. 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>);
  101643. /**
  101644. * Get the current class name of the texture useful for serialization or dynamic coding.
  101645. * @returns "HDRCubeTexture"
  101646. */
  101647. getClassName(): string;
  101648. /**
  101649. * Occurs when the file is raw .hdr file.
  101650. */
  101651. private loadTexture;
  101652. clone(): HDRCubeTexture;
  101653. delayLoad(): void;
  101654. /**
  101655. * Get the texture reflection matrix used to rotate/transform the reflection.
  101656. * @returns the reflection matrix
  101657. */
  101658. getReflectionTextureMatrix(): Matrix;
  101659. /**
  101660. * Set the texture reflection matrix used to rotate/transform the reflection.
  101661. * @param value Define the reflection matrix to set
  101662. */
  101663. setReflectionTextureMatrix(value: Matrix): void;
  101664. /**
  101665. * Parses a JSON representation of an HDR Texture in order to create the texture
  101666. * @param parsedTexture Define the JSON representation
  101667. * @param scene Define the scene the texture should be created in
  101668. * @param rootUrl Define the root url in case we need to load relative dependencies
  101669. * @returns the newly created texture after parsing
  101670. */
  101671. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101672. serialize(): any;
  101673. }
  101674. }
  101675. declare module BABYLON {
  101676. /**
  101677. * Class used to control physics engine
  101678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101679. */
  101680. export class PhysicsEngine implements IPhysicsEngine {
  101681. private _physicsPlugin;
  101682. /**
  101683. * Global value used to control the smallest number supported by the simulation
  101684. */
  101685. static Epsilon: number;
  101686. private _impostors;
  101687. private _joints;
  101688. /**
  101689. * Gets the gravity vector used by the simulation
  101690. */
  101691. gravity: Vector3;
  101692. /**
  101693. * Factory used to create the default physics plugin.
  101694. * @returns The default physics plugin
  101695. */
  101696. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101697. /**
  101698. * Creates a new Physics Engine
  101699. * @param gravity defines the gravity vector used by the simulation
  101700. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101701. */
  101702. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101703. /**
  101704. * Sets the gravity vector used by the simulation
  101705. * @param gravity defines the gravity vector to use
  101706. */
  101707. setGravity(gravity: Vector3): void;
  101708. /**
  101709. * Set the time step of the physics engine.
  101710. * Default is 1/60.
  101711. * To slow it down, enter 1/600 for example.
  101712. * To speed it up, 1/30
  101713. * @param newTimeStep defines the new timestep to apply to this world.
  101714. */
  101715. setTimeStep(newTimeStep?: number): void;
  101716. /**
  101717. * Get the time step of the physics engine.
  101718. * @returns the current time step
  101719. */
  101720. getTimeStep(): number;
  101721. /**
  101722. * Release all resources
  101723. */
  101724. dispose(): void;
  101725. /**
  101726. * Gets the name of the current physics plugin
  101727. * @returns the name of the plugin
  101728. */
  101729. getPhysicsPluginName(): string;
  101730. /**
  101731. * Adding a new impostor for the impostor tracking.
  101732. * This will be done by the impostor itself.
  101733. * @param impostor the impostor to add
  101734. */
  101735. addImpostor(impostor: PhysicsImpostor): void;
  101736. /**
  101737. * Remove an impostor from the engine.
  101738. * This impostor and its mesh will not longer be updated by the physics engine.
  101739. * @param impostor the impostor to remove
  101740. */
  101741. removeImpostor(impostor: PhysicsImpostor): void;
  101742. /**
  101743. * Add a joint to the physics engine
  101744. * @param mainImpostor defines the main impostor to which the joint is added.
  101745. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101746. * @param joint defines the joint that will connect both impostors.
  101747. */
  101748. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101749. /**
  101750. * Removes a joint from the simulation
  101751. * @param mainImpostor defines the impostor used with the joint
  101752. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101753. * @param joint defines the joint to remove
  101754. */
  101755. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101756. /**
  101757. * Called by the scene. No need to call it.
  101758. * @param delta defines the timespam between frames
  101759. */
  101760. _step(delta: number): void;
  101761. /**
  101762. * Gets the current plugin used to run the simulation
  101763. * @returns current plugin
  101764. */
  101765. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101766. /**
  101767. * Gets the list of physic impostors
  101768. * @returns an array of PhysicsImpostor
  101769. */
  101770. getImpostors(): Array<PhysicsImpostor>;
  101771. /**
  101772. * Gets the impostor for a physics enabled object
  101773. * @param object defines the object impersonated by the impostor
  101774. * @returns the PhysicsImpostor or null if not found
  101775. */
  101776. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101777. /**
  101778. * Gets the impostor for a physics body object
  101779. * @param body defines physics body used by the impostor
  101780. * @returns the PhysicsImpostor or null if not found
  101781. */
  101782. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101783. }
  101784. }
  101785. declare module BABYLON {
  101786. /** @hidden */
  101787. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101788. private _useDeltaForWorldStep;
  101789. world: any;
  101790. name: string;
  101791. private _physicsMaterials;
  101792. private _fixedTimeStep;
  101793. BJSCANNON: any;
  101794. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101795. setGravity(gravity: Vector3): void;
  101796. setTimeStep(timeStep: number): void;
  101797. getTimeStep(): number;
  101798. executeStep(delta: number): void;
  101799. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101800. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101801. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101802. private _processChildMeshes;
  101803. removePhysicsBody(impostor: PhysicsImpostor): void;
  101804. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101805. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101806. private _addMaterial;
  101807. private _checkWithEpsilon;
  101808. private _createShape;
  101809. private _createHeightmap;
  101810. private _minus90X;
  101811. private _plus90X;
  101812. private _tmpPosition;
  101813. private _tmpDeltaPosition;
  101814. private _tmpUnityRotation;
  101815. private _updatePhysicsBodyTransformation;
  101816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101818. isSupported(): boolean;
  101819. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101820. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101822. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101824. getBodyMass(impostor: PhysicsImpostor): number;
  101825. getBodyFriction(impostor: PhysicsImpostor): number;
  101826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101827. getBodyRestitution(impostor: PhysicsImpostor): number;
  101828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101829. sleepBody(impostor: PhysicsImpostor): void;
  101830. wakeUpBody(impostor: PhysicsImpostor): void;
  101831. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101832. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101835. getRadius(impostor: PhysicsImpostor): number;
  101836. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101837. dispose(): void;
  101838. private _extendNamespace;
  101839. }
  101840. }
  101841. declare module BABYLON {
  101842. /** @hidden */
  101843. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101844. world: any;
  101845. name: string;
  101846. BJSOIMO: any;
  101847. constructor(iterations?: number, oimoInjection?: any);
  101848. setGravity(gravity: Vector3): void;
  101849. setTimeStep(timeStep: number): void;
  101850. getTimeStep(): number;
  101851. private _tmpImpostorsArray;
  101852. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101853. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101854. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101855. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101856. private _tmpPositionVector;
  101857. removePhysicsBody(impostor: PhysicsImpostor): void;
  101858. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101859. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101860. isSupported(): boolean;
  101861. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101862. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101863. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101864. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101865. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101866. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101867. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101868. getBodyMass(impostor: PhysicsImpostor): number;
  101869. getBodyFriction(impostor: PhysicsImpostor): number;
  101870. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101871. getBodyRestitution(impostor: PhysicsImpostor): number;
  101872. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101873. sleepBody(impostor: PhysicsImpostor): void;
  101874. wakeUpBody(impostor: PhysicsImpostor): void;
  101875. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101876. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  101877. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101878. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101879. getRadius(impostor: PhysicsImpostor): number;
  101880. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101881. dispose(): void;
  101882. }
  101883. }
  101884. declare module BABYLON {
  101885. interface AbstractScene {
  101886. /**
  101887. * The list of reflection probes added to the scene
  101888. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101889. */
  101890. reflectionProbes: Array<ReflectionProbe>;
  101891. /**
  101892. * Removes the given reflection probe from this scene.
  101893. * @param toRemove The reflection probe to remove
  101894. * @returns The index of the removed reflection probe
  101895. */
  101896. removeReflectionProbe(toRemove: ReflectionProbe): number;
  101897. /**
  101898. * Adds the given reflection probe to this scene.
  101899. * @param newReflectionProbe The reflection probe to add
  101900. */
  101901. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  101902. }
  101903. /**
  101904. * Class used to generate realtime reflection / refraction cube textures
  101905. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101906. */
  101907. export class ReflectionProbe {
  101908. /** defines the name of the probe */
  101909. name: string;
  101910. private _scene;
  101911. private _renderTargetTexture;
  101912. private _projectionMatrix;
  101913. private _viewMatrix;
  101914. private _target;
  101915. private _add;
  101916. private _attachedMesh;
  101917. private _invertYAxis;
  101918. /** Gets or sets probe position (center of the cube map) */
  101919. position: Vector3;
  101920. /**
  101921. * Creates a new reflection probe
  101922. * @param name defines the name of the probe
  101923. * @param size defines the texture resolution (for each face)
  101924. * @param scene defines the hosting scene
  101925. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  101926. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  101927. */
  101928. constructor(
  101929. /** defines the name of the probe */
  101930. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  101931. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  101932. samples: number;
  101933. /** Gets or sets the refresh rate to use (on every frame by default) */
  101934. refreshRate: number;
  101935. /**
  101936. * Gets the hosting scene
  101937. * @returns a Scene
  101938. */
  101939. getScene(): Scene;
  101940. /** Gets the internal CubeTexture used to render to */
  101941. readonly cubeTexture: RenderTargetTexture;
  101942. /** Gets the list of meshes to render */
  101943. readonly renderList: Nullable<AbstractMesh[]>;
  101944. /**
  101945. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  101946. * @param mesh defines the mesh to attach to
  101947. */
  101948. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101949. /**
  101950. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  101951. * @param renderingGroupId The rendering group id corresponding to its index
  101952. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101953. */
  101954. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101955. /**
  101956. * Clean all associated resources
  101957. */
  101958. dispose(): void;
  101959. /**
  101960. * Converts the reflection probe information to a readable string for debug purpose.
  101961. * @param fullDetails Supports for multiple levels of logging within scene loading
  101962. * @returns the human readable reflection probe info
  101963. */
  101964. toString(fullDetails?: boolean): string;
  101965. /**
  101966. * Get the class name of the relfection probe.
  101967. * @returns "ReflectionProbe"
  101968. */
  101969. getClassName(): string;
  101970. /**
  101971. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  101972. * @returns The JSON representation of the texture
  101973. */
  101974. serialize(): any;
  101975. /**
  101976. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  101977. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  101978. * @param scene Define the scene the parsed reflection probe should be instantiated in
  101979. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101980. * @returns The parsed reflection probe if successful
  101981. */
  101982. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  101983. }
  101984. }
  101985. declare module BABYLON {
  101986. /** @hidden */
  101987. export var _BabylonLoaderRegistered: boolean;
  101988. }
  101989. declare module BABYLON {
  101990. /**
  101991. * The Physically based simple base material of BJS.
  101992. *
  101993. * This enables better naming and convention enforcements on top of the pbrMaterial.
  101994. * It is used as the base class for both the specGloss and metalRough conventions.
  101995. */
  101996. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  101997. /**
  101998. * Number of Simultaneous lights allowed on the material.
  101999. */
  102000. maxSimultaneousLights: number;
  102001. /**
  102002. * If sets to true, disables all the lights affecting the material.
  102003. */
  102004. disableLighting: boolean;
  102005. /**
  102006. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  102007. */
  102008. environmentTexture: BaseTexture;
  102009. /**
  102010. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102011. */
  102012. invertNormalMapX: boolean;
  102013. /**
  102014. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102015. */
  102016. invertNormalMapY: boolean;
  102017. /**
  102018. * Normal map used in the model.
  102019. */
  102020. normalTexture: BaseTexture;
  102021. /**
  102022. * Emissivie color used to self-illuminate the model.
  102023. */
  102024. emissiveColor: Color3;
  102025. /**
  102026. * Emissivie texture used to self-illuminate the model.
  102027. */
  102028. emissiveTexture: BaseTexture;
  102029. /**
  102030. * Occlusion Channel Strenght.
  102031. */
  102032. occlusionStrength: number;
  102033. /**
  102034. * Occlusion Texture of the material (adding extra occlusion effects).
  102035. */
  102036. occlusionTexture: BaseTexture;
  102037. /**
  102038. * Defines the alpha limits in alpha test mode.
  102039. */
  102040. alphaCutOff: number;
  102041. /**
  102042. * Gets the current double sided mode.
  102043. */
  102044. /**
  102045. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102046. */
  102047. doubleSided: boolean;
  102048. /**
  102049. * Stores the pre-calculated light information of a mesh in a texture.
  102050. */
  102051. lightmapTexture: BaseTexture;
  102052. /**
  102053. * If true, the light map contains occlusion information instead of lighting info.
  102054. */
  102055. useLightmapAsShadowmap: boolean;
  102056. /**
  102057. * Return the active textures of the material.
  102058. */
  102059. getActiveTextures(): BaseTexture[];
  102060. hasTexture(texture: BaseTexture): boolean;
  102061. /**
  102062. * Instantiates a new PBRMaterial instance.
  102063. *
  102064. * @param name The material name
  102065. * @param scene The scene the material will be use in.
  102066. */
  102067. constructor(name: string, scene: Scene);
  102068. getClassName(): string;
  102069. }
  102070. }
  102071. declare module BABYLON {
  102072. /**
  102073. * The PBR material of BJS following the metal roughness convention.
  102074. *
  102075. * This fits to the PBR convention in the GLTF definition:
  102076. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  102077. */
  102078. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  102079. /**
  102080. * The base color has two different interpretations depending on the value of metalness.
  102081. * When the material is a metal, the base color is the specific measured reflectance value
  102082. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  102083. * of the material.
  102084. */
  102085. baseColor: Color3;
  102086. /**
  102087. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  102088. * well as opacity information in the alpha channel.
  102089. */
  102090. baseTexture: BaseTexture;
  102091. /**
  102092. * Specifies the metallic scalar value of the material.
  102093. * Can also be used to scale the metalness values of the metallic texture.
  102094. */
  102095. metallic: number;
  102096. /**
  102097. * Specifies the roughness scalar value of the material.
  102098. * Can also be used to scale the roughness values of the metallic texture.
  102099. */
  102100. roughness: number;
  102101. /**
  102102. * Texture containing both the metallic value in the B channel and the
  102103. * roughness value in the G channel to keep better precision.
  102104. */
  102105. metallicRoughnessTexture: BaseTexture;
  102106. /**
  102107. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102108. *
  102109. * @param name The material name
  102110. * @param scene The scene the material will be use in.
  102111. */
  102112. constructor(name: string, scene: Scene);
  102113. /**
  102114. * Return the currrent class name of the material.
  102115. */
  102116. getClassName(): string;
  102117. /**
  102118. * Return the active textures of the material.
  102119. */
  102120. getActiveTextures(): BaseTexture[];
  102121. /**
  102122. * Checks to see if a texture is used in the material.
  102123. * @param texture - Base texture to use.
  102124. * @returns - Boolean specifying if a texture is used in the material.
  102125. */
  102126. hasTexture(texture: BaseTexture): boolean;
  102127. /**
  102128. * Makes a duplicate of the current material.
  102129. * @param name - name to use for the new material.
  102130. */
  102131. clone(name: string): PBRMetallicRoughnessMaterial;
  102132. /**
  102133. * Serialize the material to a parsable JSON object.
  102134. */
  102135. serialize(): any;
  102136. /**
  102137. * Parses a JSON object correponding to the serialize function.
  102138. */
  102139. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102140. }
  102141. }
  102142. declare module BABYLON {
  102143. /**
  102144. * The PBR material of BJS following the specular glossiness convention.
  102145. *
  102146. * This fits to the PBR convention in the GLTF definition:
  102147. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102148. */
  102149. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102150. /**
  102151. * Specifies the diffuse color of the material.
  102152. */
  102153. diffuseColor: Color3;
  102154. /**
  102155. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102156. * channel.
  102157. */
  102158. diffuseTexture: BaseTexture;
  102159. /**
  102160. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102161. */
  102162. specularColor: Color3;
  102163. /**
  102164. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102165. */
  102166. glossiness: number;
  102167. /**
  102168. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102169. */
  102170. specularGlossinessTexture: BaseTexture;
  102171. /**
  102172. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102173. *
  102174. * @param name The material name
  102175. * @param scene The scene the material will be use in.
  102176. */
  102177. constructor(name: string, scene: Scene);
  102178. /**
  102179. * Return the currrent class name of the material.
  102180. */
  102181. getClassName(): string;
  102182. /**
  102183. * Return the active textures of the material.
  102184. */
  102185. getActiveTextures(): BaseTexture[];
  102186. /**
  102187. * Checks to see if a texture is used in the material.
  102188. * @param texture - Base texture to use.
  102189. * @returns - Boolean specifying if a texture is used in the material.
  102190. */
  102191. hasTexture(texture: BaseTexture): boolean;
  102192. /**
  102193. * Makes a duplicate of the current material.
  102194. * @param name - name to use for the new material.
  102195. */
  102196. clone(name: string): PBRSpecularGlossinessMaterial;
  102197. /**
  102198. * Serialize the material to a parsable JSON object.
  102199. */
  102200. serialize(): any;
  102201. /**
  102202. * Parses a JSON object correponding to the serialize function.
  102203. */
  102204. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102205. }
  102206. }
  102207. declare module BABYLON {
  102208. /**
  102209. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102210. * It can help converting any input color in a desired output one. This can then be used to create effects
  102211. * from sepia, black and white to sixties or futuristic rendering...
  102212. *
  102213. * The only supported format is currently 3dl.
  102214. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102215. */
  102216. export class ColorGradingTexture extends BaseTexture {
  102217. /**
  102218. * The current texture matrix. (will always be identity in color grading texture)
  102219. */
  102220. private _textureMatrix;
  102221. /**
  102222. * The texture URL.
  102223. */
  102224. url: string;
  102225. /**
  102226. * Empty line regex stored for GC.
  102227. */
  102228. private static _noneEmptyLineRegex;
  102229. private _engine;
  102230. /**
  102231. * Instantiates a ColorGradingTexture from the following parameters.
  102232. *
  102233. * @param url The location of the color gradind data (currently only supporting 3dl)
  102234. * @param scene The scene the texture will be used in
  102235. */
  102236. constructor(url: string, scene: Scene);
  102237. /**
  102238. * Returns the texture matrix used in most of the material.
  102239. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102240. */
  102241. getTextureMatrix(): Matrix;
  102242. /**
  102243. * Occurs when the file being loaded is a .3dl LUT file.
  102244. */
  102245. private load3dlTexture;
  102246. /**
  102247. * Starts the loading process of the texture.
  102248. */
  102249. private loadTexture;
  102250. /**
  102251. * Clones the color gradind texture.
  102252. */
  102253. clone(): ColorGradingTexture;
  102254. /**
  102255. * Called during delayed load for textures.
  102256. */
  102257. delayLoad(): void;
  102258. /**
  102259. * Parses a color grading texture serialized by Babylon.
  102260. * @param parsedTexture The texture information being parsedTexture
  102261. * @param scene The scene to load the texture in
  102262. * @param rootUrl The root url of the data assets to load
  102263. * @return A color gradind texture
  102264. */
  102265. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102266. /**
  102267. * Serializes the LUT texture to json format.
  102268. */
  102269. serialize(): any;
  102270. }
  102271. }
  102272. declare module BABYLON {
  102273. /**
  102274. * Direct draw surface info
  102275. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102276. */
  102277. export interface DDSInfo {
  102278. /**
  102279. * Width of the texture
  102280. */
  102281. width: number;
  102282. /**
  102283. * Width of the texture
  102284. */
  102285. height: number;
  102286. /**
  102287. * Number of Mipmaps for the texture
  102288. * @see https://en.wikipedia.org/wiki/Mipmap
  102289. */
  102290. mipmapCount: number;
  102291. /**
  102292. * If the textures format is a known fourCC format
  102293. * @see https://www.fourcc.org/
  102294. */
  102295. isFourCC: boolean;
  102296. /**
  102297. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102298. */
  102299. isRGB: boolean;
  102300. /**
  102301. * If the texture is a lumincance format
  102302. */
  102303. isLuminance: boolean;
  102304. /**
  102305. * If this is a cube texture
  102306. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102307. */
  102308. isCube: boolean;
  102309. /**
  102310. * If the texture is a compressed format eg. FOURCC_DXT1
  102311. */
  102312. isCompressed: boolean;
  102313. /**
  102314. * The dxgiFormat of the texture
  102315. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102316. */
  102317. dxgiFormat: number;
  102318. /**
  102319. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102320. */
  102321. textureType: number;
  102322. /**
  102323. * Sphericle polynomial created for the dds texture
  102324. */
  102325. sphericalPolynomial?: SphericalPolynomial;
  102326. }
  102327. /**
  102328. * Class used to provide DDS decompression tools
  102329. */
  102330. export class DDSTools {
  102331. /**
  102332. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102333. */
  102334. static StoreLODInAlphaChannel: boolean;
  102335. /**
  102336. * Gets DDS information from an array buffer
  102337. * @param arrayBuffer defines the array buffer to read data from
  102338. * @returns the DDS information
  102339. */
  102340. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102341. private static _FloatView;
  102342. private static _Int32View;
  102343. private static _ToHalfFloat;
  102344. private static _FromHalfFloat;
  102345. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102346. private static _GetHalfFloatRGBAArrayBuffer;
  102347. private static _GetFloatRGBAArrayBuffer;
  102348. private static _GetFloatAsUIntRGBAArrayBuffer;
  102349. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102350. private static _GetRGBAArrayBuffer;
  102351. private static _ExtractLongWordOrder;
  102352. private static _GetRGBArrayBuffer;
  102353. private static _GetLuminanceArrayBuffer;
  102354. /**
  102355. * Uploads DDS Levels to a Babylon Texture
  102356. * @hidden
  102357. */
  102358. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102359. }
  102360. interface Engine {
  102361. /**
  102362. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102363. * @param rootUrl defines the url where the file to load is located
  102364. * @param scene defines the current scene
  102365. * @param lodScale defines scale to apply to the mip map selection
  102366. * @param lodOffset defines offset to apply to the mip map selection
  102367. * @param onLoad defines an optional callback raised when the texture is loaded
  102368. * @param onError defines an optional callback raised if there is an issue to load the texture
  102369. * @param format defines the format of the data
  102370. * @param forcedExtension defines the extension to use to pick the right loader
  102371. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102372. * @returns the cube texture as an InternalTexture
  102373. */
  102374. 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;
  102375. }
  102376. }
  102377. declare module BABYLON {
  102378. /**
  102379. * Implementation of the DDS Texture Loader.
  102380. * @hidden
  102381. */
  102382. export class _DDSTextureLoader implements IInternalTextureLoader {
  102383. /**
  102384. * Defines wether the loader supports cascade loading the different faces.
  102385. */
  102386. readonly supportCascades: boolean;
  102387. /**
  102388. * This returns if the loader support the current file information.
  102389. * @param extension defines the file extension of the file being loaded
  102390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102391. * @param fallback defines the fallback internal texture if any
  102392. * @param isBase64 defines whether the texture is encoded as a base64
  102393. * @param isBuffer defines whether the texture data are stored as a buffer
  102394. * @returns true if the loader can load the specified file
  102395. */
  102396. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102397. /**
  102398. * Transform the url before loading if required.
  102399. * @param rootUrl the url of the texture
  102400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102401. * @returns the transformed texture
  102402. */
  102403. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102404. /**
  102405. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102406. * @param rootUrl the url of the texture
  102407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102408. * @returns the fallback texture
  102409. */
  102410. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102411. /**
  102412. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102413. * @param data contains the texture data
  102414. * @param texture defines the BabylonJS internal texture
  102415. * @param createPolynomials will be true if polynomials have been requested
  102416. * @param onLoad defines the callback to trigger once the texture is ready
  102417. * @param onError defines the callback to trigger in case of error
  102418. */
  102419. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102420. /**
  102421. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102422. * @param data contains the texture data
  102423. * @param texture defines the BabylonJS internal texture
  102424. * @param callback defines the method to call once ready to upload
  102425. */
  102426. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102427. }
  102428. }
  102429. declare module BABYLON {
  102430. /** @hidden */
  102431. export var rgbdEncodePixelShader: {
  102432. name: string;
  102433. shader: string;
  102434. };
  102435. }
  102436. declare module BABYLON {
  102437. /** @hidden */
  102438. export var rgbdDecodePixelShader: {
  102439. name: string;
  102440. shader: string;
  102441. };
  102442. }
  102443. declare module BABYLON {
  102444. /**
  102445. * Raw texture data and descriptor sufficient for WebGL texture upload
  102446. */
  102447. export interface EnvironmentTextureInfo {
  102448. /**
  102449. * Version of the environment map
  102450. */
  102451. version: number;
  102452. /**
  102453. * Width of image
  102454. */
  102455. width: number;
  102456. /**
  102457. * Irradiance information stored in the file.
  102458. */
  102459. irradiance: any;
  102460. /**
  102461. * Specular information stored in the file.
  102462. */
  102463. specular: any;
  102464. }
  102465. /**
  102466. * Sets of helpers addressing the serialization and deserialization of environment texture
  102467. * stored in a BabylonJS env file.
  102468. * Those files are usually stored as .env files.
  102469. */
  102470. export class EnvironmentTextureTools {
  102471. /**
  102472. * Magic number identifying the env file.
  102473. */
  102474. private static _MagicBytes;
  102475. /**
  102476. * Gets the environment info from an env file.
  102477. * @param data The array buffer containing the .env bytes.
  102478. * @returns the environment file info (the json header) if successfully parsed.
  102479. */
  102480. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102481. /**
  102482. * Creates an environment texture from a loaded cube texture.
  102483. * @param texture defines the cube texture to convert in env file
  102484. * @return a promise containing the environment data if succesfull.
  102485. */
  102486. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102487. /**
  102488. * Creates a JSON representation of the spherical data.
  102489. * @param texture defines the texture containing the polynomials
  102490. * @return the JSON representation of the spherical info
  102491. */
  102492. private static _CreateEnvTextureIrradiance;
  102493. /**
  102494. * Uploads the texture info contained in the env file to the GPU.
  102495. * @param texture defines the internal texture to upload to
  102496. * @param arrayBuffer defines the buffer cotaining the data to load
  102497. * @param info defines the texture info retrieved through the GetEnvInfo method
  102498. * @returns a promise
  102499. */
  102500. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102501. /**
  102502. * Uploads the levels of image data to the GPU.
  102503. * @param texture defines the internal texture to upload to
  102504. * @param imageData defines the array buffer views of image data [mipmap][face]
  102505. * @returns a promise
  102506. */
  102507. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102508. /**
  102509. * Uploads spherical polynomials information to the texture.
  102510. * @param texture defines the texture we are trying to upload the information to
  102511. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102512. */
  102513. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102514. /** @hidden */
  102515. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102516. }
  102517. }
  102518. declare module BABYLON {
  102519. /**
  102520. * Implementation of the ENV Texture Loader.
  102521. * @hidden
  102522. */
  102523. export class _ENVTextureLoader implements IInternalTextureLoader {
  102524. /**
  102525. * Defines wether the loader supports cascade loading the different faces.
  102526. */
  102527. readonly supportCascades: boolean;
  102528. /**
  102529. * This returns if the loader support the current file information.
  102530. * @param extension defines the file extension of the file being loaded
  102531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102532. * @param fallback defines the fallback internal texture if any
  102533. * @param isBase64 defines whether the texture is encoded as a base64
  102534. * @param isBuffer defines whether the texture data are stored as a buffer
  102535. * @returns true if the loader can load the specified file
  102536. */
  102537. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102538. /**
  102539. * Transform the url before loading if required.
  102540. * @param rootUrl the url of the texture
  102541. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102542. * @returns the transformed texture
  102543. */
  102544. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102545. /**
  102546. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102547. * @param rootUrl the url of the texture
  102548. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102549. * @returns the fallback texture
  102550. */
  102551. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102552. /**
  102553. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102554. * @param data contains the texture data
  102555. * @param texture defines the BabylonJS internal texture
  102556. * @param createPolynomials will be true if polynomials have been requested
  102557. * @param onLoad defines the callback to trigger once the texture is ready
  102558. * @param onError defines the callback to trigger in case of error
  102559. */
  102560. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102561. /**
  102562. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102563. * @param data contains the texture data
  102564. * @param texture defines the BabylonJS internal texture
  102565. * @param callback defines the method to call once ready to upload
  102566. */
  102567. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102568. }
  102569. }
  102570. declare module BABYLON {
  102571. /**
  102572. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102573. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102574. */
  102575. export class KhronosTextureContainer {
  102576. /** contents of the KTX container file */
  102577. arrayBuffer: any;
  102578. private static HEADER_LEN;
  102579. private static COMPRESSED_2D;
  102580. private static COMPRESSED_3D;
  102581. private static TEX_2D;
  102582. private static TEX_3D;
  102583. /**
  102584. * Gets the openGL type
  102585. */
  102586. glType: number;
  102587. /**
  102588. * Gets the openGL type size
  102589. */
  102590. glTypeSize: number;
  102591. /**
  102592. * Gets the openGL format
  102593. */
  102594. glFormat: number;
  102595. /**
  102596. * Gets the openGL internal format
  102597. */
  102598. glInternalFormat: number;
  102599. /**
  102600. * Gets the base internal format
  102601. */
  102602. glBaseInternalFormat: number;
  102603. /**
  102604. * Gets image width in pixel
  102605. */
  102606. pixelWidth: number;
  102607. /**
  102608. * Gets image height in pixel
  102609. */
  102610. pixelHeight: number;
  102611. /**
  102612. * Gets image depth in pixels
  102613. */
  102614. pixelDepth: number;
  102615. /**
  102616. * Gets the number of array elements
  102617. */
  102618. numberOfArrayElements: number;
  102619. /**
  102620. * Gets the number of faces
  102621. */
  102622. numberOfFaces: number;
  102623. /**
  102624. * Gets the number of mipmap levels
  102625. */
  102626. numberOfMipmapLevels: number;
  102627. /**
  102628. * Gets the bytes of key value data
  102629. */
  102630. bytesOfKeyValueData: number;
  102631. /**
  102632. * Gets the load type
  102633. */
  102634. loadType: number;
  102635. /**
  102636. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102637. */
  102638. isInvalid: boolean;
  102639. /**
  102640. * Creates a new KhronosTextureContainer
  102641. * @param arrayBuffer contents of the KTX container file
  102642. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102643. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102644. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102645. */
  102646. constructor(
  102647. /** contents of the KTX container file */
  102648. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102649. /**
  102650. * Uploads KTX content to a Babylon Texture.
  102651. * It is assumed that the texture has already been created & is currently bound
  102652. * @hidden
  102653. */
  102654. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102655. private _upload2DCompressedLevels;
  102656. }
  102657. }
  102658. declare module BABYLON {
  102659. /**
  102660. * Implementation of the KTX Texture Loader.
  102661. * @hidden
  102662. */
  102663. export class _KTXTextureLoader implements IInternalTextureLoader {
  102664. /**
  102665. * Defines wether the loader supports cascade loading the different faces.
  102666. */
  102667. readonly supportCascades: boolean;
  102668. /**
  102669. * This returns if the loader support the current file information.
  102670. * @param extension defines the file extension of the file being loaded
  102671. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102672. * @param fallback defines the fallback internal texture if any
  102673. * @param isBase64 defines whether the texture is encoded as a base64
  102674. * @param isBuffer defines whether the texture data are stored as a buffer
  102675. * @returns true if the loader can load the specified file
  102676. */
  102677. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102678. /**
  102679. * Transform the url before loading if required.
  102680. * @param rootUrl the url of the texture
  102681. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102682. * @returns the transformed texture
  102683. */
  102684. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102685. /**
  102686. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102687. * @param rootUrl the url of the texture
  102688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102689. * @returns the fallback texture
  102690. */
  102691. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102692. /**
  102693. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102694. * @param data contains the texture data
  102695. * @param texture defines the BabylonJS internal texture
  102696. * @param createPolynomials will be true if polynomials have been requested
  102697. * @param onLoad defines the callback to trigger once the texture is ready
  102698. * @param onError defines the callback to trigger in case of error
  102699. */
  102700. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102701. /**
  102702. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102703. * @param data contains the texture data
  102704. * @param texture defines the BabylonJS internal texture
  102705. * @param callback defines the method to call once ready to upload
  102706. */
  102707. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * Based on jsTGALoader - Javascript loader for TGA file
  102713. * By Vincent Thibault
  102714. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102715. */
  102716. export class TGATools {
  102717. private static _TYPE_INDEXED;
  102718. private static _TYPE_RGB;
  102719. private static _TYPE_GREY;
  102720. private static _TYPE_RLE_INDEXED;
  102721. private static _TYPE_RLE_RGB;
  102722. private static _TYPE_RLE_GREY;
  102723. private static _ORIGIN_MASK;
  102724. private static _ORIGIN_SHIFT;
  102725. private static _ORIGIN_BL;
  102726. private static _ORIGIN_BR;
  102727. private static _ORIGIN_UL;
  102728. private static _ORIGIN_UR;
  102729. /**
  102730. * Gets the header of a TGA file
  102731. * @param data defines the TGA data
  102732. * @returns the header
  102733. */
  102734. static GetTGAHeader(data: Uint8Array): any;
  102735. /**
  102736. * Uploads TGA content to a Babylon Texture
  102737. * @hidden
  102738. */
  102739. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102740. /** @hidden */
  102741. 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;
  102742. /** @hidden */
  102743. 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;
  102744. /** @hidden */
  102745. 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;
  102746. /** @hidden */
  102747. 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;
  102748. /** @hidden */
  102749. 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;
  102750. /** @hidden */
  102751. 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;
  102752. }
  102753. }
  102754. declare module BABYLON {
  102755. /**
  102756. * Implementation of the TGA Texture Loader.
  102757. * @hidden
  102758. */
  102759. export class _TGATextureLoader implements IInternalTextureLoader {
  102760. /**
  102761. * Defines wether the loader supports cascade loading the different faces.
  102762. */
  102763. readonly supportCascades: boolean;
  102764. /**
  102765. * This returns if the loader support the current file information.
  102766. * @param extension defines the file extension of the file being loaded
  102767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102768. * @param fallback defines the fallback internal texture if any
  102769. * @param isBase64 defines whether the texture is encoded as a base64
  102770. * @param isBuffer defines whether the texture data are stored as a buffer
  102771. * @returns true if the loader can load the specified file
  102772. */
  102773. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102774. /**
  102775. * Transform the url before loading if required.
  102776. * @param rootUrl the url of the texture
  102777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102778. * @returns the transformed texture
  102779. */
  102780. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102781. /**
  102782. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102783. * @param rootUrl the url of the texture
  102784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102785. * @returns the fallback texture
  102786. */
  102787. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102788. /**
  102789. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102790. * @param data contains the texture data
  102791. * @param texture defines the BabylonJS internal texture
  102792. * @param createPolynomials will be true if polynomials have been requested
  102793. * @param onLoad defines the callback to trigger once the texture is ready
  102794. * @param onError defines the callback to trigger in case of error
  102795. */
  102796. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102797. /**
  102798. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102799. * @param data contains the texture data
  102800. * @param texture defines the BabylonJS internal texture
  102801. * @param callback defines the method to call once ready to upload
  102802. */
  102803. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102804. }
  102805. }
  102806. declare module BABYLON {
  102807. /**
  102808. * 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.
  102809. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102810. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102811. */
  102812. export class CustomProceduralTexture extends ProceduralTexture {
  102813. private _animate;
  102814. private _time;
  102815. private _config;
  102816. private _texturePath;
  102817. /**
  102818. * Instantiates a new Custom Procedural Texture.
  102819. * 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.
  102820. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102821. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102822. * @param name Define the name of the texture
  102823. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102824. * @param size Define the size of the texture to create
  102825. * @param scene Define the scene the texture belongs to
  102826. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102827. * @param generateMipMaps Define if the texture should creates mip maps or not
  102828. */
  102829. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102830. private _loadJson;
  102831. /**
  102832. * Is the texture ready to be used ? (rendered at least once)
  102833. * @returns true if ready, otherwise, false.
  102834. */
  102835. isReady(): boolean;
  102836. /**
  102837. * Render the texture to its associated render target.
  102838. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102839. */
  102840. render(useCameraPostProcess?: boolean): void;
  102841. /**
  102842. * Update the list of dependant textures samplers in the shader.
  102843. */
  102844. updateTextures(): void;
  102845. /**
  102846. * Update the uniform values of the procedural texture in the shader.
  102847. */
  102848. updateShaderUniforms(): void;
  102849. /**
  102850. * Define if the texture animates or not.
  102851. */
  102852. animate: boolean;
  102853. }
  102854. }
  102855. declare module BABYLON {
  102856. /** @hidden */
  102857. export var noisePixelShader: {
  102858. name: string;
  102859. shader: string;
  102860. };
  102861. }
  102862. declare module BABYLON {
  102863. /**
  102864. * Class used to generate noise procedural textures
  102865. */
  102866. export class NoiseProceduralTexture extends ProceduralTexture {
  102867. private _time;
  102868. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102869. brightness: number;
  102870. /** Defines the number of octaves to process */
  102871. octaves: number;
  102872. /** Defines the level of persistence (0.8 by default) */
  102873. persistence: number;
  102874. /** Gets or sets animation speed factor (default is 1) */
  102875. animationSpeedFactor: number;
  102876. /**
  102877. * Creates a new NoiseProceduralTexture
  102878. * @param name defines the name fo the texture
  102879. * @param size defines the size of the texture (default is 256)
  102880. * @param scene defines the hosting scene
  102881. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  102882. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  102883. */
  102884. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102885. private _updateShaderUniforms;
  102886. protected _getDefines(): string;
  102887. /** Generate the current state of the procedural texture */
  102888. render(useCameraPostProcess?: boolean): void;
  102889. /**
  102890. * Serializes this noise procedural texture
  102891. * @returns a serialized noise procedural texture object
  102892. */
  102893. serialize(): any;
  102894. /**
  102895. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  102896. * @param parsedTexture defines parsed texture data
  102897. * @param scene defines the current scene
  102898. * @param rootUrl defines the root URL containing noise procedural texture information
  102899. * @returns a parsed NoiseProceduralTexture
  102900. */
  102901. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  102902. }
  102903. }
  102904. declare module BABYLON {
  102905. /**
  102906. * Raw cube texture where the raw buffers are passed in
  102907. */
  102908. export class RawCubeTexture extends CubeTexture {
  102909. /**
  102910. * Creates a cube texture where the raw buffers are passed in.
  102911. * @param scene defines the scene the texture is attached to
  102912. * @param data defines the array of data to use to create each face
  102913. * @param size defines the size of the textures
  102914. * @param format defines the format of the data
  102915. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102916. * @param generateMipMaps defines if the engine should generate the mip levels
  102917. * @param invertY defines if data must be stored with Y axis inverted
  102918. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102919. * @param compression defines the compression used (null by default)
  102920. */
  102921. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  102922. /**
  102923. * Updates the raw cube texture.
  102924. * @param data defines the data to store
  102925. * @param format defines the data format
  102926. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102927. * @param invertY defines if data must be stored with Y axis inverted
  102928. * @param compression defines the compression used (null by default)
  102929. * @param level defines which level of the texture to update
  102930. */
  102931. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  102932. /**
  102933. * Updates a raw cube texture with RGBD encoded data.
  102934. * @param data defines the array of data [mipmap][face] to use to create each face
  102935. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  102936. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  102937. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  102938. * @returns a promsie that resolves when the operation is complete
  102939. */
  102940. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  102941. /**
  102942. * Clones the raw cube texture.
  102943. * @return a new cube texture
  102944. */
  102945. clone(): CubeTexture;
  102946. /** @hidden */
  102947. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102948. }
  102949. }
  102950. declare module BABYLON {
  102951. /**
  102952. * Class used to store 3D textures containing user data
  102953. */
  102954. export class RawTexture3D extends Texture {
  102955. /** Gets or sets the texture format to use */
  102956. format: number;
  102957. private _engine;
  102958. /**
  102959. * Create a new RawTexture3D
  102960. * @param data defines the data of the texture
  102961. * @param width defines the width of the texture
  102962. * @param height defines the height of the texture
  102963. * @param depth defines the depth of the texture
  102964. * @param format defines the texture format to use
  102965. * @param scene defines the hosting scene
  102966. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  102967. * @param invertY defines if texture must be stored with Y axis inverted
  102968. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  102969. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  102970. */
  102971. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  102972. /** Gets or sets the texture format to use */
  102973. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  102974. /**
  102975. * Update the texture with new data
  102976. * @param data defines the data to store in the texture
  102977. */
  102978. update(data: ArrayBufferView): void;
  102979. }
  102980. }
  102981. declare module BABYLON {
  102982. /**
  102983. * Creates a refraction texture used by refraction channel of the standard material.
  102984. * It is like a mirror but to see through a material.
  102985. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102986. */
  102987. export class RefractionTexture extends RenderTargetTexture {
  102988. /**
  102989. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  102990. * 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.
  102991. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102992. */
  102993. refractionPlane: Plane;
  102994. /**
  102995. * Define how deep under the surface we should see.
  102996. */
  102997. depth: number;
  102998. /**
  102999. * Creates a refraction texture used by refraction channel of the standard material.
  103000. * It is like a mirror but to see through a material.
  103001. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103002. * @param name Define the texture name
  103003. * @param size Define the size of the underlying texture
  103004. * @param scene Define the scene the refraction belongs to
  103005. * @param generateMipMaps Define if we need to generate mips level for the refraction
  103006. */
  103007. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  103008. /**
  103009. * Clone the refraction texture.
  103010. * @returns the cloned texture
  103011. */
  103012. clone(): RefractionTexture;
  103013. /**
  103014. * Serialize the texture to a JSON representation you could use in Parse later on
  103015. * @returns the serialized JSON representation
  103016. */
  103017. serialize(): any;
  103018. }
  103019. }
  103020. declare module BABYLON {
  103021. /**
  103022. * Configuration for Draco compression
  103023. */
  103024. export interface IDracoCompressionConfiguration {
  103025. /**
  103026. * Configuration for the decoder.
  103027. */
  103028. decoder?: {
  103029. /**
  103030. * The url to the WebAssembly module.
  103031. */
  103032. wasmUrl?: string;
  103033. /**
  103034. * The url to the WebAssembly binary.
  103035. */
  103036. wasmBinaryUrl?: string;
  103037. /**
  103038. * The url to the fallback JavaScript module.
  103039. */
  103040. fallbackUrl?: string;
  103041. };
  103042. }
  103043. /**
  103044. * Draco compression (https://google.github.io/draco/)
  103045. *
  103046. * This class wraps the Draco module.
  103047. *
  103048. * **Encoder**
  103049. *
  103050. * The encoder is not currently implemented.
  103051. *
  103052. * **Decoder**
  103053. *
  103054. * 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.
  103055. *
  103056. * To update the configuration, use the following code:
  103057. * ```javascript
  103058. * DracoCompression.Configuration = {
  103059. * decoder: {
  103060. * wasmUrl: "<url to the WebAssembly library>",
  103061. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  103062. * fallbackUrl: "<url to the fallback JavaScript library>",
  103063. * }
  103064. * };
  103065. * ```
  103066. *
  103067. * 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.
  103068. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  103069. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  103070. *
  103071. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  103072. * ```javascript
  103073. * var dracoCompression = new DracoCompression();
  103074. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  103075. * [VertexBuffer.PositionKind]: 0
  103076. * });
  103077. * ```
  103078. *
  103079. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  103080. */
  103081. export class DracoCompression implements IDisposable {
  103082. private static _DecoderModulePromise;
  103083. /**
  103084. * The configuration. Defaults to the following urls:
  103085. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  103086. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  103087. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  103088. */
  103089. static Configuration: IDracoCompressionConfiguration;
  103090. /**
  103091. * Returns true if the decoder is available.
  103092. */
  103093. static readonly DecoderAvailable: boolean;
  103094. /**
  103095. * Constructor
  103096. */
  103097. constructor();
  103098. /**
  103099. * Stop all async operations and release resources.
  103100. */
  103101. dispose(): void;
  103102. /**
  103103. * Decode Draco compressed mesh data to vertex data.
  103104. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103105. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103106. * @returns A promise that resolves with the decoded vertex data
  103107. */
  103108. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103109. [kind: string]: number;
  103110. }): Promise<VertexData>;
  103111. private static _GetDecoderModule;
  103112. private static _LoadScriptAsync;
  103113. private static _LoadFileAsync;
  103114. }
  103115. }
  103116. declare module BABYLON {
  103117. /**
  103118. * Class for building Constructive Solid Geometry
  103119. */
  103120. export class CSG {
  103121. private polygons;
  103122. /**
  103123. * The world matrix
  103124. */
  103125. matrix: Matrix;
  103126. /**
  103127. * Stores the position
  103128. */
  103129. position: Vector3;
  103130. /**
  103131. * Stores the rotation
  103132. */
  103133. rotation: Vector3;
  103134. /**
  103135. * Stores the rotation quaternion
  103136. */
  103137. rotationQuaternion: Nullable<Quaternion>;
  103138. /**
  103139. * Stores the scaling vector
  103140. */
  103141. scaling: Vector3;
  103142. /**
  103143. * Convert the Mesh to CSG
  103144. * @param mesh The Mesh to convert to CSG
  103145. * @returns A new CSG from the Mesh
  103146. */
  103147. static FromMesh(mesh: Mesh): CSG;
  103148. /**
  103149. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103150. * @param polygons Polygons used to construct a CSG solid
  103151. */
  103152. private static FromPolygons;
  103153. /**
  103154. * Clones, or makes a deep copy, of the CSG
  103155. * @returns A new CSG
  103156. */
  103157. clone(): CSG;
  103158. /**
  103159. * Unions this CSG with another CSG
  103160. * @param csg The CSG to union against this CSG
  103161. * @returns The unioned CSG
  103162. */
  103163. union(csg: CSG): CSG;
  103164. /**
  103165. * Unions this CSG with another CSG in place
  103166. * @param csg The CSG to union against this CSG
  103167. */
  103168. unionInPlace(csg: CSG): void;
  103169. /**
  103170. * Subtracts this CSG with another CSG
  103171. * @param csg The CSG to subtract against this CSG
  103172. * @returns A new CSG
  103173. */
  103174. subtract(csg: CSG): CSG;
  103175. /**
  103176. * Subtracts this CSG with another CSG in place
  103177. * @param csg The CSG to subtact against this CSG
  103178. */
  103179. subtractInPlace(csg: CSG): void;
  103180. /**
  103181. * Intersect this CSG with another CSG
  103182. * @param csg The CSG to intersect against this CSG
  103183. * @returns A new CSG
  103184. */
  103185. intersect(csg: CSG): CSG;
  103186. /**
  103187. * Intersects this CSG with another CSG in place
  103188. * @param csg The CSG to intersect against this CSG
  103189. */
  103190. intersectInPlace(csg: CSG): void;
  103191. /**
  103192. * Return a new CSG solid with solid and empty space switched. This solid is
  103193. * not modified.
  103194. * @returns A new CSG solid with solid and empty space switched
  103195. */
  103196. inverse(): CSG;
  103197. /**
  103198. * Inverses the CSG in place
  103199. */
  103200. inverseInPlace(): void;
  103201. /**
  103202. * This is used to keep meshes transformations so they can be restored
  103203. * when we build back a Babylon Mesh
  103204. * NB : All CSG operations are performed in world coordinates
  103205. * @param csg The CSG to copy the transform attributes from
  103206. * @returns This CSG
  103207. */
  103208. copyTransformAttributes(csg: CSG): CSG;
  103209. /**
  103210. * Build Raw mesh from CSG
  103211. * Coordinates here are in world space
  103212. * @param name The name of the mesh geometry
  103213. * @param scene The Scene
  103214. * @param keepSubMeshes Specifies if the submeshes should be kept
  103215. * @returns A new Mesh
  103216. */
  103217. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103218. /**
  103219. * Build Mesh from CSG taking material and transforms into account
  103220. * @param name The name of the Mesh
  103221. * @param material The material of the Mesh
  103222. * @param scene The Scene
  103223. * @param keepSubMeshes Specifies if submeshes should be kept
  103224. * @returns The new Mesh
  103225. */
  103226. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103227. }
  103228. }
  103229. declare module BABYLON {
  103230. /**
  103231. * Class containing static functions to help procedurally build meshes
  103232. */
  103233. export class RibbonBuilder {
  103234. /**
  103235. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103236. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103237. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103238. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103239. * * 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
  103240. * * 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
  103241. * * 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
  103242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103245. * * 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
  103246. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103247. * * 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
  103248. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103250. * @param name defines the name of the mesh
  103251. * @param options defines the options used to create the mesh
  103252. * @param scene defines the hosting scene
  103253. * @returns the ribbon mesh
  103254. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103255. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103256. */
  103257. static CreateRibbon(name: string, options: {
  103258. pathArray: Vector3[][];
  103259. closeArray?: boolean;
  103260. closePath?: boolean;
  103261. offset?: number;
  103262. updatable?: boolean;
  103263. sideOrientation?: number;
  103264. frontUVs?: Vector4;
  103265. backUVs?: Vector4;
  103266. instance?: Mesh;
  103267. invertUV?: boolean;
  103268. uvs?: Vector2[];
  103269. colors?: Color4[];
  103270. }, scene?: Nullable<Scene>): Mesh;
  103271. }
  103272. }
  103273. declare module BABYLON {
  103274. /**
  103275. * Class containing static functions to help procedurally build meshes
  103276. */
  103277. export class TorusKnotBuilder {
  103278. /**
  103279. * Creates a torus knot mesh
  103280. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103281. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103282. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103283. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103287. * @param name defines the name of the mesh
  103288. * @param options defines the options used to create the mesh
  103289. * @param scene defines the hosting scene
  103290. * @returns the torus knot mesh
  103291. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103292. */
  103293. static CreateTorusKnot(name: string, options: {
  103294. radius?: number;
  103295. tube?: number;
  103296. radialSegments?: number;
  103297. tubularSegments?: number;
  103298. p?: number;
  103299. q?: number;
  103300. updatable?: boolean;
  103301. sideOrientation?: number;
  103302. frontUVs?: Vector4;
  103303. backUVs?: Vector4;
  103304. }, scene: any): Mesh;
  103305. }
  103306. }
  103307. declare module BABYLON {
  103308. /**
  103309. * Polygon
  103310. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103311. */
  103312. export class Polygon {
  103313. /**
  103314. * Creates a rectangle
  103315. * @param xmin bottom X coord
  103316. * @param ymin bottom Y coord
  103317. * @param xmax top X coord
  103318. * @param ymax top Y coord
  103319. * @returns points that make the resulting rectation
  103320. */
  103321. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103322. /**
  103323. * Creates a circle
  103324. * @param radius radius of circle
  103325. * @param cx scale in x
  103326. * @param cy scale in y
  103327. * @param numberOfSides number of sides that make up the circle
  103328. * @returns points that make the resulting circle
  103329. */
  103330. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103331. /**
  103332. * Creates a polygon from input string
  103333. * @param input Input polygon data
  103334. * @returns the parsed points
  103335. */
  103336. static Parse(input: string): Vector2[];
  103337. /**
  103338. * Starts building a polygon from x and y coordinates
  103339. * @param x x coordinate
  103340. * @param y y coordinate
  103341. * @returns the started path2
  103342. */
  103343. static StartingAt(x: number, y: number): Path2;
  103344. }
  103345. /**
  103346. * Builds a polygon
  103347. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103348. */
  103349. export class PolygonMeshBuilder {
  103350. private _points;
  103351. private _outlinepoints;
  103352. private _holes;
  103353. private _name;
  103354. private _scene;
  103355. private _epoints;
  103356. private _eholes;
  103357. private _addToepoint;
  103358. /**
  103359. * Babylon reference to the earcut plugin.
  103360. */
  103361. bjsEarcut: any;
  103362. /**
  103363. * Creates a PolygonMeshBuilder
  103364. * @param name name of the builder
  103365. * @param contours Path of the polygon
  103366. * @param scene scene to add to
  103367. * @param earcutInjection can be used to inject your own earcut reference
  103368. */
  103369. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103370. /**
  103371. * Adds a whole within the polygon
  103372. * @param hole Array of points defining the hole
  103373. * @returns this
  103374. */
  103375. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103376. /**
  103377. * Creates the polygon
  103378. * @param updatable If the mesh should be updatable
  103379. * @param depth The depth of the mesh created
  103380. * @returns the created mesh
  103381. */
  103382. build(updatable?: boolean, depth?: number): Mesh;
  103383. /**
  103384. * Adds a side to the polygon
  103385. * @param positions points that make the polygon
  103386. * @param normals normals of the polygon
  103387. * @param uvs uvs of the polygon
  103388. * @param indices indices of the polygon
  103389. * @param bounds bounds of the polygon
  103390. * @param points points of the polygon
  103391. * @param depth depth of the polygon
  103392. * @param flip flip of the polygon
  103393. */
  103394. private addSide;
  103395. }
  103396. }
  103397. declare module BABYLON {
  103398. /**
  103399. * Class containing static functions to help procedurally build meshes
  103400. */
  103401. export class PolygonBuilder {
  103402. /**
  103403. * Creates a polygon mesh
  103404. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103405. * * 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
  103406. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103409. * * Remember you can only change the shape positions, not their number when updating a polygon
  103410. * @param name defines the name of the mesh
  103411. * @param options defines the options used to create the mesh
  103412. * @param scene defines the hosting scene
  103413. * @param earcutInjection can be used to inject your own earcut reference
  103414. * @returns the polygon mesh
  103415. */
  103416. static CreatePolygon(name: string, options: {
  103417. shape: Vector3[];
  103418. holes?: Vector3[][];
  103419. depth?: number;
  103420. faceUV?: Vector4[];
  103421. faceColors?: Color4[];
  103422. updatable?: boolean;
  103423. sideOrientation?: number;
  103424. frontUVs?: Vector4;
  103425. backUVs?: Vector4;
  103426. }, scene: Scene, earcutInjection?: any): Mesh;
  103427. /**
  103428. * Creates an extruded polygon mesh, with depth in the Y direction.
  103429. * * 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)
  103430. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103431. * @param name defines the name of the mesh
  103432. * @param options defines the options used to create the mesh
  103433. * @param scene defines the hosting scene
  103434. * @param earcutInjection can be used to inject your own earcut reference
  103435. * @returns the polygon mesh
  103436. */
  103437. static ExtrudePolygon(name: string, options: {
  103438. shape: Vector3[];
  103439. holes?: Vector3[][];
  103440. depth?: number;
  103441. faceUV?: Vector4[];
  103442. faceColors?: Color4[];
  103443. updatable?: boolean;
  103444. sideOrientation?: number;
  103445. frontUVs?: Vector4;
  103446. backUVs?: Vector4;
  103447. }, scene: Scene, earcutInjection?: any): Mesh;
  103448. }
  103449. }
  103450. declare module BABYLON {
  103451. /**
  103452. * Class containing static functions to help procedurally build meshes
  103453. */
  103454. export class ShapeBuilder {
  103455. /**
  103456. * 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.
  103457. * * 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.
  103458. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103459. * * 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.
  103460. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103461. * * 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
  103462. * * 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
  103463. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103468. * @param name defines the name of the mesh
  103469. * @param options defines the options used to create the mesh
  103470. * @param scene defines the hosting scene
  103471. * @returns the extruded shape mesh
  103472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103474. */
  103475. static ExtrudeShape(name: string, options: {
  103476. shape: Vector3[];
  103477. path: Vector3[];
  103478. scale?: number;
  103479. rotation?: number;
  103480. cap?: number;
  103481. updatable?: boolean;
  103482. sideOrientation?: number;
  103483. frontUVs?: Vector4;
  103484. backUVs?: Vector4;
  103485. instance?: Mesh;
  103486. invertUV?: boolean;
  103487. }, scene?: Nullable<Scene>): Mesh;
  103488. /**
  103489. * Creates an custom extruded shape mesh.
  103490. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103491. * * 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.
  103492. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103493. * * 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
  103494. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103495. * * 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
  103496. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103497. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103498. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103499. * * 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
  103500. * * 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
  103501. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103506. * @param name defines the name of the mesh
  103507. * @param options defines the options used to create the mesh
  103508. * @param scene defines the hosting scene
  103509. * @returns the custom extruded shape mesh
  103510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103513. */
  103514. static ExtrudeShapeCustom(name: string, options: {
  103515. shape: Vector3[];
  103516. path: Vector3[];
  103517. scaleFunction?: any;
  103518. rotationFunction?: any;
  103519. ribbonCloseArray?: boolean;
  103520. ribbonClosePath?: boolean;
  103521. cap?: number;
  103522. updatable?: boolean;
  103523. sideOrientation?: number;
  103524. frontUVs?: Vector4;
  103525. backUVs?: Vector4;
  103526. instance?: Mesh;
  103527. invertUV?: boolean;
  103528. }, scene: Scene): Mesh;
  103529. private static _ExtrudeShapeGeneric;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * Class containing static functions to help procedurally build meshes
  103535. */
  103536. export class LatheBuilder {
  103537. /**
  103538. * Creates lathe mesh.
  103539. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103540. * * 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
  103541. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103542. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103543. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103544. * * 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
  103545. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103546. * * 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
  103547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103551. * @param name defines the name of the mesh
  103552. * @param options defines the options used to create the mesh
  103553. * @param scene defines the hosting scene
  103554. * @returns the lathe mesh
  103555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103556. */
  103557. static CreateLathe(name: string, options: {
  103558. shape: Vector3[];
  103559. radius?: number;
  103560. tessellation?: number;
  103561. clip?: number;
  103562. arc?: number;
  103563. closed?: boolean;
  103564. updatable?: boolean;
  103565. sideOrientation?: number;
  103566. frontUVs?: Vector4;
  103567. backUVs?: Vector4;
  103568. cap?: number;
  103569. invertUV?: boolean;
  103570. }, scene: Scene): Mesh;
  103571. }
  103572. }
  103573. declare module BABYLON {
  103574. /**
  103575. * Class containing static functions to help procedurally build meshes
  103576. */
  103577. export class TubeBuilder {
  103578. /**
  103579. * Creates a tube mesh.
  103580. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103581. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103582. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103583. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103584. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103585. * * 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)
  103586. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103587. * * 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
  103588. * * 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
  103589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103593. * @param name defines the name of the mesh
  103594. * @param options defines the options used to create the mesh
  103595. * @param scene defines the hosting scene
  103596. * @returns the tube mesh
  103597. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103598. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103599. */
  103600. static CreateTube(name: string, options: {
  103601. path: Vector3[];
  103602. radius?: number;
  103603. tessellation?: number;
  103604. radiusFunction?: {
  103605. (i: number, distance: number): number;
  103606. };
  103607. cap?: number;
  103608. arc?: number;
  103609. updatable?: boolean;
  103610. sideOrientation?: number;
  103611. frontUVs?: Vector4;
  103612. backUVs?: Vector4;
  103613. instance?: Mesh;
  103614. invertUV?: boolean;
  103615. }, scene: Scene): Mesh;
  103616. }
  103617. }
  103618. declare module BABYLON {
  103619. /**
  103620. * Class containing static functions to help procedurally build meshes
  103621. */
  103622. export class IcoSphereBuilder {
  103623. /**
  103624. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103625. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103626. * * 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`)
  103627. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103628. * * 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
  103629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103632. * @param name defines the name of the mesh
  103633. * @param options defines the options used to create the mesh
  103634. * @param scene defines the hosting scene
  103635. * @returns the icosahedron mesh
  103636. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103637. */
  103638. static CreateIcoSphere(name: string, options: {
  103639. radius?: number;
  103640. radiusX?: number;
  103641. radiusY?: number;
  103642. radiusZ?: number;
  103643. flat?: boolean;
  103644. subdivisions?: number;
  103645. sideOrientation?: number;
  103646. frontUVs?: Vector4;
  103647. backUVs?: Vector4;
  103648. updatable?: boolean;
  103649. }, scene: Scene): Mesh;
  103650. }
  103651. }
  103652. declare module BABYLON {
  103653. /**
  103654. * Class containing static functions to help procedurally build meshes
  103655. */
  103656. export class DecalBuilder {
  103657. /**
  103658. * Creates a decal mesh.
  103659. * 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
  103660. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103661. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103662. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103663. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103664. * @param name defines the name of the mesh
  103665. * @param sourceMesh defines the mesh where the decal must be applied
  103666. * @param options defines the options used to create the mesh
  103667. * @param scene defines the hosting scene
  103668. * @returns the decal mesh
  103669. * @see https://doc.babylonjs.com/how_to/decals
  103670. */
  103671. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  103672. position?: Vector3;
  103673. normal?: Vector3;
  103674. size?: Vector3;
  103675. angle?: number;
  103676. }): Mesh;
  103677. }
  103678. }
  103679. declare module BABYLON {
  103680. /**
  103681. * Class containing static functions to help procedurally build meshes
  103682. */
  103683. export class MeshBuilder {
  103684. /**
  103685. * Creates a box mesh
  103686. * * The parameter `size` sets the size (float) of each box side (default 1)
  103687. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103688. * * 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)
  103689. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103693. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103694. * @param name defines the name of the mesh
  103695. * @param options defines the options used to create the mesh
  103696. * @param scene defines the hosting scene
  103697. * @returns the box mesh
  103698. */
  103699. static CreateBox(name: string, options: {
  103700. size?: number;
  103701. width?: number;
  103702. height?: number;
  103703. depth?: number;
  103704. faceUV?: Vector4[];
  103705. faceColors?: Color4[];
  103706. sideOrientation?: number;
  103707. frontUVs?: Vector4;
  103708. backUVs?: Vector4;
  103709. updatable?: boolean;
  103710. }, scene?: Nullable<Scene>): Mesh;
  103711. /**
  103712. * Creates a sphere mesh
  103713. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103714. * * 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`)
  103715. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103716. * * 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
  103717. * * 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)
  103718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 sphere mesh
  103725. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103726. */
  103727. static CreateSphere(name: string, options: {
  103728. segments?: number;
  103729. diameter?: number;
  103730. diameterX?: number;
  103731. diameterY?: number;
  103732. diameterZ?: number;
  103733. arc?: number;
  103734. slice?: number;
  103735. sideOrientation?: number;
  103736. frontUVs?: Vector4;
  103737. backUVs?: Vector4;
  103738. updatable?: boolean;
  103739. }, scene: any): Mesh;
  103740. /**
  103741. * Creates a plane polygonal mesh. By default, this is a disc
  103742. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103743. * * 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
  103744. * * 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
  103745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103748. * @param name defines the name of the mesh
  103749. * @param options defines the options used to create the mesh
  103750. * @param scene defines the hosting scene
  103751. * @returns the plane polygonal mesh
  103752. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103753. */
  103754. static CreateDisc(name: string, options: {
  103755. radius?: number;
  103756. tessellation?: number;
  103757. arc?: number;
  103758. updatable?: boolean;
  103759. sideOrientation?: number;
  103760. frontUVs?: Vector4;
  103761. backUVs?: Vector4;
  103762. }, scene?: Nullable<Scene>): Mesh;
  103763. /**
  103764. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103765. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103766. * * 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`)
  103767. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103768. * * 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
  103769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103772. * @param name defines the name of the mesh
  103773. * @param options defines the options used to create the mesh
  103774. * @param scene defines the hosting scene
  103775. * @returns the icosahedron mesh
  103776. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103777. */
  103778. static CreateIcoSphere(name: string, options: {
  103779. radius?: number;
  103780. radiusX?: number;
  103781. radiusY?: number;
  103782. radiusZ?: number;
  103783. flat?: boolean;
  103784. subdivisions?: number;
  103785. sideOrientation?: number;
  103786. frontUVs?: Vector4;
  103787. backUVs?: Vector4;
  103788. updatable?: boolean;
  103789. }, scene: Scene): Mesh;
  103790. /**
  103791. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103792. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103793. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103794. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103795. * * 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
  103796. * * 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
  103797. * * 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
  103798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103800. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103801. * * 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
  103802. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103803. * * 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
  103804. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103806. * @param name defines the name of the mesh
  103807. * @param options defines the options used to create the mesh
  103808. * @param scene defines the hosting scene
  103809. * @returns the ribbon mesh
  103810. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103811. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103812. */
  103813. static CreateRibbon(name: string, options: {
  103814. pathArray: Vector3[][];
  103815. closeArray?: boolean;
  103816. closePath?: boolean;
  103817. offset?: number;
  103818. updatable?: boolean;
  103819. sideOrientation?: number;
  103820. frontUVs?: Vector4;
  103821. backUVs?: Vector4;
  103822. instance?: Mesh;
  103823. invertUV?: boolean;
  103824. uvs?: Vector2[];
  103825. colors?: Color4[];
  103826. }, scene?: Nullable<Scene>): Mesh;
  103827. /**
  103828. * Creates a cylinder or a cone mesh
  103829. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103830. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103831. * * 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.
  103832. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103833. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103834. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103835. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103836. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103837. * * 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).
  103838. * * 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
  103839. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103840. * * 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
  103841. * * 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.
  103842. * * If `enclose` is false, a ring surface is one element.
  103843. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103844. * * 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
  103845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103848. * @param name defines the name of the mesh
  103849. * @param options defines the options used to create the mesh
  103850. * @param scene defines the hosting scene
  103851. * @returns the cylinder mesh
  103852. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103853. */
  103854. static CreateCylinder(name: string, options: {
  103855. height?: number;
  103856. diameterTop?: number;
  103857. diameterBottom?: number;
  103858. diameter?: number;
  103859. tessellation?: number;
  103860. subdivisions?: number;
  103861. arc?: number;
  103862. faceColors?: Color4[];
  103863. faceUV?: Vector4[];
  103864. updatable?: boolean;
  103865. hasRings?: boolean;
  103866. enclose?: boolean;
  103867. sideOrientation?: number;
  103868. frontUVs?: Vector4;
  103869. backUVs?: Vector4;
  103870. }, scene: any): Mesh;
  103871. /**
  103872. * Creates a torus mesh
  103873. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103874. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103875. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103879. * @param name defines the name of the mesh
  103880. * @param options defines the options used to create the mesh
  103881. * @param scene defines the hosting scene
  103882. * @returns the torus mesh
  103883. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103884. */
  103885. static CreateTorus(name: string, options: {
  103886. diameter?: number;
  103887. thickness?: number;
  103888. tessellation?: number;
  103889. updatable?: boolean;
  103890. sideOrientation?: number;
  103891. frontUVs?: Vector4;
  103892. backUVs?: Vector4;
  103893. }, scene: any): Mesh;
  103894. /**
  103895. * Creates a torus knot mesh
  103896. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103897. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103898. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103899. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103903. * @param name defines the name of the mesh
  103904. * @param options defines the options used to create the mesh
  103905. * @param scene defines the hosting scene
  103906. * @returns the torus knot mesh
  103907. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103908. */
  103909. static CreateTorusKnot(name: string, options: {
  103910. radius?: number;
  103911. tube?: number;
  103912. radialSegments?: number;
  103913. tubularSegments?: number;
  103914. p?: number;
  103915. q?: number;
  103916. updatable?: boolean;
  103917. sideOrientation?: number;
  103918. frontUVs?: Vector4;
  103919. backUVs?: Vector4;
  103920. }, scene: any): Mesh;
  103921. /**
  103922. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103923. * * 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
  103924. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103925. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103926. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103927. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103928. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103929. * * 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
  103930. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103933. * @param name defines the name of the new line system
  103934. * @param options defines the options used to create the line system
  103935. * @param scene defines the hosting scene
  103936. * @returns a new line system mesh
  103937. */
  103938. static CreateLineSystem(name: string, options: {
  103939. lines: Vector3[][];
  103940. updatable?: boolean;
  103941. instance?: Nullable<LinesMesh>;
  103942. colors?: Nullable<Color4[][]>;
  103943. useVertexAlpha?: boolean;
  103944. }, scene: Nullable<Scene>): LinesMesh;
  103945. /**
  103946. * Creates a line mesh
  103947. * 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
  103948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103949. * * The parameter `points` is an array successive Vector3
  103950. * * 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
  103951. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103953. * * When updating an instance, remember that only point positions can change, not the number of points
  103954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103956. * @param name defines the name of the new line system
  103957. * @param options defines the options used to create the line system
  103958. * @param scene defines the hosting scene
  103959. * @returns a new line mesh
  103960. */
  103961. static CreateLines(name: string, options: {
  103962. points: Vector3[];
  103963. updatable?: boolean;
  103964. instance?: Nullable<LinesMesh>;
  103965. colors?: Color4[];
  103966. useVertexAlpha?: boolean;
  103967. }, scene?: Nullable<Scene>): LinesMesh;
  103968. /**
  103969. * Creates a dashed line mesh
  103970. * * 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
  103971. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103972. * * The parameter `points` is an array successive Vector3
  103973. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103974. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103975. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103976. * * 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
  103977. * * When updating an instance, remember that only point positions can change, not the number of points
  103978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103979. * @param name defines the name of the mesh
  103980. * @param options defines the options used to create the mesh
  103981. * @param scene defines the hosting scene
  103982. * @returns the dashed line mesh
  103983. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103984. */
  103985. static CreateDashedLines(name: string, options: {
  103986. points: Vector3[];
  103987. dashSize?: number;
  103988. gapSize?: number;
  103989. dashNb?: number;
  103990. updatable?: boolean;
  103991. instance?: LinesMesh;
  103992. }, scene?: Nullable<Scene>): LinesMesh;
  103993. /**
  103994. * 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.
  103995. * * 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.
  103996. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103997. * * 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.
  103998. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103999. * * 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
  104000. * * 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
  104001. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  104002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  104005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104006. * @param name defines the name of the mesh
  104007. * @param options defines the options used to create the mesh
  104008. * @param scene defines the hosting scene
  104009. * @returns the extruded shape mesh
  104010. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104012. */
  104013. static ExtrudeShape(name: string, options: {
  104014. shape: Vector3[];
  104015. path: Vector3[];
  104016. scale?: number;
  104017. rotation?: number;
  104018. cap?: number;
  104019. updatable?: boolean;
  104020. sideOrientation?: number;
  104021. frontUVs?: Vector4;
  104022. backUVs?: Vector4;
  104023. instance?: Mesh;
  104024. invertUV?: boolean;
  104025. }, scene?: Nullable<Scene>): Mesh;
  104026. /**
  104027. * Creates an custom extruded shape mesh.
  104028. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104029. * * 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.
  104030. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104031. * * 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
  104032. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104033. * * 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
  104034. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104035. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104036. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104037. * * 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
  104038. * * 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
  104039. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104044. * @param name defines the name of the mesh
  104045. * @param options defines the options used to create the mesh
  104046. * @param scene defines the hosting scene
  104047. * @returns the custom extruded shape mesh
  104048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104049. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104051. */
  104052. static ExtrudeShapeCustom(name: string, options: {
  104053. shape: Vector3[];
  104054. path: Vector3[];
  104055. scaleFunction?: any;
  104056. rotationFunction?: any;
  104057. ribbonCloseArray?: boolean;
  104058. ribbonClosePath?: boolean;
  104059. cap?: number;
  104060. updatable?: boolean;
  104061. sideOrientation?: number;
  104062. frontUVs?: Vector4;
  104063. backUVs?: Vector4;
  104064. instance?: Mesh;
  104065. invertUV?: boolean;
  104066. }, scene: Scene): Mesh;
  104067. /**
  104068. * Creates lathe mesh.
  104069. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104070. * * 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
  104071. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104072. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104073. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104074. * * 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
  104075. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104076. * * 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
  104077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104079. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104081. * @param name defines the name of the mesh
  104082. * @param options defines the options used to create the mesh
  104083. * @param scene defines the hosting scene
  104084. * @returns the lathe mesh
  104085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104086. */
  104087. static CreateLathe(name: string, options: {
  104088. shape: Vector3[];
  104089. radius?: number;
  104090. tessellation?: number;
  104091. clip?: number;
  104092. arc?: number;
  104093. closed?: boolean;
  104094. updatable?: boolean;
  104095. sideOrientation?: number;
  104096. frontUVs?: Vector4;
  104097. backUVs?: Vector4;
  104098. cap?: number;
  104099. invertUV?: boolean;
  104100. }, scene: Scene): Mesh;
  104101. /**
  104102. * Creates a plane mesh
  104103. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104104. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104105. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104109. * @param name defines the name of the mesh
  104110. * @param options defines the options used to create the mesh
  104111. * @param scene defines the hosting scene
  104112. * @returns the plane mesh
  104113. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104114. */
  104115. static CreatePlane(name: string, options: {
  104116. size?: number;
  104117. width?: number;
  104118. height?: number;
  104119. sideOrientation?: number;
  104120. frontUVs?: Vector4;
  104121. backUVs?: Vector4;
  104122. updatable?: boolean;
  104123. sourcePlane?: Plane;
  104124. }, scene: Scene): Mesh;
  104125. /**
  104126. * Creates a ground mesh
  104127. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104128. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104130. * @param name defines the name of the mesh
  104131. * @param options defines the options used to create the mesh
  104132. * @param scene defines the hosting scene
  104133. * @returns the ground mesh
  104134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104135. */
  104136. static CreateGround(name: string, options: {
  104137. width?: number;
  104138. height?: number;
  104139. subdivisions?: number;
  104140. subdivisionsX?: number;
  104141. subdivisionsY?: number;
  104142. updatable?: boolean;
  104143. }, scene: any): Mesh;
  104144. /**
  104145. * Creates a tiled ground mesh
  104146. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104147. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104148. * * 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
  104149. * * 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
  104150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104151. * @param name defines the name of the mesh
  104152. * @param options defines the options used to create the mesh
  104153. * @param scene defines the hosting scene
  104154. * @returns the tiled ground mesh
  104155. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104156. */
  104157. static CreateTiledGround(name: string, options: {
  104158. xmin: number;
  104159. zmin: number;
  104160. xmax: number;
  104161. zmax: number;
  104162. subdivisions?: {
  104163. w: number;
  104164. h: number;
  104165. };
  104166. precision?: {
  104167. w: number;
  104168. h: number;
  104169. };
  104170. updatable?: boolean;
  104171. }, scene: Scene): Mesh;
  104172. /**
  104173. * Creates a ground mesh from a height map
  104174. * * The parameter `url` sets the URL of the height map image resource.
  104175. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104176. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104177. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104178. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104179. * * 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.
  104180. * * 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).
  104181. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104183. * @param name defines the name of the mesh
  104184. * @param url defines the url to the height map
  104185. * @param options defines the options used to create the mesh
  104186. * @param scene defines the hosting scene
  104187. * @returns the ground mesh
  104188. * @see https://doc.babylonjs.com/babylon101/height_map
  104189. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104190. */
  104191. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104192. width?: number;
  104193. height?: number;
  104194. subdivisions?: number;
  104195. minHeight?: number;
  104196. maxHeight?: number;
  104197. colorFilter?: Color3;
  104198. alphaFilter?: number;
  104199. updatable?: boolean;
  104200. onReady?: (mesh: GroundMesh) => void;
  104201. }, scene: Scene): GroundMesh;
  104202. /**
  104203. * Creates a polygon mesh
  104204. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104205. * * 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
  104206. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104209. * * Remember you can only change the shape positions, not their number when updating a polygon
  104210. * @param name defines the name of the mesh
  104211. * @param options defines the options used to create the mesh
  104212. * @param scene defines the hosting scene
  104213. * @param earcutInjection can be used to inject your own earcut reference
  104214. * @returns the polygon mesh
  104215. */
  104216. static CreatePolygon(name: string, options: {
  104217. shape: Vector3[];
  104218. holes?: Vector3[][];
  104219. depth?: number;
  104220. faceUV?: Vector4[];
  104221. faceColors?: Color4[];
  104222. updatable?: boolean;
  104223. sideOrientation?: number;
  104224. frontUVs?: Vector4;
  104225. backUVs?: Vector4;
  104226. }, scene: Scene, earcutInjection?: any): Mesh;
  104227. /**
  104228. * Creates an extruded polygon mesh, with depth in the Y direction.
  104229. * * 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)
  104230. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104231. * @param name defines the name of the mesh
  104232. * @param options defines the options used to create the mesh
  104233. * @param scene defines the hosting scene
  104234. * @param earcutInjection can be used to inject your own earcut reference
  104235. * @returns the polygon mesh
  104236. */
  104237. static ExtrudePolygon(name: string, options: {
  104238. shape: Vector3[];
  104239. holes?: Vector3[][];
  104240. depth?: number;
  104241. faceUV?: Vector4[];
  104242. faceColors?: Color4[];
  104243. updatable?: boolean;
  104244. sideOrientation?: number;
  104245. frontUVs?: Vector4;
  104246. backUVs?: Vector4;
  104247. }, scene: Scene, earcutInjection?: any): Mesh;
  104248. /**
  104249. * Creates a tube mesh.
  104250. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104251. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104252. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104253. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104254. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104255. * * 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)
  104256. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104257. * * 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
  104258. * * 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
  104259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104263. * @param name defines the name of the mesh
  104264. * @param options defines the options used to create the mesh
  104265. * @param scene defines the hosting scene
  104266. * @returns the tube mesh
  104267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104268. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104269. */
  104270. static CreateTube(name: string, options: {
  104271. path: Vector3[];
  104272. radius?: number;
  104273. tessellation?: number;
  104274. radiusFunction?: {
  104275. (i: number, distance: number): number;
  104276. };
  104277. cap?: number;
  104278. arc?: number;
  104279. updatable?: boolean;
  104280. sideOrientation?: number;
  104281. frontUVs?: Vector4;
  104282. backUVs?: Vector4;
  104283. instance?: Mesh;
  104284. invertUV?: boolean;
  104285. }, scene: Scene): Mesh;
  104286. /**
  104287. * Creates a polyhedron mesh
  104288. * * 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
  104289. * * The parameter `size` (positive float, default 1) sets the polygon size
  104290. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104291. * * 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`
  104292. * * 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
  104293. * * 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)`)
  104294. * * 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
  104295. * * 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
  104296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104299. * @param name defines the name of the mesh
  104300. * @param options defines the options used to create the mesh
  104301. * @param scene defines the hosting scene
  104302. * @returns the polyhedron mesh
  104303. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104304. */
  104305. static CreatePolyhedron(name: string, options: {
  104306. type?: number;
  104307. size?: number;
  104308. sizeX?: number;
  104309. sizeY?: number;
  104310. sizeZ?: number;
  104311. custom?: any;
  104312. faceUV?: Vector4[];
  104313. faceColors?: Color4[];
  104314. flat?: boolean;
  104315. updatable?: boolean;
  104316. sideOrientation?: number;
  104317. frontUVs?: Vector4;
  104318. backUVs?: Vector4;
  104319. }, scene: Scene): Mesh;
  104320. /**
  104321. * Creates a decal mesh.
  104322. * 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
  104323. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104324. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104325. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104326. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104327. * @param name defines the name of the mesh
  104328. * @param sourceMesh defines the mesh where the decal must be applied
  104329. * @param options defines the options used to create the mesh
  104330. * @param scene defines the hosting scene
  104331. * @returns the decal mesh
  104332. * @see https://doc.babylonjs.com/how_to/decals
  104333. */
  104334. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104335. position?: Vector3;
  104336. normal?: Vector3;
  104337. size?: Vector3;
  104338. angle?: number;
  104339. }): Mesh;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * A simplifier interface for future simplification implementations
  104345. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104346. */
  104347. export interface ISimplifier {
  104348. /**
  104349. * Simplification of a given mesh according to the given settings.
  104350. * Since this requires computation, it is assumed that the function runs async.
  104351. * @param settings The settings of the simplification, including quality and distance
  104352. * @param successCallback A callback that will be called after the mesh was simplified.
  104353. * @param errorCallback in case of an error, this callback will be called. optional.
  104354. */
  104355. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104356. }
  104357. /**
  104358. * Expected simplification settings.
  104359. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104360. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104361. */
  104362. export interface ISimplificationSettings {
  104363. /**
  104364. * Gets or sets the expected quality
  104365. */
  104366. quality: number;
  104367. /**
  104368. * Gets or sets the distance when this optimized version should be used
  104369. */
  104370. distance: number;
  104371. /**
  104372. * Gets an already optimized mesh
  104373. */
  104374. optimizeMesh?: boolean;
  104375. }
  104376. /**
  104377. * Class used to specify simplification options
  104378. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104379. */
  104380. export class SimplificationSettings implements ISimplificationSettings {
  104381. /** expected quality */
  104382. quality: number;
  104383. /** distance when this optimized version should be used */
  104384. distance: number;
  104385. /** already optimized mesh */
  104386. optimizeMesh?: boolean | undefined;
  104387. /**
  104388. * Creates a SimplificationSettings
  104389. * @param quality expected quality
  104390. * @param distance distance when this optimized version should be used
  104391. * @param optimizeMesh already optimized mesh
  104392. */
  104393. constructor(
  104394. /** expected quality */
  104395. quality: number,
  104396. /** distance when this optimized version should be used */
  104397. distance: number,
  104398. /** already optimized mesh */
  104399. optimizeMesh?: boolean | undefined);
  104400. }
  104401. /**
  104402. * Interface used to define a simplification task
  104403. */
  104404. export interface ISimplificationTask {
  104405. /**
  104406. * Array of settings
  104407. */
  104408. settings: Array<ISimplificationSettings>;
  104409. /**
  104410. * Simplification type
  104411. */
  104412. simplificationType: SimplificationType;
  104413. /**
  104414. * Mesh to simplify
  104415. */
  104416. mesh: Mesh;
  104417. /**
  104418. * Callback called on success
  104419. */
  104420. successCallback?: () => void;
  104421. /**
  104422. * Defines if parallel processing can be used
  104423. */
  104424. parallelProcessing: boolean;
  104425. }
  104426. /**
  104427. * Queue used to order the simplification tasks
  104428. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104429. */
  104430. export class SimplificationQueue {
  104431. private _simplificationArray;
  104432. /**
  104433. * Gets a boolean indicating that the process is still running
  104434. */
  104435. running: boolean;
  104436. /**
  104437. * Creates a new queue
  104438. */
  104439. constructor();
  104440. /**
  104441. * Adds a new simplification task
  104442. * @param task defines a task to add
  104443. */
  104444. addTask(task: ISimplificationTask): void;
  104445. /**
  104446. * Execute next task
  104447. */
  104448. executeNext(): void;
  104449. /**
  104450. * Execute a simplification task
  104451. * @param task defines the task to run
  104452. */
  104453. runSimplification(task: ISimplificationTask): void;
  104454. private getSimplifier;
  104455. }
  104456. /**
  104457. * The implemented types of simplification
  104458. * At the moment only Quadratic Error Decimation is implemented
  104459. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104460. */
  104461. export enum SimplificationType {
  104462. /** Quadratic error decimation */
  104463. QUADRATIC = 0
  104464. }
  104465. }
  104466. declare module BABYLON {
  104467. interface Scene {
  104468. /** @hidden (Backing field) */
  104469. _simplificationQueue: SimplificationQueue;
  104470. /**
  104471. * Gets or sets the simplification queue attached to the scene
  104472. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104473. */
  104474. simplificationQueue: SimplificationQueue;
  104475. }
  104476. interface Mesh {
  104477. /**
  104478. * Simplify the mesh according to the given array of settings.
  104479. * Function will return immediately and will simplify async
  104480. * @param settings a collection of simplification settings
  104481. * @param parallelProcessing should all levels calculate parallel or one after the other
  104482. * @param simplificationType the type of simplification to run
  104483. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  104484. * @returns the current mesh
  104485. */
  104486. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  104487. }
  104488. /**
  104489. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104490. * created in a scene
  104491. */
  104492. export class SimplicationQueueSceneComponent implements ISceneComponent {
  104493. /**
  104494. * The component name helpfull to identify the component in the list of scene components.
  104495. */
  104496. readonly name: string;
  104497. /**
  104498. * The scene the component belongs to.
  104499. */
  104500. scene: Scene;
  104501. /**
  104502. * Creates a new instance of the component for the given scene
  104503. * @param scene Defines the scene to register the component in
  104504. */
  104505. constructor(scene: Scene);
  104506. /**
  104507. * Registers the component in a given scene
  104508. */
  104509. register(): void;
  104510. /**
  104511. * Rebuilds the elements related to this component in case of
  104512. * context lost for instance.
  104513. */
  104514. rebuild(): void;
  104515. /**
  104516. * Disposes the component and the associated ressources
  104517. */
  104518. dispose(): void;
  104519. private _beforeCameraUpdate;
  104520. }
  104521. }
  104522. declare module BABYLON {
  104523. /**
  104524. * Class used to enable access to IndexedDB
  104525. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104526. */
  104527. export class Database implements IOfflineProvider {
  104528. private _callbackManifestChecked;
  104529. private _currentSceneUrl;
  104530. private _db;
  104531. private _enableSceneOffline;
  104532. private _enableTexturesOffline;
  104533. private _manifestVersionFound;
  104534. private _mustUpdateRessources;
  104535. private _hasReachedQuota;
  104536. private _isSupported;
  104537. private _idbFactory;
  104538. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104539. private static IsUASupportingBlobStorage;
  104540. /**
  104541. * Gets a boolean indicating if Database storate is enabled (off by default)
  104542. */
  104543. static IDBStorageEnabled: boolean;
  104544. /**
  104545. * Gets a boolean indicating if scene must be saved in the database
  104546. */
  104547. readonly enableSceneOffline: boolean;
  104548. /**
  104549. * Gets a boolean indicating if textures must be saved in the database
  104550. */
  104551. readonly enableTexturesOffline: boolean;
  104552. /**
  104553. * Creates a new Database
  104554. * @param urlToScene defines the url to load the scene
  104555. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104556. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104557. */
  104558. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  104559. private static _ParseURL;
  104560. private static _ReturnFullUrlLocation;
  104561. private _checkManifestFile;
  104562. /**
  104563. * Open the database and make it available
  104564. * @param successCallback defines the callback to call on success
  104565. * @param errorCallback defines the callback to call on error
  104566. */
  104567. open(successCallback: () => void, errorCallback: () => void): void;
  104568. /**
  104569. * Loads an image from the database
  104570. * @param url defines the url to load from
  104571. * @param image defines the target DOM image
  104572. */
  104573. loadImage(url: string, image: HTMLImageElement): void;
  104574. private _loadImageFromDBAsync;
  104575. private _saveImageIntoDBAsync;
  104576. private _checkVersionFromDB;
  104577. private _loadVersionFromDBAsync;
  104578. private _saveVersionIntoDBAsync;
  104579. /**
  104580. * Loads a file from database
  104581. * @param url defines the URL to load from
  104582. * @param sceneLoaded defines a callback to call on success
  104583. * @param progressCallBack defines a callback to call when progress changed
  104584. * @param errorCallback defines a callback to call on error
  104585. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104586. */
  104587. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  104588. private _loadFileAsync;
  104589. private _saveFileAsync;
  104590. /**
  104591. * Validates if xhr data is correct
  104592. * @param xhr defines the request to validate
  104593. * @param dataType defines the expected data type
  104594. * @returns true if data is correct
  104595. */
  104596. private static _ValidateXHRData;
  104597. }
  104598. }
  104599. declare module BABYLON {
  104600. /** @hidden */
  104601. export var gpuUpdateParticlesPixelShader: {
  104602. name: string;
  104603. shader: string;
  104604. };
  104605. }
  104606. declare module BABYLON {
  104607. /** @hidden */
  104608. export var gpuUpdateParticlesVertexShader: {
  104609. name: string;
  104610. shader: string;
  104611. };
  104612. }
  104613. declare module BABYLON {
  104614. /** @hidden */
  104615. export var clipPlaneFragmentDeclaration2: {
  104616. name: string;
  104617. shader: string;
  104618. };
  104619. }
  104620. declare module BABYLON {
  104621. /** @hidden */
  104622. export var gpuRenderParticlesPixelShader: {
  104623. name: string;
  104624. shader: string;
  104625. };
  104626. }
  104627. declare module BABYLON {
  104628. /** @hidden */
  104629. export var clipPlaneVertexDeclaration2: {
  104630. name: string;
  104631. shader: string;
  104632. };
  104633. }
  104634. declare module BABYLON {
  104635. /** @hidden */
  104636. export var gpuRenderParticlesVertexShader: {
  104637. name: string;
  104638. shader: string;
  104639. };
  104640. }
  104641. declare module BABYLON {
  104642. /**
  104643. * This represents a GPU particle system in Babylon
  104644. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104645. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104646. */
  104647. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  104648. /**
  104649. * The layer mask we are rendering the particles through.
  104650. */
  104651. layerMask: number;
  104652. private _capacity;
  104653. private _activeCount;
  104654. private _currentActiveCount;
  104655. private _accumulatedCount;
  104656. private _renderEffect;
  104657. private _updateEffect;
  104658. private _buffer0;
  104659. private _buffer1;
  104660. private _spriteBuffer;
  104661. private _updateVAO;
  104662. private _renderVAO;
  104663. private _targetIndex;
  104664. private _sourceBuffer;
  104665. private _targetBuffer;
  104666. private _engine;
  104667. private _currentRenderId;
  104668. private _started;
  104669. private _stopped;
  104670. private _timeDelta;
  104671. private _randomTexture;
  104672. private _randomTexture2;
  104673. private _attributesStrideSize;
  104674. private _updateEffectOptions;
  104675. private _randomTextureSize;
  104676. private _actualFrame;
  104677. private readonly _rawTextureWidth;
  104678. /**
  104679. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104680. */
  104681. static readonly IsSupported: boolean;
  104682. /**
  104683. * An event triggered when the system is disposed.
  104684. */
  104685. onDisposeObservable: Observable<GPUParticleSystem>;
  104686. /**
  104687. * Gets the maximum number of particles active at the same time.
  104688. * @returns The max number of active particles.
  104689. */
  104690. getCapacity(): number;
  104691. /**
  104692. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104693. * to override the particles.
  104694. */
  104695. forceDepthWrite: boolean;
  104696. /**
  104697. * Gets or set the number of active particles
  104698. */
  104699. activeParticleCount: number;
  104700. private _preWarmDone;
  104701. /**
  104702. * Is this system ready to be used/rendered
  104703. * @return true if the system is ready
  104704. */
  104705. isReady(): boolean;
  104706. /**
  104707. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104708. * @returns True if it has been started, otherwise false.
  104709. */
  104710. isStarted(): boolean;
  104711. /**
  104712. * Starts the particle system and begins to emit
  104713. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104714. */
  104715. start(delay?: number): void;
  104716. /**
  104717. * Stops the particle system.
  104718. */
  104719. stop(): void;
  104720. /**
  104721. * Remove all active particles
  104722. */
  104723. reset(): void;
  104724. /**
  104725. * Returns the string "GPUParticleSystem"
  104726. * @returns a string containing the class name
  104727. */
  104728. getClassName(): string;
  104729. private _colorGradientsTexture;
  104730. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  104731. /**
  104732. * Adds a new color gradient
  104733. * @param gradient defines the gradient to use (between 0 and 1)
  104734. * @param color1 defines the color to affect to the specified gradient
  104735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104736. * @returns the current particle system
  104737. */
  104738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  104739. /**
  104740. * Remove a specific color gradient
  104741. * @param gradient defines the gradient to remove
  104742. * @returns the current particle system
  104743. */
  104744. removeColorGradient(gradient: number): GPUParticleSystem;
  104745. private _angularSpeedGradientsTexture;
  104746. private _sizeGradientsTexture;
  104747. private _velocityGradientsTexture;
  104748. private _limitVelocityGradientsTexture;
  104749. private _dragGradientsTexture;
  104750. private _addFactorGradient;
  104751. /**
  104752. * Adds a new size gradient
  104753. * @param gradient defines the gradient to use (between 0 and 1)
  104754. * @param factor defines the size factor to affect to the specified gradient
  104755. * @returns the current particle system
  104756. */
  104757. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  104758. /**
  104759. * Remove a specific size gradient
  104760. * @param gradient defines the gradient to remove
  104761. * @returns the current particle system
  104762. */
  104763. removeSizeGradient(gradient: number): GPUParticleSystem;
  104764. /**
  104765. * Adds a new angular speed gradient
  104766. * @param gradient defines the gradient to use (between 0 and 1)
  104767. * @param factor defines the angular speed to affect to the specified gradient
  104768. * @returns the current particle system
  104769. */
  104770. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  104771. /**
  104772. * Remove a specific angular speed gradient
  104773. * @param gradient defines the gradient to remove
  104774. * @returns the current particle system
  104775. */
  104776. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  104777. /**
  104778. * Adds a new velocity gradient
  104779. * @param gradient defines the gradient to use (between 0 and 1)
  104780. * @param factor defines the velocity to affect to the specified gradient
  104781. * @returns the current particle system
  104782. */
  104783. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104784. /**
  104785. * Remove a specific velocity gradient
  104786. * @param gradient defines the gradient to remove
  104787. * @returns the current particle system
  104788. */
  104789. removeVelocityGradient(gradient: number): GPUParticleSystem;
  104790. /**
  104791. * Adds a new limit velocity gradient
  104792. * @param gradient defines the gradient to use (between 0 and 1)
  104793. * @param factor defines the limit velocity value to affect to the specified gradient
  104794. * @returns the current particle system
  104795. */
  104796. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104797. /**
  104798. * Remove a specific limit velocity gradient
  104799. * @param gradient defines the gradient to remove
  104800. * @returns the current particle system
  104801. */
  104802. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  104803. /**
  104804. * Adds a new drag gradient
  104805. * @param gradient defines the gradient to use (between 0 and 1)
  104806. * @param factor defines the drag value to affect to the specified gradient
  104807. * @returns the current particle system
  104808. */
  104809. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  104810. /**
  104811. * Remove a specific drag gradient
  104812. * @param gradient defines the gradient to remove
  104813. * @returns the current particle system
  104814. */
  104815. removeDragGradient(gradient: number): GPUParticleSystem;
  104816. /**
  104817. * Not supported by GPUParticleSystem
  104818. * @param gradient defines the gradient to use (between 0 and 1)
  104819. * @param factor defines the emit rate value to affect to the specified gradient
  104820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104821. * @returns the current particle system
  104822. */
  104823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104824. /**
  104825. * Not supported by GPUParticleSystem
  104826. * @param gradient defines the gradient to remove
  104827. * @returns the current particle system
  104828. */
  104829. removeEmitRateGradient(gradient: number): IParticleSystem;
  104830. /**
  104831. * Not supported by GPUParticleSystem
  104832. * @param gradient defines the gradient to use (between 0 and 1)
  104833. * @param factor defines the start size value to affect to the specified gradient
  104834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104835. * @returns the current particle system
  104836. */
  104837. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104838. /**
  104839. * Not supported by GPUParticleSystem
  104840. * @param gradient defines the gradient to remove
  104841. * @returns the current particle system
  104842. */
  104843. removeStartSizeGradient(gradient: number): IParticleSystem;
  104844. /**
  104845. * Not supported by GPUParticleSystem
  104846. * @param gradient defines the gradient to use (between 0 and 1)
  104847. * @param min defines the color remap minimal range
  104848. * @param max defines the color remap maximal range
  104849. * @returns the current particle system
  104850. */
  104851. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104852. /**
  104853. * Not supported by GPUParticleSystem
  104854. * @param gradient defines the gradient to remove
  104855. * @returns the current particle system
  104856. */
  104857. removeColorRemapGradient(): IParticleSystem;
  104858. /**
  104859. * Not supported by GPUParticleSystem
  104860. * @param gradient defines the gradient to use (between 0 and 1)
  104861. * @param min defines the alpha remap minimal range
  104862. * @param max defines the alpha remap maximal range
  104863. * @returns the current particle system
  104864. */
  104865. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104866. /**
  104867. * Not supported by GPUParticleSystem
  104868. * @param gradient defines the gradient to remove
  104869. * @returns the current particle system
  104870. */
  104871. removeAlphaRemapGradient(): IParticleSystem;
  104872. /**
  104873. * Not supported by GPUParticleSystem
  104874. * @param gradient defines the gradient to use (between 0 and 1)
  104875. * @param color defines the color to affect to the specified gradient
  104876. * @returns the current particle system
  104877. */
  104878. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  104879. /**
  104880. * Not supported by GPUParticleSystem
  104881. * @param gradient defines the gradient to remove
  104882. * @returns the current particle system
  104883. */
  104884. removeRampGradient(): IParticleSystem;
  104885. /**
  104886. * Not supported by GPUParticleSystem
  104887. * @returns the list of ramp gradients
  104888. */
  104889. getRampGradients(): Nullable<Array<Color3Gradient>>;
  104890. /**
  104891. * Not supported by GPUParticleSystem
  104892. * Gets or sets a boolean indicating that ramp gradients must be used
  104893. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104894. */
  104895. useRampGradients: boolean;
  104896. /**
  104897. * Not supported by GPUParticleSystem
  104898. * @param gradient defines the gradient to use (between 0 and 1)
  104899. * @param factor defines the life time factor to affect to the specified gradient
  104900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104901. * @returns the current particle system
  104902. */
  104903. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104904. /**
  104905. * Not supported by GPUParticleSystem
  104906. * @param gradient defines the gradient to remove
  104907. * @returns the current particle system
  104908. */
  104909. removeLifeTimeGradient(gradient: number): IParticleSystem;
  104910. /**
  104911. * Instantiates a GPU particle system.
  104912. * 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.
  104913. * @param name The name of the particle system
  104914. * @param options The options used to create the system
  104915. * @param scene The scene the particle system belongs to
  104916. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104917. */
  104918. constructor(name: string, options: Partial<{
  104919. capacity: number;
  104920. randomTextureSize: number;
  104921. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  104922. protected _reset(): void;
  104923. private _createUpdateVAO;
  104924. private _createRenderVAO;
  104925. private _initialize;
  104926. /** @hidden */
  104927. _recreateUpdateEffect(): void;
  104928. /** @hidden */
  104929. _recreateRenderEffect(): void;
  104930. /**
  104931. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104932. * @param preWarm defines if we are in the pre-warmimg phase
  104933. */
  104934. animate(preWarm?: boolean): void;
  104935. private _createFactorGradientTexture;
  104936. private _createSizeGradientTexture;
  104937. private _createAngularSpeedGradientTexture;
  104938. private _createVelocityGradientTexture;
  104939. private _createLimitVelocityGradientTexture;
  104940. private _createDragGradientTexture;
  104941. private _createColorGradientTexture;
  104942. /**
  104943. * Renders the particle system in its current state
  104944. * @param preWarm defines if the system should only update the particles but not render them
  104945. * @returns the current number of particles
  104946. */
  104947. render(preWarm?: boolean): number;
  104948. /**
  104949. * Rebuilds the particle system
  104950. */
  104951. rebuild(): void;
  104952. private _releaseBuffers;
  104953. private _releaseVAOs;
  104954. /**
  104955. * Disposes the particle system and free the associated resources
  104956. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104957. */
  104958. dispose(disposeTexture?: boolean): void;
  104959. /**
  104960. * Clones the particle system.
  104961. * @param name The name of the cloned object
  104962. * @param newEmitter The new emitter to use
  104963. * @returns the cloned particle system
  104964. */
  104965. clone(name: string, newEmitter: any): GPUParticleSystem;
  104966. /**
  104967. * Serializes the particle system to a JSON object.
  104968. * @returns the JSON object
  104969. */
  104970. serialize(): any;
  104971. /**
  104972. * Parses a JSON object to create a GPU particle system.
  104973. * @param parsedParticleSystem The JSON object to parse
  104974. * @param scene The scene to create the particle system in
  104975. * @param rootUrl The root url to use to load external dependencies like texture
  104976. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104977. * @returns the parsed GPU particle system
  104978. */
  104979. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  104980. }
  104981. }
  104982. declare module BABYLON {
  104983. /**
  104984. * Represents a set of particle systems working together to create a specific effect
  104985. */
  104986. export class ParticleSystemSet implements IDisposable {
  104987. private _emitterCreationOptions;
  104988. private _emitterNode;
  104989. /**
  104990. * Gets the particle system list
  104991. */
  104992. systems: IParticleSystem[];
  104993. /**
  104994. * Gets the emitter node used with this set
  104995. */
  104996. readonly emitterNode: Nullable<TransformNode>;
  104997. /**
  104998. * Creates a new emitter mesh as a sphere
  104999. * @param options defines the options used to create the sphere
  105000. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  105001. * @param scene defines the hosting scene
  105002. */
  105003. setEmitterAsSphere(options: {
  105004. diameter: number;
  105005. segments: number;
  105006. color: Color3;
  105007. }, renderingGroupId: number, scene: Scene): void;
  105008. /**
  105009. * Starts all particle systems of the set
  105010. * @param emitter defines an optional mesh to use as emitter for the particle systems
  105011. */
  105012. start(emitter?: AbstractMesh): void;
  105013. /**
  105014. * Release all associated resources
  105015. */
  105016. dispose(): void;
  105017. /**
  105018. * Serialize the set into a JSON compatible object
  105019. * @returns a JSON compatible representation of the set
  105020. */
  105021. serialize(): any;
  105022. /**
  105023. * Parse a new ParticleSystemSet from a serialized source
  105024. * @param data defines a JSON compatible representation of the set
  105025. * @param scene defines the hosting scene
  105026. * @param gpu defines if we want GPU particles or CPU particles
  105027. * @returns a new ParticleSystemSet
  105028. */
  105029. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  105030. }
  105031. }
  105032. declare module BABYLON {
  105033. /**
  105034. * This class is made for on one-liner static method to help creating particle system set.
  105035. */
  105036. export class ParticleHelper {
  105037. /**
  105038. * Gets or sets base Assets URL
  105039. */
  105040. static BaseAssetsUrl: string;
  105041. /**
  105042. * Create a default particle system that you can tweak
  105043. * @param emitter defines the emitter to use
  105044. * @param capacity defines the system capacity (default is 500 particles)
  105045. * @param scene defines the hosting scene
  105046. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105047. * @returns the new Particle system
  105048. */
  105049. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  105050. /**
  105051. * This is the main static method (one-liner) of this helper to create different particle systems
  105052. * @param type This string represents the type to the particle system to create
  105053. * @param scene The scene where the particle system should live
  105054. * @param gpu If the system will use gpu
  105055. * @returns the ParticleSystemSet created
  105056. */
  105057. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  105058. /**
  105059. * Static function used to export a particle system to a ParticleSystemSet variable.
  105060. * Please note that the emitter shape is not exported
  105061. * @param systems defines the particle systems to export
  105062. * @returns the created particle system set
  105063. */
  105064. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  105065. }
  105066. }
  105067. declare module BABYLON {
  105068. interface Engine {
  105069. /**
  105070. * Create an effect to use with particle systems.
  105071. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  105072. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  105073. * @param uniformsNames defines a list of attribute names
  105074. * @param samplers defines an array of string used to represent textures
  105075. * @param defines defines the string containing the defines to use to compile the shaders
  105076. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105077. * @param onCompiled defines a function to call when the effect creation is successful
  105078. * @param onError defines a function to call when the effect creation has failed
  105079. * @returns the new Effect
  105080. */
  105081. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  105082. }
  105083. interface Mesh {
  105084. /**
  105085. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  105086. * @returns an array of IParticleSystem
  105087. */
  105088. getEmittedParticleSystems(): IParticleSystem[];
  105089. /**
  105090. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  105091. * @returns an array of IParticleSystem
  105092. */
  105093. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  105094. }
  105095. /**
  105096. * @hidden
  105097. */
  105098. export var _IDoNeedToBeInTheBuild: number;
  105099. }
  105100. declare module BABYLON {
  105101. interface Scene {
  105102. /** @hidden (Backing field) */
  105103. _physicsEngine: Nullable<IPhysicsEngine>;
  105104. /**
  105105. * Gets the current physics engine
  105106. * @returns a IPhysicsEngine or null if none attached
  105107. */
  105108. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  105109. /**
  105110. * Enables physics to the current scene
  105111. * @param gravity defines the scene's gravity for the physics engine
  105112. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  105113. * @return a boolean indicating if the physics engine was initialized
  105114. */
  105115. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  105116. /**
  105117. * Disables and disposes the physics engine associated with the scene
  105118. */
  105119. disablePhysicsEngine(): void;
  105120. /**
  105121. * Gets a boolean indicating if there is an active physics engine
  105122. * @returns a boolean indicating if there is an active physics engine
  105123. */
  105124. isPhysicsEnabled(): boolean;
  105125. /**
  105126. * Deletes a physics compound impostor
  105127. * @param compound defines the compound to delete
  105128. */
  105129. deleteCompoundImpostor(compound: any): void;
  105130. /**
  105131. * An event triggered when physic simulation is about to be run
  105132. */
  105133. onBeforePhysicsObservable: Observable<Scene>;
  105134. /**
  105135. * An event triggered when physic simulation has been done
  105136. */
  105137. onAfterPhysicsObservable: Observable<Scene>;
  105138. }
  105139. interface AbstractMesh {
  105140. /** @hidden */
  105141. _physicsImpostor: Nullable<PhysicsImpostor>;
  105142. /**
  105143. * Gets or sets impostor used for physic simulation
  105144. * @see http://doc.babylonjs.com/features/physics_engine
  105145. */
  105146. physicsImpostor: Nullable<PhysicsImpostor>;
  105147. /**
  105148. * Gets the current physics impostor
  105149. * @see http://doc.babylonjs.com/features/physics_engine
  105150. * @returns a physics impostor or null
  105151. */
  105152. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  105153. /** Apply a physic impulse to the mesh
  105154. * @param force defines the force to apply
  105155. * @param contactPoint defines where to apply the force
  105156. * @returns the current mesh
  105157. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105158. */
  105159. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  105160. /**
  105161. * Creates a physic joint between two meshes
  105162. * @param otherMesh defines the other mesh to use
  105163. * @param pivot1 defines the pivot to use on this mesh
  105164. * @param pivot2 defines the pivot to use on the other mesh
  105165. * @param options defines additional options (can be plugin dependent)
  105166. * @returns the current mesh
  105167. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  105168. */
  105169. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  105170. /** @hidden */
  105171. _disposePhysicsObserver: Nullable<Observer<Node>>;
  105172. }
  105173. /**
  105174. * Defines the physics engine scene component responsible to manage a physics engine
  105175. */
  105176. export class PhysicsEngineSceneComponent implements ISceneComponent {
  105177. /**
  105178. * The component name helpful to identify the component in the list of scene components.
  105179. */
  105180. readonly name: string;
  105181. /**
  105182. * The scene the component belongs to.
  105183. */
  105184. scene: Scene;
  105185. /**
  105186. * Creates a new instance of the component for the given scene
  105187. * @param scene Defines the scene to register the component in
  105188. */
  105189. constructor(scene: Scene);
  105190. /**
  105191. * Registers the component in a given scene
  105192. */
  105193. register(): void;
  105194. /**
  105195. * Rebuilds the elements related to this component in case of
  105196. * context lost for instance.
  105197. */
  105198. rebuild(): void;
  105199. /**
  105200. * Disposes the component and the associated ressources
  105201. */
  105202. dispose(): void;
  105203. }
  105204. }
  105205. declare module BABYLON {
  105206. /**
  105207. * A helper for physics simulations
  105208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105209. */
  105210. export class PhysicsHelper {
  105211. private _scene;
  105212. private _physicsEngine;
  105213. /**
  105214. * Initializes the Physics helper
  105215. * @param scene Babylon.js scene
  105216. */
  105217. constructor(scene: Scene);
  105218. /**
  105219. * Applies a radial explosion impulse
  105220. * @param origin the origin of the explosion
  105221. * @param radius the explosion radius
  105222. * @param strength the explosion strength
  105223. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105224. * @returns A physics radial explosion event, or null
  105225. */
  105226. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105227. /**
  105228. * Applies a radial explosion force
  105229. * @param origin the origin of the explosion
  105230. * @param radius the explosion radius
  105231. * @param strength the explosion strength
  105232. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105233. * @returns A physics radial explosion event, or null
  105234. */
  105235. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105236. /**
  105237. * Creates a gravitational field
  105238. * @param origin the origin of the explosion
  105239. * @param radius the explosion radius
  105240. * @param strength the explosion strength
  105241. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105242. * @returns A physics gravitational field event, or null
  105243. */
  105244. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105245. /**
  105246. * Creates a physics updraft event
  105247. * @param origin the origin of the updraft
  105248. * @param radius the radius of the updraft
  105249. * @param strength the strength of the updraft
  105250. * @param height the height of the updraft
  105251. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105252. * @returns A physics updraft event, or null
  105253. */
  105254. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105255. /**
  105256. * Creates a physics vortex event
  105257. * @param origin the of the vortex
  105258. * @param radius the radius of the vortex
  105259. * @param strength the strength of the vortex
  105260. * @param height the height of the vortex
  105261. * @returns a Physics vortex event, or null
  105262. * A physics vortex event or null
  105263. */
  105264. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105265. }
  105266. /**
  105267. * Represents a physics radial explosion event
  105268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105269. */
  105270. export class PhysicsRadialExplosionEvent {
  105271. private _scene;
  105272. private _sphere;
  105273. private _sphereOptions;
  105274. private _rays;
  105275. private _dataFetched;
  105276. /**
  105277. * Initializes a radial explosioin event
  105278. * @param scene BabylonJS scene
  105279. */
  105280. constructor(scene: Scene);
  105281. /**
  105282. * Returns the data related to the radial explosion event (sphere & rays).
  105283. * @returns The radial explosion event data
  105284. */
  105285. getData(): PhysicsRadialExplosionEventData;
  105286. /**
  105287. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105288. * @param impostor A physics imposter
  105289. * @param origin the origin of the explosion
  105290. * @param radius the explosion radius
  105291. * @param strength the explosion strength
  105292. * @param falloff possible options: Constant & Linear
  105293. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105294. */
  105295. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105296. /**
  105297. * Disposes the sphere.
  105298. * @param force Specifies if the sphere should be disposed by force
  105299. */
  105300. dispose(force?: boolean): void;
  105301. /*** Helpers ***/
  105302. private _prepareSphere;
  105303. private _intersectsWithSphere;
  105304. }
  105305. /**
  105306. * Represents a gravitational field event
  105307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105308. */
  105309. export class PhysicsGravitationalFieldEvent {
  105310. private _physicsHelper;
  105311. private _scene;
  105312. private _origin;
  105313. private _radius;
  105314. private _strength;
  105315. private _falloff;
  105316. private _tickCallback;
  105317. private _sphere;
  105318. private _dataFetched;
  105319. /**
  105320. * Initializes the physics gravitational field event
  105321. * @param physicsHelper A physics helper
  105322. * @param scene BabylonJS scene
  105323. * @param origin The origin position of the gravitational field event
  105324. * @param radius The radius of the gravitational field event
  105325. * @param strength The strength of the gravitational field event
  105326. * @param falloff The falloff for the gravitational field event
  105327. */
  105328. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105329. /**
  105330. * Returns the data related to the gravitational field event (sphere).
  105331. * @returns A gravitational field event
  105332. */
  105333. getData(): PhysicsGravitationalFieldEventData;
  105334. /**
  105335. * Enables the gravitational field.
  105336. */
  105337. enable(): void;
  105338. /**
  105339. * Disables the gravitational field.
  105340. */
  105341. disable(): void;
  105342. /**
  105343. * Disposes the sphere.
  105344. * @param force The force to dispose from the gravitational field event
  105345. */
  105346. dispose(force?: boolean): void;
  105347. private _tick;
  105348. }
  105349. /**
  105350. * Represents a physics updraft event
  105351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105352. */
  105353. export class PhysicsUpdraftEvent {
  105354. private _scene;
  105355. private _origin;
  105356. private _radius;
  105357. private _strength;
  105358. private _height;
  105359. private _updraftMode;
  105360. private _physicsEngine;
  105361. private _originTop;
  105362. private _originDirection;
  105363. private _tickCallback;
  105364. private _cylinder;
  105365. private _cylinderPosition;
  105366. private _dataFetched;
  105367. /**
  105368. * Initializes the physics updraft event
  105369. * @param _scene BabylonJS scene
  105370. * @param _origin The origin position of the updraft
  105371. * @param _radius The radius of the updraft
  105372. * @param _strength The strength of the updraft
  105373. * @param _height The height of the updraft
  105374. * @param _updraftMode The mode of the updraft
  105375. */
  105376. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105377. /**
  105378. * Returns the data related to the updraft event (cylinder).
  105379. * @returns A physics updraft event
  105380. */
  105381. getData(): PhysicsUpdraftEventData;
  105382. /**
  105383. * Enables the updraft.
  105384. */
  105385. enable(): void;
  105386. /**
  105387. * Disables the cortex.
  105388. */
  105389. disable(): void;
  105390. /**
  105391. * Disposes the sphere.
  105392. * @param force Specifies if the updraft should be disposed by force
  105393. */
  105394. dispose(force?: boolean): void;
  105395. private getImpostorForceAndContactPoint;
  105396. private _tick;
  105397. /*** Helpers ***/
  105398. private _prepareCylinder;
  105399. private _intersectsWithCylinder;
  105400. }
  105401. /**
  105402. * Represents a physics vortex event
  105403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105404. */
  105405. export class PhysicsVortexEvent {
  105406. private _scene;
  105407. private _origin;
  105408. private _radius;
  105409. private _strength;
  105410. private _height;
  105411. private _physicsEngine;
  105412. private _originTop;
  105413. private _centripetalForceThreshold;
  105414. private _updraftMultiplier;
  105415. private _tickCallback;
  105416. private _cylinder;
  105417. private _cylinderPosition;
  105418. private _dataFetched;
  105419. /**
  105420. * Initializes the physics vortex event
  105421. * @param _scene The BabylonJS scene
  105422. * @param _origin The origin position of the vortex
  105423. * @param _radius The radius of the vortex
  105424. * @param _strength The strength of the vortex
  105425. * @param _height The height of the vortex
  105426. */
  105427. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105428. /**
  105429. * Returns the data related to the vortex event (cylinder).
  105430. * @returns The physics vortex event data
  105431. */
  105432. getData(): PhysicsVortexEventData;
  105433. /**
  105434. * Enables the vortex.
  105435. */
  105436. enable(): void;
  105437. /**
  105438. * Disables the cortex.
  105439. */
  105440. disable(): void;
  105441. /**
  105442. * Disposes the sphere.
  105443. * @param force
  105444. */
  105445. dispose(force?: boolean): void;
  105446. private getImpostorForceAndContactPoint;
  105447. private _tick;
  105448. /*** Helpers ***/
  105449. private _prepareCylinder;
  105450. private _intersectsWithCylinder;
  105451. }
  105452. /**
  105453. * The strenght of the force in correspondence to the distance of the affected object
  105454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105455. */
  105456. export enum PhysicsRadialImpulseFalloff {
  105457. /** Defines that impulse is constant in strength across it's whole radius */
  105458. Constant = 0,
  105459. /** DEfines that impulse gets weaker if it's further from the origin */
  105460. Linear = 1
  105461. }
  105462. /**
  105463. * The strength of the force in correspondence to the distance of the affected object
  105464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105465. */
  105466. export enum PhysicsUpdraftMode {
  105467. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105468. Center = 0,
  105469. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  105470. Perpendicular = 1
  105471. }
  105472. /**
  105473. * Interface for a physics force and contact point
  105474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105475. */
  105476. export interface PhysicsForceAndContactPoint {
  105477. /**
  105478. * The force applied at the contact point
  105479. */
  105480. force: Vector3;
  105481. /**
  105482. * The contact point
  105483. */
  105484. contactPoint: Vector3;
  105485. }
  105486. /**
  105487. * Interface for radial explosion event data
  105488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105489. */
  105490. export interface PhysicsRadialExplosionEventData {
  105491. /**
  105492. * A sphere used for the radial explosion event
  105493. */
  105494. sphere: Mesh;
  105495. /**
  105496. * An array of rays for the radial explosion event
  105497. */
  105498. rays: Array<Ray>;
  105499. }
  105500. /**
  105501. * Interface for gravitational field event data
  105502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105503. */
  105504. export interface PhysicsGravitationalFieldEventData {
  105505. /**
  105506. * A sphere mesh used for the gravitational field event
  105507. */
  105508. sphere: Mesh;
  105509. }
  105510. /**
  105511. * Interface for updraft event data
  105512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105513. */
  105514. export interface PhysicsUpdraftEventData {
  105515. /**
  105516. * A cylinder used for the updraft event
  105517. */
  105518. cylinder: Mesh;
  105519. }
  105520. /**
  105521. * Interface for vortex event data
  105522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105523. */
  105524. export interface PhysicsVortexEventData {
  105525. /**
  105526. * A cylinder used for the vortex event
  105527. */
  105528. cylinder: Mesh;
  105529. }
  105530. }
  105531. declare module BABYLON {
  105532. /**
  105533. * AmmoJS Physics plugin
  105534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105535. * @see https://github.com/kripken/ammo.js/
  105536. */
  105537. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  105538. private _useDeltaForWorldStep;
  105539. /**
  105540. * Reference to the Ammo library
  105541. */
  105542. bjsAMMO: any;
  105543. /**
  105544. * Created ammoJS world which physics bodies are added to
  105545. */
  105546. world: any;
  105547. /**
  105548. * Name of the plugin
  105549. */
  105550. name: string;
  105551. private _timeStep;
  105552. private _fixedTimeStep;
  105553. private _maxSteps;
  105554. private _tmpQuaternion;
  105555. private _tmpAmmoTransform;
  105556. private _tmpAmmoQuaternion;
  105557. private _tmpAmmoConcreteContactResultCallback;
  105558. private _collisionConfiguration;
  105559. private _dispatcher;
  105560. private _overlappingPairCache;
  105561. private _solver;
  105562. private _tmpAmmoVectorA;
  105563. private _tmpAmmoVectorB;
  105564. private _tmpAmmoVectorC;
  105565. private _tmpContactCallbackResult;
  105566. private static readonly DISABLE_COLLISION_FLAG;
  105567. private static readonly KINEMATIC_FLAG;
  105568. private static readonly DISABLE_DEACTIVATION_FLAG;
  105569. /**
  105570. * Initializes the ammoJS plugin
  105571. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  105572. * @param ammoInjection can be used to inject your own ammo reference
  105573. */
  105574. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  105575. /**
  105576. * Sets the gravity of the physics world (m/(s^2))
  105577. * @param gravity Gravity to set
  105578. */
  105579. setGravity(gravity: Vector3): void;
  105580. /**
  105581. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  105582. * @param timeStep timestep to use in seconds
  105583. */
  105584. setTimeStep(timeStep: number): void;
  105585. /**
  105586. * 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)
  105587. * @param fixedTimeStep fixedTimeStep to use in seconds
  105588. */
  105589. setFixedTimeStep(fixedTimeStep: number): void;
  105590. /**
  105591. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  105592. * @param maxSteps the maximum number of steps by the physics engine per frame
  105593. */
  105594. setMaxSteps(maxSteps: number): void;
  105595. /**
  105596. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  105597. * @returns the current timestep in seconds
  105598. */
  105599. getTimeStep(): number;
  105600. private _isImpostorInContact;
  105601. private _isImpostorPairInContact;
  105602. private _stepSimulation;
  105603. /**
  105604. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  105605. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  105606. * After the step the babylon meshes are set to the position of the physics imposters
  105607. * @param delta amount of time to step forward
  105608. * @param impostors array of imposters to update before/after the step
  105609. */
  105610. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105611. private _tmpVector;
  105612. private _tmpMatrix;
  105613. /**
  105614. * Applies an implulse on the imposter
  105615. * @param impostor imposter to apply impulse
  105616. * @param force amount of force to be applied to the imposter
  105617. * @param contactPoint the location to apply the impulse on the imposter
  105618. */
  105619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105620. /**
  105621. * Applies a force on the imposter
  105622. * @param impostor imposter to apply force
  105623. * @param force amount of force to be applied to the imposter
  105624. * @param contactPoint the location to apply the force on the imposter
  105625. */
  105626. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105627. /**
  105628. * Creates a physics body using the plugin
  105629. * @param impostor the imposter to create the physics body on
  105630. */
  105631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105632. /**
  105633. * Removes the physics body from the imposter and disposes of the body's memory
  105634. * @param impostor imposter to remove the physics body from
  105635. */
  105636. removePhysicsBody(impostor: PhysicsImpostor): void;
  105637. /**
  105638. * Generates a joint
  105639. * @param impostorJoint the imposter joint to create the joint with
  105640. */
  105641. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105642. /**
  105643. * Removes a joint
  105644. * @param impostorJoint the imposter joint to remove the joint from
  105645. */
  105646. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105647. private _addMeshVerts;
  105648. private _createShape;
  105649. /**
  105650. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  105651. * @param impostor imposter containing the physics body and babylon object
  105652. */
  105653. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105654. /**
  105655. * Sets the babylon object's position/rotation from the physics body's position/rotation
  105656. * @param impostor imposter containing the physics body and babylon object
  105657. * @param newPosition new position
  105658. * @param newRotation new rotation
  105659. */
  105660. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105661. /**
  105662. * If this plugin is supported
  105663. * @returns true if its supported
  105664. */
  105665. isSupported(): boolean;
  105666. /**
  105667. * Sets the linear velocity of the physics body
  105668. * @param impostor imposter to set the velocity on
  105669. * @param velocity velocity to set
  105670. */
  105671. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105672. /**
  105673. * Sets the angular velocity of the physics body
  105674. * @param impostor imposter to set the velocity on
  105675. * @param velocity velocity to set
  105676. */
  105677. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105678. /**
  105679. * gets the linear velocity
  105680. * @param impostor imposter to get linear velocity from
  105681. * @returns linear velocity
  105682. */
  105683. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105684. /**
  105685. * gets the angular velocity
  105686. * @param impostor imposter to get angular velocity from
  105687. * @returns angular velocity
  105688. */
  105689. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105690. /**
  105691. * Sets the mass of physics body
  105692. * @param impostor imposter to set the mass on
  105693. * @param mass mass to set
  105694. */
  105695. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105696. /**
  105697. * Gets the mass of the physics body
  105698. * @param impostor imposter to get the mass from
  105699. * @returns mass
  105700. */
  105701. getBodyMass(impostor: PhysicsImpostor): number;
  105702. /**
  105703. * Gets friction of the impostor
  105704. * @param impostor impostor to get friction from
  105705. * @returns friction value
  105706. */
  105707. getBodyFriction(impostor: PhysicsImpostor): number;
  105708. /**
  105709. * Sets friction of the impostor
  105710. * @param impostor impostor to set friction on
  105711. * @param friction friction value
  105712. */
  105713. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105714. /**
  105715. * Gets restitution of the impostor
  105716. * @param impostor impostor to get restitution from
  105717. * @returns restitution value
  105718. */
  105719. getBodyRestitution(impostor: PhysicsImpostor): number;
  105720. /**
  105721. * Sets resitution of the impostor
  105722. * @param impostor impostor to set resitution on
  105723. * @param restitution resitution value
  105724. */
  105725. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105726. /**
  105727. * Sleeps the physics body and stops it from being active
  105728. * @param impostor impostor to sleep
  105729. */
  105730. sleepBody(impostor: PhysicsImpostor): void;
  105731. /**
  105732. * Activates the physics body
  105733. * @param impostor impostor to activate
  105734. */
  105735. wakeUpBody(impostor: PhysicsImpostor): void;
  105736. /**
  105737. * Updates the distance parameters of the joint
  105738. * @param joint joint to update
  105739. * @param maxDistance maximum distance of the joint
  105740. * @param minDistance minimum distance of the joint
  105741. */
  105742. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105743. /**
  105744. * Sets a motor on the joint
  105745. * @param joint joint to set motor on
  105746. * @param speed speed of the motor
  105747. * @param maxForce maximum force of the motor
  105748. * @param motorIndex index of the motor
  105749. */
  105750. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105751. /**
  105752. * Sets the motors limit
  105753. * @param joint joint to set limit on
  105754. * @param upperLimit upper limit
  105755. * @param lowerLimit lower limit
  105756. */
  105757. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105758. /**
  105759. * Syncs the position and rotation of a mesh with the impostor
  105760. * @param mesh mesh to sync
  105761. * @param impostor impostor to update the mesh with
  105762. */
  105763. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105764. /**
  105765. * Gets the radius of the impostor
  105766. * @param impostor impostor to get radius from
  105767. * @returns the radius
  105768. */
  105769. getRadius(impostor: PhysicsImpostor): number;
  105770. /**
  105771. * Gets the box size of the impostor
  105772. * @param impostor impostor to get box size from
  105773. * @param result the resulting box size
  105774. */
  105775. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105776. /**
  105777. * Disposes of the impostor
  105778. */
  105779. dispose(): void;
  105780. }
  105781. }
  105782. declare module BABYLON {
  105783. /** @hidden */
  105784. export var blackAndWhitePixelShader: {
  105785. name: string;
  105786. shader: string;
  105787. };
  105788. }
  105789. declare module BABYLON {
  105790. /**
  105791. * Post process used to render in black and white
  105792. */
  105793. export class BlackAndWhitePostProcess extends PostProcess {
  105794. /**
  105795. * Linear about to convert he result to black and white (default: 1)
  105796. */
  105797. degree: number;
  105798. /**
  105799. * Creates a black and white post process
  105800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  105801. * @param name The name of the effect.
  105802. * @param options The required width/height ratio to downsize to before computing the render pass.
  105803. * @param camera The camera to apply the render pass to.
  105804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105805. * @param engine The engine which the post process will be applied. (default: current engine)
  105806. * @param reusable If the post process can be reused on the same frame. (default: false)
  105807. */
  105808. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105809. }
  105810. }
  105811. declare module BABYLON {
  105812. /**
  105813. * This represents a set of one or more post processes in Babylon.
  105814. * A post process can be used to apply a shader to a texture after it is rendered.
  105815. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105816. */
  105817. export class PostProcessRenderEffect {
  105818. private _postProcesses;
  105819. private _getPostProcesses;
  105820. private _singleInstance;
  105821. private _cameras;
  105822. private _indicesForCamera;
  105823. /**
  105824. * Name of the effect
  105825. * @hidden
  105826. */
  105827. _name: string;
  105828. /**
  105829. * Instantiates a post process render effect.
  105830. * A post process can be used to apply a shader to a texture after it is rendered.
  105831. * @param engine The engine the effect is tied to
  105832. * @param name The name of the effect
  105833. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  105834. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  105835. */
  105836. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  105837. /**
  105838. * Checks if all the post processes in the effect are supported.
  105839. */
  105840. readonly isSupported: boolean;
  105841. /**
  105842. * Updates the current state of the effect
  105843. * @hidden
  105844. */
  105845. _update(): void;
  105846. /**
  105847. * Attaches the effect on cameras
  105848. * @param cameras The camera to attach to.
  105849. * @hidden
  105850. */
  105851. _attachCameras(cameras: Camera): void;
  105852. /**
  105853. * Attaches the effect on cameras
  105854. * @param cameras The camera to attach to.
  105855. * @hidden
  105856. */
  105857. _attachCameras(cameras: Camera[]): void;
  105858. /**
  105859. * Detatches the effect on cameras
  105860. * @param cameras The camera to detatch from.
  105861. * @hidden
  105862. */
  105863. _detachCameras(cameras: Camera): void;
  105864. /**
  105865. * Detatches the effect on cameras
  105866. * @param cameras The camera to detatch from.
  105867. * @hidden
  105868. */
  105869. _detachCameras(cameras: Camera[]): void;
  105870. /**
  105871. * Enables the effect on given cameras
  105872. * @param cameras The camera to enable.
  105873. * @hidden
  105874. */
  105875. _enable(cameras: Camera): void;
  105876. /**
  105877. * Enables the effect on given cameras
  105878. * @param cameras The camera to enable.
  105879. * @hidden
  105880. */
  105881. _enable(cameras: Nullable<Camera[]>): void;
  105882. /**
  105883. * Disables the effect on the given cameras
  105884. * @param cameras The camera to disable.
  105885. * @hidden
  105886. */
  105887. _disable(cameras: Camera): void;
  105888. /**
  105889. * Disables the effect on the given cameras
  105890. * @param cameras The camera to disable.
  105891. * @hidden
  105892. */
  105893. _disable(cameras: Nullable<Camera[]>): void;
  105894. /**
  105895. * Gets a list of the post processes contained in the effect.
  105896. * @param camera The camera to get the post processes on.
  105897. * @returns The list of the post processes in the effect.
  105898. */
  105899. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  105900. }
  105901. }
  105902. declare module BABYLON {
  105903. /** @hidden */
  105904. export var extractHighlightsPixelShader: {
  105905. name: string;
  105906. shader: string;
  105907. };
  105908. }
  105909. declare module BABYLON {
  105910. /**
  105911. * 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.
  105912. */
  105913. export class ExtractHighlightsPostProcess extends PostProcess {
  105914. /**
  105915. * The luminance threshold, pixels below this value will be set to black.
  105916. */
  105917. threshold: number;
  105918. /** @hidden */
  105919. _exposure: number;
  105920. /**
  105921. * Post process which has the input texture to be used when performing highlight extraction
  105922. * @hidden
  105923. */
  105924. _inputPostProcess: Nullable<PostProcess>;
  105925. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105926. }
  105927. }
  105928. declare module BABYLON {
  105929. /** @hidden */
  105930. export var bloomMergePixelShader: {
  105931. name: string;
  105932. shader: string;
  105933. };
  105934. }
  105935. declare module BABYLON {
  105936. /**
  105937. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105938. */
  105939. export class BloomMergePostProcess extends PostProcess {
  105940. /** Weight of the bloom to be added to the original input. */
  105941. weight: number;
  105942. /**
  105943. * Creates a new instance of @see BloomMergePostProcess
  105944. * @param name The name of the effect.
  105945. * @param originalFromInput Post process which's input will be used for the merge.
  105946. * @param blurred Blurred highlights post process which's output will be used.
  105947. * @param weight Weight of the bloom to be added to the original input.
  105948. * @param options The required width/height ratio to downsize to before computing the render pass.
  105949. * @param camera The camera to apply the render pass to.
  105950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105951. * @param engine The engine which the post process will be applied. (default: current engine)
  105952. * @param reusable If the post process can be reused on the same frame. (default: false)
  105953. * @param textureType Type of textures used when performing the post process. (default: 0)
  105954. * @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)
  105955. */
  105956. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  105957. /** Weight of the bloom to be added to the original input. */
  105958. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105959. }
  105960. }
  105961. declare module BABYLON {
  105962. /**
  105963. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  105964. */
  105965. export class BloomEffect extends PostProcessRenderEffect {
  105966. private bloomScale;
  105967. /**
  105968. * @hidden Internal
  105969. */
  105970. _effects: Array<PostProcess>;
  105971. /**
  105972. * @hidden Internal
  105973. */
  105974. _downscale: ExtractHighlightsPostProcess;
  105975. private _blurX;
  105976. private _blurY;
  105977. private _merge;
  105978. /**
  105979. * The luminance threshold to find bright areas of the image to bloom.
  105980. */
  105981. threshold: number;
  105982. /**
  105983. * The strength of the bloom.
  105984. */
  105985. weight: number;
  105986. /**
  105987. * Specifies the size of the bloom blur kernel, relative to the final output size
  105988. */
  105989. kernel: number;
  105990. /**
  105991. * Creates a new instance of @see BloomEffect
  105992. * @param scene The scene the effect belongs to.
  105993. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105994. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105995. * @param bloomWeight The the strength of bloom.
  105996. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105997. * @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)
  105998. */
  105999. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  106000. /**
  106001. * Disposes each of the internal effects for a given camera.
  106002. * @param camera The camera to dispose the effect on.
  106003. */
  106004. disposeEffects(camera: Camera): void;
  106005. /**
  106006. * @hidden Internal
  106007. */
  106008. _updateEffects(): void;
  106009. /**
  106010. * Internal
  106011. * @returns if all the contained post processes are ready.
  106012. * @hidden
  106013. */
  106014. _isReady(): boolean;
  106015. }
  106016. }
  106017. declare module BABYLON {
  106018. /** @hidden */
  106019. export var chromaticAberrationPixelShader: {
  106020. name: string;
  106021. shader: string;
  106022. };
  106023. }
  106024. declare module BABYLON {
  106025. /**
  106026. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  106027. */
  106028. export class ChromaticAberrationPostProcess extends PostProcess {
  106029. /**
  106030. * The amount of seperation of rgb channels (default: 30)
  106031. */
  106032. aberrationAmount: number;
  106033. /**
  106034. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  106035. */
  106036. radialIntensity: number;
  106037. /**
  106038. * 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))
  106039. */
  106040. direction: Vector2;
  106041. /**
  106042. * 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))
  106043. */
  106044. centerPosition: Vector2;
  106045. /**
  106046. * Creates a new instance ChromaticAberrationPostProcess
  106047. * @param name The name of the effect.
  106048. * @param screenWidth The width of the screen to apply the effect on.
  106049. * @param screenHeight The height of the screen to apply the effect on.
  106050. * @param options The required width/height ratio to downsize to before computing the render pass.
  106051. * @param camera The camera to apply the render pass to.
  106052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106053. * @param engine The engine which the post process will be applied. (default: current engine)
  106054. * @param reusable If the post process can be reused on the same frame. (default: false)
  106055. * @param textureType Type of textures used when performing the post process. (default: 0)
  106056. * @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)
  106057. */
  106058. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106059. }
  106060. }
  106061. declare module BABYLON {
  106062. /** @hidden */
  106063. export var circleOfConfusionPixelShader: {
  106064. name: string;
  106065. shader: string;
  106066. };
  106067. }
  106068. declare module BABYLON {
  106069. /**
  106070. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  106071. */
  106072. export class CircleOfConfusionPostProcess extends PostProcess {
  106073. /**
  106074. * 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.
  106075. */
  106076. lensSize: number;
  106077. /**
  106078. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106079. */
  106080. fStop: number;
  106081. /**
  106082. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106083. */
  106084. focusDistance: number;
  106085. /**
  106086. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  106087. */
  106088. focalLength: number;
  106089. private _depthTexture;
  106090. /**
  106091. * Creates a new instance CircleOfConfusionPostProcess
  106092. * @param name The name of the effect.
  106093. * @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.
  106094. * @param options The required width/height ratio to downsize to before computing the render pass.
  106095. * @param camera The camera to apply the render pass to.
  106096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106097. * @param engine The engine which the post process will be applied. (default: current engine)
  106098. * @param reusable If the post process can be reused on the same frame. (default: false)
  106099. * @param textureType Type of textures used when performing the post process. (default: 0)
  106100. * @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)
  106101. */
  106102. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106103. /**
  106104. * 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.
  106105. */
  106106. depthTexture: RenderTargetTexture;
  106107. }
  106108. }
  106109. declare module BABYLON {
  106110. /** @hidden */
  106111. export var colorCorrectionPixelShader: {
  106112. name: string;
  106113. shader: string;
  106114. };
  106115. }
  106116. declare module BABYLON {
  106117. /**
  106118. *
  106119. * This post-process allows the modification of rendered colors by using
  106120. * a 'look-up table' (LUT). This effect is also called Color Grading.
  106121. *
  106122. * The object needs to be provided an url to a texture containing the color
  106123. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  106124. * Use an image editing software to tweak the LUT to match your needs.
  106125. *
  106126. * For an example of a color LUT, see here:
  106127. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  106128. * For explanations on color grading, see here:
  106129. * @see http://udn.epicgames.com/Three/ColorGrading.html
  106130. *
  106131. */
  106132. export class ColorCorrectionPostProcess extends PostProcess {
  106133. private _colorTableTexture;
  106134. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106135. }
  106136. }
  106137. declare module BABYLON {
  106138. /** @hidden */
  106139. export var convolutionPixelShader: {
  106140. name: string;
  106141. shader: string;
  106142. };
  106143. }
  106144. declare module BABYLON {
  106145. /**
  106146. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106147. * input texture to perform effects such as edge detection or sharpening
  106148. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106149. */
  106150. export class ConvolutionPostProcess extends PostProcess {
  106151. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106152. kernel: number[];
  106153. /**
  106154. * Creates a new instance ConvolutionPostProcess
  106155. * @param name The name of the effect.
  106156. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  106157. * @param options The required width/height ratio to downsize to before computing the render pass.
  106158. * @param camera The camera to apply the render pass to.
  106159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106160. * @param engine The engine which the post process will be applied. (default: current engine)
  106161. * @param reusable If the post process can be reused on the same frame. (default: false)
  106162. * @param textureType Type of textures used when performing the post process. (default: 0)
  106163. */
  106164. constructor(name: string,
  106165. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  106166. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106167. /**
  106168. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106169. */
  106170. static EdgeDetect0Kernel: number[];
  106171. /**
  106172. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106173. */
  106174. static EdgeDetect1Kernel: number[];
  106175. /**
  106176. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106177. */
  106178. static EdgeDetect2Kernel: number[];
  106179. /**
  106180. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106181. */
  106182. static SharpenKernel: number[];
  106183. /**
  106184. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106185. */
  106186. static EmbossKernel: number[];
  106187. /**
  106188. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106189. */
  106190. static GaussianKernel: number[];
  106191. }
  106192. }
  106193. declare module BABYLON {
  106194. /**
  106195. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106196. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106197. * based on samples that have a large difference in distance than the center pixel.
  106198. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106199. */
  106200. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106201. direction: Vector2;
  106202. /**
  106203. * Creates a new instance CircleOfConfusionPostProcess
  106204. * @param name The name of the effect.
  106205. * @param scene The scene the effect belongs to.
  106206. * @param direction The direction the blur should be applied.
  106207. * @param kernel The size of the kernel used to blur.
  106208. * @param options The required width/height ratio to downsize to before computing the render pass.
  106209. * @param camera The camera to apply the render pass to.
  106210. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106211. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106213. * @param engine The engine which the post process will be applied. (default: current engine)
  106214. * @param reusable If the post process can be reused on the same frame. (default: false)
  106215. * @param textureType Type of textures used when performing the post process. (default: 0)
  106216. * @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)
  106217. */
  106218. 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);
  106219. }
  106220. }
  106221. declare module BABYLON {
  106222. /** @hidden */
  106223. export var depthOfFieldMergePixelShader: {
  106224. name: string;
  106225. shader: string;
  106226. };
  106227. }
  106228. declare module BABYLON {
  106229. /**
  106230. * Options to be set when merging outputs from the default pipeline.
  106231. */
  106232. export class DepthOfFieldMergePostProcessOptions {
  106233. /**
  106234. * The original image to merge on top of
  106235. */
  106236. originalFromInput: PostProcess;
  106237. /**
  106238. * Parameters to perform the merge of the depth of field effect
  106239. */
  106240. depthOfField?: {
  106241. circleOfConfusion: PostProcess;
  106242. blurSteps: Array<PostProcess>;
  106243. };
  106244. /**
  106245. * Parameters to perform the merge of bloom effect
  106246. */
  106247. bloom?: {
  106248. blurred: PostProcess;
  106249. weight: number;
  106250. };
  106251. }
  106252. /**
  106253. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106254. */
  106255. export class DepthOfFieldMergePostProcess extends PostProcess {
  106256. private blurSteps;
  106257. /**
  106258. * Creates a new instance of DepthOfFieldMergePostProcess
  106259. * @param name The name of the effect.
  106260. * @param originalFromInput Post process which's input will be used for the merge.
  106261. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106262. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106263. * @param options The required width/height ratio to downsize to before computing the render pass.
  106264. * @param camera The camera to apply the render pass to.
  106265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106266. * @param engine The engine which the post process will be applied. (default: current engine)
  106267. * @param reusable If the post process can be reused on the same frame. (default: false)
  106268. * @param textureType Type of textures used when performing the post process. (default: 0)
  106269. * @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)
  106270. */
  106271. 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);
  106272. /**
  106273. * Updates the effect with the current post process compile time values and recompiles the shader.
  106274. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106275. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106276. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106277. * @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
  106278. * @param onCompiled Called when the shader has been compiled.
  106279. * @param onError Called if there is an error when compiling a shader.
  106280. */
  106281. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106282. }
  106283. }
  106284. declare module BABYLON {
  106285. /**
  106286. * Specifies the level of max blur that should be applied when using the depth of field effect
  106287. */
  106288. export enum DepthOfFieldEffectBlurLevel {
  106289. /**
  106290. * Subtle blur
  106291. */
  106292. Low = 0,
  106293. /**
  106294. * Medium blur
  106295. */
  106296. Medium = 1,
  106297. /**
  106298. * Large blur
  106299. */
  106300. High = 2
  106301. }
  106302. /**
  106303. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106304. */
  106305. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106306. private _circleOfConfusion;
  106307. /**
  106308. * @hidden Internal, blurs from high to low
  106309. */
  106310. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106311. private _depthOfFieldBlurY;
  106312. private _dofMerge;
  106313. /**
  106314. * @hidden Internal post processes in depth of field effect
  106315. */
  106316. _effects: Array<PostProcess>;
  106317. /**
  106318. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106319. */
  106320. focalLength: number;
  106321. /**
  106322. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106323. */
  106324. fStop: number;
  106325. /**
  106326. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106327. */
  106328. focusDistance: number;
  106329. /**
  106330. * 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.
  106331. */
  106332. lensSize: number;
  106333. /**
  106334. * Creates a new instance DepthOfFieldEffect
  106335. * @param scene The scene the effect belongs to.
  106336. * @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.
  106337. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106338. * @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)
  106339. */
  106340. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106341. /**
  106342. * 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.
  106343. */
  106344. depthTexture: RenderTargetTexture;
  106345. /**
  106346. * Disposes each of the internal effects for a given camera.
  106347. * @param camera The camera to dispose the effect on.
  106348. */
  106349. disposeEffects(camera: Camera): void;
  106350. /**
  106351. * @hidden Internal
  106352. */
  106353. _updateEffects(): void;
  106354. /**
  106355. * Internal
  106356. * @returns if all the contained post processes are ready.
  106357. * @hidden
  106358. */
  106359. _isReady(): boolean;
  106360. }
  106361. }
  106362. declare module BABYLON {
  106363. /** @hidden */
  106364. export var displayPassPixelShader: {
  106365. name: string;
  106366. shader: string;
  106367. };
  106368. }
  106369. declare module BABYLON {
  106370. /**
  106371. * DisplayPassPostProcess which produces an output the same as it's input
  106372. */
  106373. export class DisplayPassPostProcess extends PostProcess {
  106374. /**
  106375. * Creates the DisplayPassPostProcess
  106376. * @param name The name of the effect.
  106377. * @param options The required width/height ratio to downsize to before computing the render pass.
  106378. * @param camera The camera to apply the render pass to.
  106379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106380. * @param engine The engine which the post process will be applied. (default: current engine)
  106381. * @param reusable If the post process can be reused on the same frame. (default: false)
  106382. */
  106383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106384. }
  106385. }
  106386. declare module BABYLON {
  106387. /** @hidden */
  106388. export var filterPixelShader: {
  106389. name: string;
  106390. shader: string;
  106391. };
  106392. }
  106393. declare module BABYLON {
  106394. /**
  106395. * Applies a kernel filter to the image
  106396. */
  106397. export class FilterPostProcess extends PostProcess {
  106398. /** The matrix to be applied to the image */
  106399. kernelMatrix: Matrix;
  106400. /**
  106401. *
  106402. * @param name The name of the effect.
  106403. * @param kernelMatrix The matrix to be applied to the image
  106404. * @param options The required width/height ratio to downsize to before computing the render pass.
  106405. * @param camera The camera to apply the render pass to.
  106406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106407. * @param engine The engine which the post process will be applied. (default: current engine)
  106408. * @param reusable If the post process can be reused on the same frame. (default: false)
  106409. */
  106410. constructor(name: string,
  106411. /** The matrix to be applied to the image */
  106412. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106413. }
  106414. }
  106415. declare module BABYLON {
  106416. /** @hidden */
  106417. export var fxaaPixelShader: {
  106418. name: string;
  106419. shader: string;
  106420. };
  106421. }
  106422. declare module BABYLON {
  106423. /** @hidden */
  106424. export var fxaaVertexShader: {
  106425. name: string;
  106426. shader: string;
  106427. };
  106428. }
  106429. declare module BABYLON {
  106430. /**
  106431. * Fxaa post process
  106432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106433. */
  106434. export class FxaaPostProcess extends PostProcess {
  106435. /** @hidden */
  106436. texelWidth: number;
  106437. /** @hidden */
  106438. texelHeight: number;
  106439. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106440. private _getDefines;
  106441. }
  106442. }
  106443. declare module BABYLON {
  106444. /** @hidden */
  106445. export var grainPixelShader: {
  106446. name: string;
  106447. shader: string;
  106448. };
  106449. }
  106450. declare module BABYLON {
  106451. /**
  106452. * The GrainPostProcess adds noise to the image at mid luminance levels
  106453. */
  106454. export class GrainPostProcess extends PostProcess {
  106455. /**
  106456. * The intensity of the grain added (default: 30)
  106457. */
  106458. intensity: number;
  106459. /**
  106460. * If the grain should be randomized on every frame
  106461. */
  106462. animated: boolean;
  106463. /**
  106464. * Creates a new instance of @see GrainPostProcess
  106465. * @param name The name of the effect.
  106466. * @param options The required width/height ratio to downsize to before computing the render pass.
  106467. * @param camera The camera to apply the render pass to.
  106468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106469. * @param engine The engine which the post process will be applied. (default: current engine)
  106470. * @param reusable If the post process can be reused on the same frame. (default: false)
  106471. * @param textureType Type of textures used when performing the post process. (default: 0)
  106472. * @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)
  106473. */
  106474. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106475. }
  106476. }
  106477. declare module BABYLON {
  106478. /** @hidden */
  106479. export var highlightsPixelShader: {
  106480. name: string;
  106481. shader: string;
  106482. };
  106483. }
  106484. declare module BABYLON {
  106485. /**
  106486. * Extracts highlights from the image
  106487. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106488. */
  106489. export class HighlightsPostProcess extends PostProcess {
  106490. /**
  106491. * Extracts highlights from the image
  106492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106493. * @param name The name of the effect.
  106494. * @param options The required width/height ratio to downsize to before computing the render pass.
  106495. * @param camera The camera to apply the render pass to.
  106496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106497. * @param engine The engine which the post process will be applied. (default: current engine)
  106498. * @param reusable If the post process can be reused on the same frame. (default: false)
  106499. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  106500. */
  106501. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106502. }
  106503. }
  106504. declare module BABYLON {
  106505. /** @hidden */
  106506. export var mrtFragmentDeclaration: {
  106507. name: string;
  106508. shader: string;
  106509. };
  106510. }
  106511. declare module BABYLON {
  106512. /** @hidden */
  106513. export var geometryPixelShader: {
  106514. name: string;
  106515. shader: string;
  106516. };
  106517. }
  106518. declare module BABYLON {
  106519. /** @hidden */
  106520. export var geometryVertexShader: {
  106521. name: string;
  106522. shader: string;
  106523. };
  106524. }
  106525. declare module BABYLON {
  106526. /**
  106527. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  106528. */
  106529. export class GeometryBufferRenderer {
  106530. /**
  106531. * Constant used to retrieve the position texture index in the G-Buffer textures array
  106532. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  106533. */
  106534. static readonly POSITION_TEXTURE_TYPE: number;
  106535. /**
  106536. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  106537. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  106538. */
  106539. static readonly VELOCITY_TEXTURE_TYPE: number;
  106540. /**
  106541. * Dictionary used to store the previous transformation matrices of each rendered mesh
  106542. * in order to compute objects velocities when enableVelocity is set to "true"
  106543. * @hidden
  106544. */
  106545. _previousTransformationMatrices: {
  106546. [index: number]: Matrix;
  106547. };
  106548. private _scene;
  106549. private _multiRenderTarget;
  106550. private _ratio;
  106551. private _enablePosition;
  106552. private _enableVelocity;
  106553. private _positionIndex;
  106554. private _velocityIndex;
  106555. protected _effect: Effect;
  106556. protected _cachedDefines: string;
  106557. /**
  106558. * Set the render list (meshes to be rendered) used in the G buffer.
  106559. */
  106560. renderList: Mesh[];
  106561. /**
  106562. * Gets wether or not G buffer are supported by the running hardware.
  106563. * This requires draw buffer supports
  106564. */
  106565. readonly isSupported: boolean;
  106566. /**
  106567. * Returns the index of the given texture type in the G-Buffer textures array
  106568. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  106569. * @returns the index of the given texture type in the G-Buffer textures array
  106570. */
  106571. getTextureIndex(textureType: number): number;
  106572. /**
  106573. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  106574. */
  106575. /**
  106576. * Sets whether or not objects positions are enabled for the G buffer.
  106577. */
  106578. enablePosition: boolean;
  106579. /**
  106580. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  106581. */
  106582. /**
  106583. * Sets wether or not objects velocities are enabled for the G buffer.
  106584. */
  106585. enableVelocity: boolean;
  106586. /**
  106587. * Gets the scene associated with the buffer.
  106588. */
  106589. readonly scene: Scene;
  106590. /**
  106591. * Gets the ratio used by the buffer during its creation.
  106592. * How big is the buffer related to the main canvas.
  106593. */
  106594. readonly ratio: number;
  106595. /** @hidden */
  106596. static _SceneComponentInitialization: (scene: Scene) => void;
  106597. /**
  106598. * Creates a new G Buffer for the scene
  106599. * @param scene The scene the buffer belongs to
  106600. * @param ratio How big is the buffer related to the main canvas.
  106601. */
  106602. constructor(scene: Scene, ratio?: number);
  106603. /**
  106604. * Checks wether everything is ready to render a submesh to the G buffer.
  106605. * @param subMesh the submesh to check readiness for
  106606. * @param useInstances is the mesh drawn using instance or not
  106607. * @returns true if ready otherwise false
  106608. */
  106609. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106610. /**
  106611. * Gets the current underlying G Buffer.
  106612. * @returns the buffer
  106613. */
  106614. getGBuffer(): MultiRenderTarget;
  106615. /**
  106616. * Gets the number of samples used to render the buffer (anti aliasing).
  106617. */
  106618. /**
  106619. * Sets the number of samples used to render the buffer (anti aliasing).
  106620. */
  106621. samples: number;
  106622. /**
  106623. * Disposes the renderer and frees up associated resources.
  106624. */
  106625. dispose(): void;
  106626. protected _createRenderTargets(): void;
  106627. }
  106628. }
  106629. declare module BABYLON {
  106630. /** @hidden */
  106631. export var motionBlurPixelShader: {
  106632. name: string;
  106633. shader: string;
  106634. };
  106635. }
  106636. declare module BABYLON {
  106637. /**
  106638. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  106639. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  106640. * As an example, all you have to do is to create the post-process:
  106641. * var mb = new BABYLON.MotionBlurPostProcess(
  106642. * 'mb', // The name of the effect.
  106643. * scene, // The scene containing the objects to blur according to their velocity.
  106644. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  106645. * camera // The camera to apply the render pass to.
  106646. * );
  106647. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  106648. */
  106649. export class MotionBlurPostProcess extends PostProcess {
  106650. /**
  106651. * Defines how much the image is blurred by the movement. Default value is equal to 1
  106652. */
  106653. motionStrength: number;
  106654. /**
  106655. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  106656. */
  106657. /**
  106658. * Sets the number of iterations to be used for motion blur quality
  106659. */
  106660. motionBlurSamples: number;
  106661. private _motionBlurSamples;
  106662. private _geometryBufferRenderer;
  106663. /**
  106664. * Creates a new instance MotionBlurPostProcess
  106665. * @param name The name of the effect.
  106666. * @param scene The scene containing the objects to blur according to their velocity.
  106667. * @param options The required width/height ratio to downsize to before computing the render pass.
  106668. * @param camera The camera to apply the render pass to.
  106669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106670. * @param engine The engine which the post process will be applied. (default: current engine)
  106671. * @param reusable If the post process can be reused on the same frame. (default: false)
  106672. * @param textureType Type of textures used when performing the post process. (default: 0)
  106673. * @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)
  106674. */
  106675. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106676. /**
  106677. * Disposes the post process.
  106678. * @param camera The camera to dispose the post process on.
  106679. */
  106680. dispose(camera?: Camera): void;
  106681. }
  106682. }
  106683. declare module BABYLON {
  106684. /** @hidden */
  106685. export var refractionPixelShader: {
  106686. name: string;
  106687. shader: string;
  106688. };
  106689. }
  106690. declare module BABYLON {
  106691. /**
  106692. * Post process which applies a refractin texture
  106693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106694. */
  106695. export class RefractionPostProcess extends PostProcess {
  106696. /** the base color of the refraction (used to taint the rendering) */
  106697. color: Color3;
  106698. /** simulated refraction depth */
  106699. depth: number;
  106700. /** the coefficient of the base color (0 to remove base color tainting) */
  106701. colorLevel: number;
  106702. private _refTexture;
  106703. private _ownRefractionTexture;
  106704. /**
  106705. * Gets or sets the refraction texture
  106706. * Please note that you are responsible for disposing the texture if you set it manually
  106707. */
  106708. refractionTexture: Texture;
  106709. /**
  106710. * Initializes the RefractionPostProcess
  106711. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106712. * @param name The name of the effect.
  106713. * @param refractionTextureUrl Url of the refraction texture to use
  106714. * @param color the base color of the refraction (used to taint the rendering)
  106715. * @param depth simulated refraction depth
  106716. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  106717. * @param camera The camera to apply the render pass to.
  106718. * @param options The required width/height ratio to downsize to before computing the render pass.
  106719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106720. * @param engine The engine which the post process will be applied. (default: current engine)
  106721. * @param reusable If the post process can be reused on the same frame. (default: false)
  106722. */
  106723. constructor(name: string, refractionTextureUrl: string,
  106724. /** the base color of the refraction (used to taint the rendering) */
  106725. color: Color3,
  106726. /** simulated refraction depth */
  106727. depth: number,
  106728. /** the coefficient of the base color (0 to remove base color tainting) */
  106729. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106730. /**
  106731. * Disposes of the post process
  106732. * @param camera Camera to dispose post process on
  106733. */
  106734. dispose(camera: Camera): void;
  106735. }
  106736. }
  106737. declare module BABYLON {
  106738. /** @hidden */
  106739. export var sharpenPixelShader: {
  106740. name: string;
  106741. shader: string;
  106742. };
  106743. }
  106744. declare module BABYLON {
  106745. /**
  106746. * The SharpenPostProcess applies a sharpen kernel to every pixel
  106747. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106748. */
  106749. export class SharpenPostProcess extends PostProcess {
  106750. /**
  106751. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  106752. */
  106753. colorAmount: number;
  106754. /**
  106755. * How much sharpness should be applied (default: 0.3)
  106756. */
  106757. edgeAmount: number;
  106758. /**
  106759. * Creates a new instance ConvolutionPostProcess
  106760. * @param name The name of the effect.
  106761. * @param options The required width/height ratio to downsize to before computing the render pass.
  106762. * @param camera The camera to apply the render pass to.
  106763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106764. * @param engine The engine which the post process will be applied. (default: current engine)
  106765. * @param reusable If the post process can be reused on the same frame. (default: false)
  106766. * @param textureType Type of textures used when performing the post process. (default: 0)
  106767. * @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)
  106768. */
  106769. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106770. }
  106771. }
  106772. declare module BABYLON {
  106773. /**
  106774. * PostProcessRenderPipeline
  106775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106776. */
  106777. export class PostProcessRenderPipeline {
  106778. private engine;
  106779. private _renderEffects;
  106780. private _renderEffectsForIsolatedPass;
  106781. /**
  106782. * @hidden
  106783. */
  106784. protected _cameras: Camera[];
  106785. /** @hidden */
  106786. _name: string;
  106787. /**
  106788. * Gets pipeline name
  106789. */
  106790. readonly name: string;
  106791. /**
  106792. * Initializes a PostProcessRenderPipeline
  106793. * @param engine engine to add the pipeline to
  106794. * @param name name of the pipeline
  106795. */
  106796. constructor(engine: Engine, name: string);
  106797. /**
  106798. * Gets the class name
  106799. * @returns "PostProcessRenderPipeline"
  106800. */
  106801. getClassName(): string;
  106802. /**
  106803. * If all the render effects in the pipeline are supported
  106804. */
  106805. readonly isSupported: boolean;
  106806. /**
  106807. * Adds an effect to the pipeline
  106808. * @param renderEffect the effect to add
  106809. */
  106810. addEffect(renderEffect: PostProcessRenderEffect): void;
  106811. /** @hidden */
  106812. _rebuild(): void;
  106813. /** @hidden */
  106814. _enableEffect(renderEffectName: string, cameras: Camera): void;
  106815. /** @hidden */
  106816. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  106817. /** @hidden */
  106818. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106819. /** @hidden */
  106820. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106821. /** @hidden */
  106822. _attachCameras(cameras: Camera, unique: boolean): void;
  106823. /** @hidden */
  106824. _attachCameras(cameras: Camera[], unique: boolean): void;
  106825. /** @hidden */
  106826. _detachCameras(cameras: Camera): void;
  106827. /** @hidden */
  106828. _detachCameras(cameras: Nullable<Camera[]>): void;
  106829. /** @hidden */
  106830. _update(): void;
  106831. /** @hidden */
  106832. _reset(): void;
  106833. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  106834. /**
  106835. * Disposes of the pipeline
  106836. */
  106837. dispose(): void;
  106838. }
  106839. }
  106840. declare module BABYLON {
  106841. /**
  106842. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  106843. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106844. */
  106845. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106846. private _scene;
  106847. private _camerasToBeAttached;
  106848. /**
  106849. * ID of the sharpen post process,
  106850. */
  106851. private readonly SharpenPostProcessId;
  106852. /**
  106853. * @ignore
  106854. * ID of the image processing post process;
  106855. */
  106856. readonly ImageProcessingPostProcessId: string;
  106857. /**
  106858. * @ignore
  106859. * ID of the Fast Approximate Anti-Aliasing post process;
  106860. */
  106861. readonly FxaaPostProcessId: string;
  106862. /**
  106863. * ID of the chromatic aberration post process,
  106864. */
  106865. private readonly ChromaticAberrationPostProcessId;
  106866. /**
  106867. * ID of the grain post process
  106868. */
  106869. private readonly GrainPostProcessId;
  106870. /**
  106871. * Sharpen post process which will apply a sharpen convolution to enhance edges
  106872. */
  106873. sharpen: SharpenPostProcess;
  106874. private _sharpenEffect;
  106875. private bloom;
  106876. /**
  106877. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  106878. */
  106879. depthOfField: DepthOfFieldEffect;
  106880. /**
  106881. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106882. */
  106883. fxaa: FxaaPostProcess;
  106884. /**
  106885. * Image post processing pass used to perform operations such as tone mapping or color grading.
  106886. */
  106887. imageProcessing: ImageProcessingPostProcess;
  106888. /**
  106889. * Chromatic aberration post process which will shift rgb colors in the image
  106890. */
  106891. chromaticAberration: ChromaticAberrationPostProcess;
  106892. private _chromaticAberrationEffect;
  106893. /**
  106894. * Grain post process which add noise to the image
  106895. */
  106896. grain: GrainPostProcess;
  106897. private _grainEffect;
  106898. /**
  106899. * Glow post process which adds a glow to emissive areas of the image
  106900. */
  106901. private _glowLayer;
  106902. /**
  106903. * Animations which can be used to tweak settings over a period of time
  106904. */
  106905. animations: Animation[];
  106906. private _imageProcessingConfigurationObserver;
  106907. private _sharpenEnabled;
  106908. private _bloomEnabled;
  106909. private _depthOfFieldEnabled;
  106910. private _depthOfFieldBlurLevel;
  106911. private _fxaaEnabled;
  106912. private _imageProcessingEnabled;
  106913. private _defaultPipelineTextureType;
  106914. private _bloomScale;
  106915. private _chromaticAberrationEnabled;
  106916. private _grainEnabled;
  106917. private _buildAllowed;
  106918. /**
  106919. * Gets active scene
  106920. */
  106921. readonly scene: Scene;
  106922. /**
  106923. * Enable or disable the sharpen process from the pipeline
  106924. */
  106925. sharpenEnabled: boolean;
  106926. private _resizeObserver;
  106927. private _hardwareScaleLevel;
  106928. private _bloomKernel;
  106929. /**
  106930. * Specifies the size of the bloom blur kernel, relative to the final output size
  106931. */
  106932. bloomKernel: number;
  106933. /**
  106934. * Specifies the weight of the bloom in the final rendering
  106935. */
  106936. private _bloomWeight;
  106937. /**
  106938. * Specifies the luma threshold for the area that will be blurred by the bloom
  106939. */
  106940. private _bloomThreshold;
  106941. private _hdr;
  106942. /**
  106943. * The strength of the bloom.
  106944. */
  106945. bloomWeight: number;
  106946. /**
  106947. * The strength of the bloom.
  106948. */
  106949. bloomThreshold: number;
  106950. /**
  106951. * The scale of the bloom, lower value will provide better performance.
  106952. */
  106953. bloomScale: number;
  106954. /**
  106955. * Enable or disable the bloom from the pipeline
  106956. */
  106957. bloomEnabled: boolean;
  106958. private _rebuildBloom;
  106959. /**
  106960. * If the depth of field is enabled.
  106961. */
  106962. depthOfFieldEnabled: boolean;
  106963. /**
  106964. * Blur level of the depth of field effect. (Higher blur will effect performance)
  106965. */
  106966. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  106967. /**
  106968. * If the anti aliasing is enabled.
  106969. */
  106970. fxaaEnabled: boolean;
  106971. private _samples;
  106972. /**
  106973. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106974. */
  106975. samples: number;
  106976. /**
  106977. * If image processing is enabled.
  106978. */
  106979. imageProcessingEnabled: boolean;
  106980. /**
  106981. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  106982. */
  106983. glowLayerEnabled: boolean;
  106984. /**
  106985. * Enable or disable the chromaticAberration process from the pipeline
  106986. */
  106987. chromaticAberrationEnabled: boolean;
  106988. /**
  106989. * Enable or disable the grain process from the pipeline
  106990. */
  106991. grainEnabled: boolean;
  106992. /**
  106993. * @constructor
  106994. * @param name - The rendering pipeline name (default: "")
  106995. * @param hdr - If high dynamic range textures should be used (default: true)
  106996. * @param scene - The scene linked to this pipeline (default: the last created scene)
  106997. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  106998. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  106999. */
  107000. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  107001. /**
  107002. * Get the class name
  107003. * @returns "DefaultRenderingPipeline"
  107004. */
  107005. getClassName(): string;
  107006. /**
  107007. * Force the compilation of the entire pipeline.
  107008. */
  107009. prepare(): void;
  107010. private _hasCleared;
  107011. private _prevPostProcess;
  107012. private _prevPrevPostProcess;
  107013. private _setAutoClearAndTextureSharing;
  107014. private _depthOfFieldSceneObserver;
  107015. private _buildPipeline;
  107016. private _disposePostProcesses;
  107017. /**
  107018. * Adds a camera to the pipeline
  107019. * @param camera the camera to be added
  107020. */
  107021. addCamera(camera: Camera): void;
  107022. /**
  107023. * Removes a camera from the pipeline
  107024. * @param camera the camera to remove
  107025. */
  107026. removeCamera(camera: Camera): void;
  107027. /**
  107028. * Dispose of the pipeline and stop all post processes
  107029. */
  107030. dispose(): void;
  107031. /**
  107032. * Serialize the rendering pipeline (Used when exporting)
  107033. * @returns the serialized object
  107034. */
  107035. serialize(): any;
  107036. /**
  107037. * Parse the serialized pipeline
  107038. * @param source Source pipeline.
  107039. * @param scene The scene to load the pipeline to.
  107040. * @param rootUrl The URL of the serialized pipeline.
  107041. * @returns An instantiated pipeline from the serialized object.
  107042. */
  107043. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  107044. }
  107045. }
  107046. declare module BABYLON {
  107047. /** @hidden */
  107048. export var lensHighlightsPixelShader: {
  107049. name: string;
  107050. shader: string;
  107051. };
  107052. }
  107053. declare module BABYLON {
  107054. /** @hidden */
  107055. export var depthOfFieldPixelShader: {
  107056. name: string;
  107057. shader: string;
  107058. };
  107059. }
  107060. declare module BABYLON {
  107061. /**
  107062. * BABYLON.JS Chromatic Aberration GLSL Shader
  107063. * Author: Olivier Guyot
  107064. * Separates very slightly R, G and B colors on the edges of the screen
  107065. * Inspired by Francois Tarlier & Martins Upitis
  107066. */
  107067. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  107068. /**
  107069. * @ignore
  107070. * The chromatic aberration PostProcess id in the pipeline
  107071. */
  107072. LensChromaticAberrationEffect: string;
  107073. /**
  107074. * @ignore
  107075. * The highlights enhancing PostProcess id in the pipeline
  107076. */
  107077. HighlightsEnhancingEffect: string;
  107078. /**
  107079. * @ignore
  107080. * The depth-of-field PostProcess id in the pipeline
  107081. */
  107082. LensDepthOfFieldEffect: string;
  107083. private _scene;
  107084. private _depthTexture;
  107085. private _grainTexture;
  107086. private _chromaticAberrationPostProcess;
  107087. private _highlightsPostProcess;
  107088. private _depthOfFieldPostProcess;
  107089. private _edgeBlur;
  107090. private _grainAmount;
  107091. private _chromaticAberration;
  107092. private _distortion;
  107093. private _highlightsGain;
  107094. private _highlightsThreshold;
  107095. private _dofDistance;
  107096. private _dofAperture;
  107097. private _dofDarken;
  107098. private _dofPentagon;
  107099. private _blurNoise;
  107100. /**
  107101. * @constructor
  107102. *
  107103. * Effect parameters are as follow:
  107104. * {
  107105. * chromatic_aberration: number; // from 0 to x (1 for realism)
  107106. * edge_blur: number; // from 0 to x (1 for realism)
  107107. * distortion: number; // from 0 to x (1 for realism)
  107108. * grain_amount: number; // from 0 to 1
  107109. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  107110. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  107111. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  107112. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  107113. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  107114. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  107115. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  107116. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  107117. * }
  107118. * Note: if an effect parameter is unset, effect is disabled
  107119. *
  107120. * @param name The rendering pipeline name
  107121. * @param parameters - An object containing all parameters (see above)
  107122. * @param scene The scene linked to this pipeline
  107123. * @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)
  107124. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107125. */
  107126. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  107127. /**
  107128. * Sets the amount of blur at the edges
  107129. * @param amount blur amount
  107130. */
  107131. setEdgeBlur(amount: number): void;
  107132. /**
  107133. * Sets edge blur to 0
  107134. */
  107135. disableEdgeBlur(): void;
  107136. /**
  107137. * Sets the amout of grain
  107138. * @param amount Amount of grain
  107139. */
  107140. setGrainAmount(amount: number): void;
  107141. /**
  107142. * Set grain amount to 0
  107143. */
  107144. disableGrain(): void;
  107145. /**
  107146. * Sets the chromatic aberration amount
  107147. * @param amount amount of chromatic aberration
  107148. */
  107149. setChromaticAberration(amount: number): void;
  107150. /**
  107151. * Sets chromatic aberration amount to 0
  107152. */
  107153. disableChromaticAberration(): void;
  107154. /**
  107155. * Sets the EdgeDistortion amount
  107156. * @param amount amount of EdgeDistortion
  107157. */
  107158. setEdgeDistortion(amount: number): void;
  107159. /**
  107160. * Sets edge distortion to 0
  107161. */
  107162. disableEdgeDistortion(): void;
  107163. /**
  107164. * Sets the FocusDistance amount
  107165. * @param amount amount of FocusDistance
  107166. */
  107167. setFocusDistance(amount: number): void;
  107168. /**
  107169. * Disables depth of field
  107170. */
  107171. disableDepthOfField(): void;
  107172. /**
  107173. * Sets the Aperture amount
  107174. * @param amount amount of Aperture
  107175. */
  107176. setAperture(amount: number): void;
  107177. /**
  107178. * Sets the DarkenOutOfFocus amount
  107179. * @param amount amount of DarkenOutOfFocus
  107180. */
  107181. setDarkenOutOfFocus(amount: number): void;
  107182. /**
  107183. * Creates a pentagon bokeh effect
  107184. */
  107185. enablePentagonBokeh(): void;
  107186. /**
  107187. * Disables the pentagon bokeh effect
  107188. */
  107189. disablePentagonBokeh(): void;
  107190. /**
  107191. * Enables noise blur
  107192. */
  107193. enableNoiseBlur(): void;
  107194. /**
  107195. * Disables noise blur
  107196. */
  107197. disableNoiseBlur(): void;
  107198. /**
  107199. * Sets the HighlightsGain amount
  107200. * @param amount amount of HighlightsGain
  107201. */
  107202. setHighlightsGain(amount: number): void;
  107203. /**
  107204. * Sets the HighlightsThreshold amount
  107205. * @param amount amount of HighlightsThreshold
  107206. */
  107207. setHighlightsThreshold(amount: number): void;
  107208. /**
  107209. * Disables highlights
  107210. */
  107211. disableHighlights(): void;
  107212. /**
  107213. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107214. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107215. */
  107216. dispose(disableDepthRender?: boolean): void;
  107217. private _createChromaticAberrationPostProcess;
  107218. private _createHighlightsPostProcess;
  107219. private _createDepthOfFieldPostProcess;
  107220. private _createGrainTexture;
  107221. }
  107222. }
  107223. declare module BABYLON {
  107224. /** @hidden */
  107225. export var ssao2PixelShader: {
  107226. name: string;
  107227. shader: string;
  107228. };
  107229. }
  107230. declare module BABYLON {
  107231. /** @hidden */
  107232. export var ssaoCombinePixelShader: {
  107233. name: string;
  107234. shader: string;
  107235. };
  107236. }
  107237. declare module BABYLON {
  107238. /**
  107239. * Render pipeline to produce ssao effect
  107240. */
  107241. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107242. /**
  107243. * @ignore
  107244. * The PassPostProcess id in the pipeline that contains the original scene color
  107245. */
  107246. SSAOOriginalSceneColorEffect: string;
  107247. /**
  107248. * @ignore
  107249. * The SSAO PostProcess id in the pipeline
  107250. */
  107251. SSAORenderEffect: string;
  107252. /**
  107253. * @ignore
  107254. * The horizontal blur PostProcess id in the pipeline
  107255. */
  107256. SSAOBlurHRenderEffect: string;
  107257. /**
  107258. * @ignore
  107259. * The vertical blur PostProcess id in the pipeline
  107260. */
  107261. SSAOBlurVRenderEffect: string;
  107262. /**
  107263. * @ignore
  107264. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107265. */
  107266. SSAOCombineRenderEffect: string;
  107267. /**
  107268. * The output strength of the SSAO post-process. Default value is 1.0.
  107269. */
  107270. totalStrength: number;
  107271. /**
  107272. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107273. */
  107274. maxZ: number;
  107275. /**
  107276. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107277. */
  107278. minZAspect: number;
  107279. private _samples;
  107280. /**
  107281. * Number of samples used for the SSAO calculations. Default value is 8
  107282. */
  107283. samples: number;
  107284. private _textureSamples;
  107285. /**
  107286. * Number of samples to use for antialiasing
  107287. */
  107288. textureSamples: number;
  107289. /**
  107290. * Ratio object used for SSAO ratio and blur ratio
  107291. */
  107292. private _ratio;
  107293. /**
  107294. * Dynamically generated sphere sampler.
  107295. */
  107296. private _sampleSphere;
  107297. /**
  107298. * Blur filter offsets
  107299. */
  107300. private _samplerOffsets;
  107301. private _expensiveBlur;
  107302. /**
  107303. * If bilateral blur should be used
  107304. */
  107305. expensiveBlur: boolean;
  107306. /**
  107307. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107308. */
  107309. radius: number;
  107310. /**
  107311. * The base color of the SSAO post-process
  107312. * The final result is "base + ssao" between [0, 1]
  107313. */
  107314. base: number;
  107315. /**
  107316. * Support test.
  107317. */
  107318. static readonly IsSupported: boolean;
  107319. private _scene;
  107320. private _depthTexture;
  107321. private _normalTexture;
  107322. private _randomTexture;
  107323. private _originalColorPostProcess;
  107324. private _ssaoPostProcess;
  107325. private _blurHPostProcess;
  107326. private _blurVPostProcess;
  107327. private _ssaoCombinePostProcess;
  107328. private _firstUpdate;
  107329. /**
  107330. * @constructor
  107331. * @param name The rendering pipeline name
  107332. * @param scene The scene linked to this pipeline
  107333. * @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 }
  107334. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107335. */
  107336. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107337. /**
  107338. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107339. */
  107340. dispose(disableGeometryBufferRenderer?: boolean): void;
  107341. private _createBlurPostProcess;
  107342. /** @hidden */
  107343. _rebuild(): void;
  107344. private _bits;
  107345. private _radicalInverse_VdC;
  107346. private _hammersley;
  107347. private _hemisphereSample_uniform;
  107348. private _generateHemisphere;
  107349. private _createSSAOPostProcess;
  107350. private _createSSAOCombinePostProcess;
  107351. private _createRandomTexture;
  107352. /**
  107353. * Serialize the rendering pipeline (Used when exporting)
  107354. * @returns the serialized object
  107355. */
  107356. serialize(): any;
  107357. /**
  107358. * Parse the serialized pipeline
  107359. * @param source Source pipeline.
  107360. * @param scene The scene to load the pipeline to.
  107361. * @param rootUrl The URL of the serialized pipeline.
  107362. * @returns An instantiated pipeline from the serialized object.
  107363. */
  107364. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107365. }
  107366. }
  107367. declare module BABYLON {
  107368. /** @hidden */
  107369. export var ssaoPixelShader: {
  107370. name: string;
  107371. shader: string;
  107372. };
  107373. }
  107374. declare module BABYLON {
  107375. /**
  107376. * Render pipeline to produce ssao effect
  107377. */
  107378. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107379. /**
  107380. * @ignore
  107381. * The PassPostProcess id in the pipeline that contains the original scene color
  107382. */
  107383. SSAOOriginalSceneColorEffect: string;
  107384. /**
  107385. * @ignore
  107386. * The SSAO PostProcess id in the pipeline
  107387. */
  107388. SSAORenderEffect: string;
  107389. /**
  107390. * @ignore
  107391. * The horizontal blur PostProcess id in the pipeline
  107392. */
  107393. SSAOBlurHRenderEffect: string;
  107394. /**
  107395. * @ignore
  107396. * The vertical blur PostProcess id in the pipeline
  107397. */
  107398. SSAOBlurVRenderEffect: string;
  107399. /**
  107400. * @ignore
  107401. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107402. */
  107403. SSAOCombineRenderEffect: string;
  107404. /**
  107405. * The output strength of the SSAO post-process. Default value is 1.0.
  107406. */
  107407. totalStrength: number;
  107408. /**
  107409. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107410. */
  107411. radius: number;
  107412. /**
  107413. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107414. * Must not be equal to fallOff and superior to fallOff.
  107415. * Default value is 0.975
  107416. */
  107417. area: number;
  107418. /**
  107419. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107420. * Must not be equal to area and inferior to area.
  107421. * Default value is 0.0
  107422. */
  107423. fallOff: number;
  107424. /**
  107425. * The base color of the SSAO post-process
  107426. * The final result is "base + ssao" between [0, 1]
  107427. */
  107428. base: number;
  107429. private _scene;
  107430. private _depthTexture;
  107431. private _randomTexture;
  107432. private _originalColorPostProcess;
  107433. private _ssaoPostProcess;
  107434. private _blurHPostProcess;
  107435. private _blurVPostProcess;
  107436. private _ssaoCombinePostProcess;
  107437. private _firstUpdate;
  107438. /**
  107439. * @constructor
  107440. * @param name - The rendering pipeline name
  107441. * @param scene - The scene linked to this pipeline
  107442. * @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 }
  107443. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107444. */
  107445. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107446. /**
  107447. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107448. */
  107449. dispose(disableDepthRender?: boolean): void;
  107450. private _createBlurPostProcess;
  107451. /** @hidden */
  107452. _rebuild(): void;
  107453. private _createSSAOPostProcess;
  107454. private _createSSAOCombinePostProcess;
  107455. private _createRandomTexture;
  107456. }
  107457. }
  107458. declare module BABYLON {
  107459. /** @hidden */
  107460. export var standardPixelShader: {
  107461. name: string;
  107462. shader: string;
  107463. };
  107464. }
  107465. declare module BABYLON {
  107466. /**
  107467. * Standard rendering pipeline
  107468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107469. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  107470. */
  107471. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107472. /**
  107473. * Public members
  107474. */
  107475. /**
  107476. * Post-process which contains the original scene color before the pipeline applies all the effects
  107477. */
  107478. originalPostProcess: Nullable<PostProcess>;
  107479. /**
  107480. * Post-process used to down scale an image x4
  107481. */
  107482. downSampleX4PostProcess: Nullable<PostProcess>;
  107483. /**
  107484. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  107485. */
  107486. brightPassPostProcess: Nullable<PostProcess>;
  107487. /**
  107488. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  107489. */
  107490. blurHPostProcesses: PostProcess[];
  107491. /**
  107492. * Post-process array storing all the vertical blur post-processes used by the pipeline
  107493. */
  107494. blurVPostProcesses: PostProcess[];
  107495. /**
  107496. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  107497. */
  107498. textureAdderPostProcess: Nullable<PostProcess>;
  107499. /**
  107500. * Post-process used to create volumetric lighting effect
  107501. */
  107502. volumetricLightPostProcess: Nullable<PostProcess>;
  107503. /**
  107504. * Post-process used to smooth the previous volumetric light post-process on the X axis
  107505. */
  107506. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  107507. /**
  107508. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  107509. */
  107510. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  107511. /**
  107512. * Post-process used to merge the volumetric light effect and the real scene color
  107513. */
  107514. volumetricLightMergePostProces: Nullable<PostProcess>;
  107515. /**
  107516. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  107517. */
  107518. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  107519. /**
  107520. * Base post-process used to calculate the average luminance of the final image for HDR
  107521. */
  107522. luminancePostProcess: Nullable<PostProcess>;
  107523. /**
  107524. * Post-processes used to create down sample post-processes in order to get
  107525. * the average luminance of the final image for HDR
  107526. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  107527. */
  107528. luminanceDownSamplePostProcesses: PostProcess[];
  107529. /**
  107530. * Post-process used to create a HDR effect (light adaptation)
  107531. */
  107532. hdrPostProcess: Nullable<PostProcess>;
  107533. /**
  107534. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  107535. */
  107536. textureAdderFinalPostProcess: Nullable<PostProcess>;
  107537. /**
  107538. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  107539. */
  107540. lensFlareFinalPostProcess: Nullable<PostProcess>;
  107541. /**
  107542. * Post-process used to merge the final HDR post-process and the real scene color
  107543. */
  107544. hdrFinalPostProcess: Nullable<PostProcess>;
  107545. /**
  107546. * Post-process used to create a lens flare effect
  107547. */
  107548. lensFlarePostProcess: Nullable<PostProcess>;
  107549. /**
  107550. * Post-process that merges the result of the lens flare post-process and the real scene color
  107551. */
  107552. lensFlareComposePostProcess: Nullable<PostProcess>;
  107553. /**
  107554. * Post-process used to create a motion blur effect
  107555. */
  107556. motionBlurPostProcess: Nullable<PostProcess>;
  107557. /**
  107558. * Post-process used to create a depth of field effect
  107559. */
  107560. depthOfFieldPostProcess: Nullable<PostProcess>;
  107561. /**
  107562. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107563. */
  107564. fxaaPostProcess: Nullable<FxaaPostProcess>;
  107565. /**
  107566. * Represents the brightness threshold in order to configure the illuminated surfaces
  107567. */
  107568. brightThreshold: number;
  107569. /**
  107570. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  107571. */
  107572. blurWidth: number;
  107573. /**
  107574. * Sets if the blur for highlighted surfaces must be only horizontal
  107575. */
  107576. horizontalBlur: boolean;
  107577. /**
  107578. * Sets the overall exposure used by the pipeline
  107579. */
  107580. exposure: number;
  107581. /**
  107582. * Texture used typically to simulate "dirty" on camera lens
  107583. */
  107584. lensTexture: Nullable<Texture>;
  107585. /**
  107586. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  107587. */
  107588. volumetricLightCoefficient: number;
  107589. /**
  107590. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  107591. */
  107592. volumetricLightPower: number;
  107593. /**
  107594. * Used the set the blur intensity to smooth the volumetric lights
  107595. */
  107596. volumetricLightBlurScale: number;
  107597. /**
  107598. * Light (spot or directional) used to generate the volumetric lights rays
  107599. * The source light must have a shadow generate so the pipeline can get its
  107600. * depth map
  107601. */
  107602. sourceLight: Nullable<SpotLight | DirectionalLight>;
  107603. /**
  107604. * For eye adaptation, represents the minimum luminance the eye can see
  107605. */
  107606. hdrMinimumLuminance: number;
  107607. /**
  107608. * For eye adaptation, represents the decrease luminance speed
  107609. */
  107610. hdrDecreaseRate: number;
  107611. /**
  107612. * For eye adaptation, represents the increase luminance speed
  107613. */
  107614. hdrIncreaseRate: number;
  107615. /**
  107616. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  107617. */
  107618. lensColorTexture: Nullable<Texture>;
  107619. /**
  107620. * The overall strengh for the lens flare effect
  107621. */
  107622. lensFlareStrength: number;
  107623. /**
  107624. * Dispersion coefficient for lens flare ghosts
  107625. */
  107626. lensFlareGhostDispersal: number;
  107627. /**
  107628. * Main lens flare halo width
  107629. */
  107630. lensFlareHaloWidth: number;
  107631. /**
  107632. * Based on the lens distortion effect, defines how much the lens flare result
  107633. * is distorted
  107634. */
  107635. lensFlareDistortionStrength: number;
  107636. /**
  107637. * Lens star texture must be used to simulate rays on the flares and is available
  107638. * in the documentation
  107639. */
  107640. lensStarTexture: Nullable<Texture>;
  107641. /**
  107642. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  107643. * flare effect by taking account of the dirt texture
  107644. */
  107645. lensFlareDirtTexture: Nullable<Texture>;
  107646. /**
  107647. * Represents the focal length for the depth of field effect
  107648. */
  107649. depthOfFieldDistance: number;
  107650. /**
  107651. * Represents the blur intensity for the blurred part of the depth of field effect
  107652. */
  107653. depthOfFieldBlurWidth: number;
  107654. /**
  107655. * For motion blur, defines how much the image is blurred by the movement
  107656. */
  107657. motionStrength: number;
  107658. /**
  107659. * List of animations for the pipeline (IAnimatable implementation)
  107660. */
  107661. animations: Animation[];
  107662. /**
  107663. * Private members
  107664. */
  107665. private _scene;
  107666. private _currentDepthOfFieldSource;
  107667. private _basePostProcess;
  107668. private _hdrCurrentLuminance;
  107669. private _floatTextureType;
  107670. private _ratio;
  107671. private _bloomEnabled;
  107672. private _depthOfFieldEnabled;
  107673. private _vlsEnabled;
  107674. private _lensFlareEnabled;
  107675. private _hdrEnabled;
  107676. private _motionBlurEnabled;
  107677. private _fxaaEnabled;
  107678. private _motionBlurSamples;
  107679. private _volumetricLightStepsCount;
  107680. private _samples;
  107681. /**
  107682. * @ignore
  107683. * Specifies if the bloom pipeline is enabled
  107684. */
  107685. BloomEnabled: boolean;
  107686. /**
  107687. * @ignore
  107688. * Specifies if the depth of field pipeline is enabed
  107689. */
  107690. DepthOfFieldEnabled: boolean;
  107691. /**
  107692. * @ignore
  107693. * Specifies if the lens flare pipeline is enabed
  107694. */
  107695. LensFlareEnabled: boolean;
  107696. /**
  107697. * @ignore
  107698. * Specifies if the HDR pipeline is enabled
  107699. */
  107700. HDREnabled: boolean;
  107701. /**
  107702. * @ignore
  107703. * Specifies if the volumetric lights scattering effect is enabled
  107704. */
  107705. VLSEnabled: boolean;
  107706. /**
  107707. * @ignore
  107708. * Specifies if the motion blur effect is enabled
  107709. */
  107710. MotionBlurEnabled: boolean;
  107711. /**
  107712. * Specifies if anti-aliasing is enabled
  107713. */
  107714. fxaaEnabled: boolean;
  107715. /**
  107716. * Specifies the number of steps used to calculate the volumetric lights
  107717. * Typically in interval [50, 200]
  107718. */
  107719. volumetricLightStepsCount: number;
  107720. /**
  107721. * Specifies the number of samples used for the motion blur effect
  107722. * Typically in interval [16, 64]
  107723. */
  107724. motionBlurSamples: number;
  107725. /**
  107726. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107727. */
  107728. samples: number;
  107729. /**
  107730. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107731. * @constructor
  107732. * @param name The rendering pipeline name
  107733. * @param scene The scene linked to this pipeline
  107734. * @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)
  107735. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  107736. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107737. */
  107738. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  107739. private _buildPipeline;
  107740. private _createDownSampleX4PostProcess;
  107741. private _createBrightPassPostProcess;
  107742. private _createBlurPostProcesses;
  107743. private _createTextureAdderPostProcess;
  107744. private _createVolumetricLightPostProcess;
  107745. private _createLuminancePostProcesses;
  107746. private _createHdrPostProcess;
  107747. private _createLensFlarePostProcess;
  107748. private _createDepthOfFieldPostProcess;
  107749. private _createMotionBlurPostProcess;
  107750. private _getDepthTexture;
  107751. private _disposePostProcesses;
  107752. /**
  107753. * Dispose of the pipeline and stop all post processes
  107754. */
  107755. dispose(): void;
  107756. /**
  107757. * Serialize the rendering pipeline (Used when exporting)
  107758. * @returns the serialized object
  107759. */
  107760. serialize(): any;
  107761. /**
  107762. * Parse the serialized pipeline
  107763. * @param source Source pipeline.
  107764. * @param scene The scene to load the pipeline to.
  107765. * @param rootUrl The URL of the serialized pipeline.
  107766. * @returns An instantiated pipeline from the serialized object.
  107767. */
  107768. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  107769. /**
  107770. * Luminance steps
  107771. */
  107772. static LuminanceSteps: number;
  107773. }
  107774. }
  107775. declare module BABYLON {
  107776. /**
  107777. * PostProcessRenderPipelineManager class
  107778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107779. */
  107780. export class PostProcessRenderPipelineManager {
  107781. private _renderPipelines;
  107782. /**
  107783. * Initializes a PostProcessRenderPipelineManager
  107784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107785. */
  107786. constructor();
  107787. /**
  107788. * Gets the list of supported render pipelines
  107789. */
  107790. readonly supportedPipelines: PostProcessRenderPipeline[];
  107791. /**
  107792. * Adds a pipeline to the manager
  107793. * @param renderPipeline The pipeline to add
  107794. */
  107795. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  107796. /**
  107797. * Attaches a camera to the pipeline
  107798. * @param renderPipelineName The name of the pipeline to attach to
  107799. * @param cameras the camera to attach
  107800. * @param unique if the camera can be attached multiple times to the pipeline
  107801. */
  107802. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  107803. /**
  107804. * Detaches a camera from the pipeline
  107805. * @param renderPipelineName The name of the pipeline to detach from
  107806. * @param cameras the camera to detach
  107807. */
  107808. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  107809. /**
  107810. * Enables an effect by name on a pipeline
  107811. * @param renderPipelineName the name of the pipeline to enable the effect in
  107812. * @param renderEffectName the name of the effect to enable
  107813. * @param cameras the cameras that the effect should be enabled on
  107814. */
  107815. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107816. /**
  107817. * Disables an effect by name on a pipeline
  107818. * @param renderPipelineName the name of the pipeline to disable the effect in
  107819. * @param renderEffectName the name of the effect to disable
  107820. * @param cameras the cameras that the effect should be disabled on
  107821. */
  107822. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107823. /**
  107824. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  107825. */
  107826. update(): void;
  107827. /** @hidden */
  107828. _rebuild(): void;
  107829. /**
  107830. * Disposes of the manager and pipelines
  107831. */
  107832. dispose(): void;
  107833. }
  107834. }
  107835. declare module BABYLON {
  107836. interface Scene {
  107837. /** @hidden (Backing field) */
  107838. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107839. /**
  107840. * Gets the postprocess render pipeline manager
  107841. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107842. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107843. */
  107844. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107845. }
  107846. /**
  107847. * Defines the Render Pipeline scene component responsible to rendering pipelines
  107848. */
  107849. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  107850. /**
  107851. * The component name helpfull to identify the component in the list of scene components.
  107852. */
  107853. readonly name: string;
  107854. /**
  107855. * The scene the component belongs to.
  107856. */
  107857. scene: Scene;
  107858. /**
  107859. * Creates a new instance of the component for the given scene
  107860. * @param scene Defines the scene to register the component in
  107861. */
  107862. constructor(scene: Scene);
  107863. /**
  107864. * Registers the component in a given scene
  107865. */
  107866. register(): void;
  107867. /**
  107868. * Rebuilds the elements related to this component in case of
  107869. * context lost for instance.
  107870. */
  107871. rebuild(): void;
  107872. /**
  107873. * Disposes the component and the associated ressources
  107874. */
  107875. dispose(): void;
  107876. private _gatherRenderTargets;
  107877. }
  107878. }
  107879. declare module BABYLON {
  107880. /** @hidden */
  107881. export var tonemapPixelShader: {
  107882. name: string;
  107883. shader: string;
  107884. };
  107885. }
  107886. declare module BABYLON {
  107887. /** Defines operator used for tonemapping */
  107888. export enum TonemappingOperator {
  107889. /** Hable */
  107890. Hable = 0,
  107891. /** Reinhard */
  107892. Reinhard = 1,
  107893. /** HejiDawson */
  107894. HejiDawson = 2,
  107895. /** Photographic */
  107896. Photographic = 3
  107897. }
  107898. /**
  107899. * Defines a post process to apply tone mapping
  107900. */
  107901. export class TonemapPostProcess extends PostProcess {
  107902. private _operator;
  107903. /** Defines the required exposure adjustement */
  107904. exposureAdjustment: number;
  107905. /**
  107906. * Creates a new TonemapPostProcess
  107907. * @param name defines the name of the postprocess
  107908. * @param _operator defines the operator to use
  107909. * @param exposureAdjustment defines the required exposure adjustement
  107910. * @param camera defines the camera to use (can be null)
  107911. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  107912. * @param engine defines the hosting engine (can be ignore if camera is set)
  107913. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107914. */
  107915. constructor(name: string, _operator: TonemappingOperator,
  107916. /** Defines the required exposure adjustement */
  107917. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  107918. }
  107919. }
  107920. declare module BABYLON {
  107921. /** @hidden */
  107922. export var depthVertexShader: {
  107923. name: string;
  107924. shader: string;
  107925. };
  107926. }
  107927. declare module BABYLON {
  107928. /** @hidden */
  107929. export var volumetricLightScatteringPixelShader: {
  107930. name: string;
  107931. shader: string;
  107932. };
  107933. }
  107934. declare module BABYLON {
  107935. /** @hidden */
  107936. export var volumetricLightScatteringPassPixelShader: {
  107937. name: string;
  107938. shader: string;
  107939. };
  107940. }
  107941. declare module BABYLON {
  107942. /**
  107943. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  107944. */
  107945. export class VolumetricLightScatteringPostProcess extends PostProcess {
  107946. private _volumetricLightScatteringPass;
  107947. private _volumetricLightScatteringRTT;
  107948. private _viewPort;
  107949. private _screenCoordinates;
  107950. private _cachedDefines;
  107951. /**
  107952. * If not undefined, the mesh position is computed from the attached node position
  107953. */
  107954. attachedNode: {
  107955. position: Vector3;
  107956. };
  107957. /**
  107958. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  107959. */
  107960. customMeshPosition: Vector3;
  107961. /**
  107962. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  107963. */
  107964. useCustomMeshPosition: boolean;
  107965. /**
  107966. * If the post-process should inverse the light scattering direction
  107967. */
  107968. invert: boolean;
  107969. /**
  107970. * The internal mesh used by the post-process
  107971. */
  107972. mesh: Mesh;
  107973. /**
  107974. * @hidden
  107975. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  107976. */
  107977. useDiffuseColor: boolean;
  107978. /**
  107979. * Array containing the excluded meshes not rendered in the internal pass
  107980. */
  107981. excludedMeshes: AbstractMesh[];
  107982. /**
  107983. * Controls the overall intensity of the post-process
  107984. */
  107985. exposure: number;
  107986. /**
  107987. * Dissipates each sample's contribution in range [0, 1]
  107988. */
  107989. decay: number;
  107990. /**
  107991. * Controls the overall intensity of each sample
  107992. */
  107993. weight: number;
  107994. /**
  107995. * Controls the density of each sample
  107996. */
  107997. density: number;
  107998. /**
  107999. * @constructor
  108000. * @param name The post-process name
  108001. * @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)
  108002. * @param camera The camera that the post-process will be attached to
  108003. * @param mesh The mesh used to create the light scattering
  108004. * @param samples The post-process quality, default 100
  108005. * @param samplingModeThe post-process filtering mode
  108006. * @param engine The babylon engine
  108007. * @param reusable If the post-process is reusable
  108008. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  108009. */
  108010. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  108011. /**
  108012. * Returns the string "VolumetricLightScatteringPostProcess"
  108013. * @returns "VolumetricLightScatteringPostProcess"
  108014. */
  108015. getClassName(): string;
  108016. private _isReady;
  108017. /**
  108018. * Sets the new light position for light scattering effect
  108019. * @param position The new custom light position
  108020. */
  108021. setCustomMeshPosition(position: Vector3): void;
  108022. /**
  108023. * Returns the light position for light scattering effect
  108024. * @return Vector3 The custom light position
  108025. */
  108026. getCustomMeshPosition(): Vector3;
  108027. /**
  108028. * Disposes the internal assets and detaches the post-process from the camera
  108029. */
  108030. dispose(camera: Camera): void;
  108031. /**
  108032. * Returns the render target texture used by the post-process
  108033. * @return the render target texture used by the post-process
  108034. */
  108035. getPass(): RenderTargetTexture;
  108036. private _meshExcluded;
  108037. private _createPass;
  108038. private _updateMeshScreenCoordinates;
  108039. /**
  108040. * Creates a default mesh for the Volumeric Light Scattering post-process
  108041. * @param name The mesh name
  108042. * @param scene The scene where to create the mesh
  108043. * @return the default mesh
  108044. */
  108045. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  108046. }
  108047. }
  108048. declare module BABYLON {
  108049. interface Scene {
  108050. /** @hidden (Backing field) */
  108051. _boundingBoxRenderer: BoundingBoxRenderer;
  108052. /** @hidden (Backing field) */
  108053. _forceShowBoundingBoxes: boolean;
  108054. /**
  108055. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  108056. */
  108057. forceShowBoundingBoxes: boolean;
  108058. /**
  108059. * Gets the bounding box renderer associated with the scene
  108060. * @returns a BoundingBoxRenderer
  108061. */
  108062. getBoundingBoxRenderer(): BoundingBoxRenderer;
  108063. }
  108064. interface AbstractMesh {
  108065. /** @hidden (Backing field) */
  108066. _showBoundingBox: boolean;
  108067. /**
  108068. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  108069. */
  108070. showBoundingBox: boolean;
  108071. }
  108072. /**
  108073. * Component responsible of rendering the bounding box of the meshes in a scene.
  108074. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  108075. */
  108076. export class BoundingBoxRenderer implements ISceneComponent {
  108077. /**
  108078. * The component name helpfull to identify the component in the list of scene components.
  108079. */
  108080. readonly name: string;
  108081. /**
  108082. * The scene the component belongs to.
  108083. */
  108084. scene: Scene;
  108085. /**
  108086. * Color of the bounding box lines placed in front of an object
  108087. */
  108088. frontColor: Color3;
  108089. /**
  108090. * Color of the bounding box lines placed behind an object
  108091. */
  108092. backColor: Color3;
  108093. /**
  108094. * Defines if the renderer should show the back lines or not
  108095. */
  108096. showBackLines: boolean;
  108097. /**
  108098. * @hidden
  108099. */
  108100. renderList: SmartArray<BoundingBox>;
  108101. private _colorShader;
  108102. private _vertexBuffers;
  108103. private _indexBuffer;
  108104. /**
  108105. * Instantiates a new bounding box renderer in a scene.
  108106. * @param scene the scene the renderer renders in
  108107. */
  108108. constructor(scene: Scene);
  108109. /**
  108110. * Registers the component in a given scene
  108111. */
  108112. register(): void;
  108113. private _evaluateSubMesh;
  108114. private _activeMesh;
  108115. private _prepareRessources;
  108116. private _createIndexBuffer;
  108117. /**
  108118. * Rebuilds the elements related to this component in case of
  108119. * context lost for instance.
  108120. */
  108121. rebuild(): void;
  108122. /**
  108123. * @hidden
  108124. */
  108125. reset(): void;
  108126. /**
  108127. * Render the bounding boxes of a specific rendering group
  108128. * @param renderingGroupId defines the rendering group to render
  108129. */
  108130. render(renderingGroupId: number): void;
  108131. /**
  108132. * In case of occlusion queries, we can render the occlusion bounding box through this method
  108133. * @param mesh Define the mesh to render the occlusion bounding box for
  108134. */
  108135. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  108136. /**
  108137. * Dispose and release the resources attached to this renderer.
  108138. */
  108139. dispose(): void;
  108140. }
  108141. }
  108142. declare module BABYLON {
  108143. /** @hidden */
  108144. export var depthPixelShader: {
  108145. name: string;
  108146. shader: string;
  108147. };
  108148. }
  108149. declare module BABYLON {
  108150. /**
  108151. * This represents a depth renderer in Babylon.
  108152. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  108153. */
  108154. export class DepthRenderer {
  108155. private _scene;
  108156. private _depthMap;
  108157. private _effect;
  108158. private _cachedDefines;
  108159. private _camera;
  108160. /**
  108161. * Specifiess that the depth renderer will only be used within
  108162. * the camera it is created for.
  108163. * This can help forcing its rendering during the camera processing.
  108164. */
  108165. useOnlyInActiveCamera: boolean;
  108166. /** @hidden */
  108167. static _SceneComponentInitialization: (scene: Scene) => void;
  108168. /**
  108169. * Instantiates a depth renderer
  108170. * @param scene The scene the renderer belongs to
  108171. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  108172. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  108173. */
  108174. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  108175. /**
  108176. * Creates the depth rendering effect and checks if the effect is ready.
  108177. * @param subMesh The submesh to be used to render the depth map of
  108178. * @param useInstances If multiple world instances should be used
  108179. * @returns if the depth renderer is ready to render the depth map
  108180. */
  108181. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108182. /**
  108183. * Gets the texture which the depth map will be written to.
  108184. * @returns The depth map texture
  108185. */
  108186. getDepthMap(): RenderTargetTexture;
  108187. /**
  108188. * Disposes of the depth renderer.
  108189. */
  108190. dispose(): void;
  108191. }
  108192. }
  108193. declare module BABYLON {
  108194. interface Scene {
  108195. /** @hidden (Backing field) */
  108196. _depthRenderer: {
  108197. [id: string]: DepthRenderer;
  108198. };
  108199. /**
  108200. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108201. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108202. * @returns the created depth renderer
  108203. */
  108204. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108205. /**
  108206. * Disables a depth renderer for a given camera
  108207. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108208. */
  108209. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108210. }
  108211. /**
  108212. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108213. * in several rendering techniques.
  108214. */
  108215. export class DepthRendererSceneComponent implements ISceneComponent {
  108216. /**
  108217. * The component name helpfull to identify the component in the list of scene components.
  108218. */
  108219. readonly name: string;
  108220. /**
  108221. * The scene the component belongs to.
  108222. */
  108223. scene: Scene;
  108224. /**
  108225. * Creates a new instance of the component for the given scene
  108226. * @param scene Defines the scene to register the component in
  108227. */
  108228. constructor(scene: Scene);
  108229. /**
  108230. * Registers the component in a given scene
  108231. */
  108232. register(): void;
  108233. /**
  108234. * Rebuilds the elements related to this component in case of
  108235. * context lost for instance.
  108236. */
  108237. rebuild(): void;
  108238. /**
  108239. * Disposes the component and the associated ressources
  108240. */
  108241. dispose(): void;
  108242. private _gatherRenderTargets;
  108243. private _gatherActiveCameraRenderTargets;
  108244. }
  108245. }
  108246. declare module BABYLON {
  108247. interface Scene {
  108248. /** @hidden (Backing field) */
  108249. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108250. /**
  108251. * Gets or Sets the current geometry buffer associated to the scene.
  108252. */
  108253. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108254. /**
  108255. * Enables a GeometryBufferRender and associates it with the scene
  108256. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108257. * @returns the GeometryBufferRenderer
  108258. */
  108259. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108260. /**
  108261. * Disables the GeometryBufferRender associated with the scene
  108262. */
  108263. disableGeometryBufferRenderer(): void;
  108264. }
  108265. /**
  108266. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108267. * in several rendering techniques.
  108268. */
  108269. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108270. /**
  108271. * The component name helpful to identify the component in the list of scene components.
  108272. */
  108273. readonly name: string;
  108274. /**
  108275. * The scene the component belongs to.
  108276. */
  108277. scene: Scene;
  108278. /**
  108279. * Creates a new instance of the component for the given scene
  108280. * @param scene Defines the scene to register the component in
  108281. */
  108282. constructor(scene: Scene);
  108283. /**
  108284. * Registers the component in a given scene
  108285. */
  108286. register(): void;
  108287. /**
  108288. * Rebuilds the elements related to this component in case of
  108289. * context lost for instance.
  108290. */
  108291. rebuild(): void;
  108292. /**
  108293. * Disposes the component and the associated ressources
  108294. */
  108295. dispose(): void;
  108296. private _gatherRenderTargets;
  108297. }
  108298. }
  108299. declare module BABYLON {
  108300. /** @hidden */
  108301. export var outlinePixelShader: {
  108302. name: string;
  108303. shader: string;
  108304. };
  108305. }
  108306. declare module BABYLON {
  108307. /** @hidden */
  108308. export var outlineVertexShader: {
  108309. name: string;
  108310. shader: string;
  108311. };
  108312. }
  108313. declare module BABYLON {
  108314. interface Scene {
  108315. /** @hidden */
  108316. _outlineRenderer: OutlineRenderer;
  108317. /**
  108318. * Gets the outline renderer associated with the scene
  108319. * @returns a OutlineRenderer
  108320. */
  108321. getOutlineRenderer(): OutlineRenderer;
  108322. }
  108323. interface AbstractMesh {
  108324. /** @hidden (Backing field) */
  108325. _renderOutline: boolean;
  108326. /**
  108327. * Gets or sets a boolean indicating if the outline must be rendered as well
  108328. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108329. */
  108330. renderOutline: boolean;
  108331. /** @hidden (Backing field) */
  108332. _renderOverlay: boolean;
  108333. /**
  108334. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108335. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108336. */
  108337. renderOverlay: boolean;
  108338. }
  108339. /**
  108340. * This class is responsible to draw bothe outline/overlay of meshes.
  108341. * It should not be used directly but through the available method on mesh.
  108342. */
  108343. export class OutlineRenderer implements ISceneComponent {
  108344. /**
  108345. * The name of the component. Each component must have a unique name.
  108346. */
  108347. name: string;
  108348. /**
  108349. * The scene the component belongs to.
  108350. */
  108351. scene: Scene;
  108352. /**
  108353. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108354. */
  108355. zOffset: number;
  108356. private _engine;
  108357. private _effect;
  108358. private _cachedDefines;
  108359. private _savedDepthWrite;
  108360. /**
  108361. * Instantiates a new outline renderer. (There could be only one per scene).
  108362. * @param scene Defines the scene it belongs to
  108363. */
  108364. constructor(scene: Scene);
  108365. /**
  108366. * Register the component to one instance of a scene.
  108367. */
  108368. register(): void;
  108369. /**
  108370. * Rebuilds the elements related to this component in case of
  108371. * context lost for instance.
  108372. */
  108373. rebuild(): void;
  108374. /**
  108375. * Disposes the component and the associated ressources.
  108376. */
  108377. dispose(): void;
  108378. /**
  108379. * Renders the outline in the canvas.
  108380. * @param subMesh Defines the sumesh to render
  108381. * @param batch Defines the batch of meshes in case of instances
  108382. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108383. */
  108384. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108385. /**
  108386. * Returns whether or not the outline renderer is ready for a given submesh.
  108387. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108388. * @param subMesh Defines the submesh to check readyness for
  108389. * @param useInstances Defines wheter wee are trying to render instances or not
  108390. * @returns true if ready otherwise false
  108391. */
  108392. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108393. private _beforeRenderingMesh;
  108394. private _afterRenderingMesh;
  108395. }
  108396. }
  108397. declare module BABYLON {
  108398. /**
  108399. * Defines the list of states available for a task inside a AssetsManager
  108400. */
  108401. export enum AssetTaskState {
  108402. /**
  108403. * Initialization
  108404. */
  108405. INIT = 0,
  108406. /**
  108407. * Running
  108408. */
  108409. RUNNING = 1,
  108410. /**
  108411. * Done
  108412. */
  108413. DONE = 2,
  108414. /**
  108415. * Error
  108416. */
  108417. ERROR = 3
  108418. }
  108419. /**
  108420. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108421. */
  108422. export abstract class AbstractAssetTask {
  108423. /**
  108424. * Task name
  108425. */ name: string;
  108426. /**
  108427. * Callback called when the task is successful
  108428. */
  108429. onSuccess: (task: any) => void;
  108430. /**
  108431. * Callback called when the task is not successful
  108432. */
  108433. onError: (task: any, message?: string, exception?: any) => void;
  108434. /**
  108435. * Creates a new AssetsManager
  108436. * @param name defines the name of the task
  108437. */
  108438. constructor(
  108439. /**
  108440. * Task name
  108441. */ name: string);
  108442. private _isCompleted;
  108443. private _taskState;
  108444. private _errorObject;
  108445. /**
  108446. * Get if the task is completed
  108447. */
  108448. readonly isCompleted: boolean;
  108449. /**
  108450. * Gets the current state of the task
  108451. */
  108452. readonly taskState: AssetTaskState;
  108453. /**
  108454. * Gets the current error object (if task is in error)
  108455. */
  108456. readonly errorObject: {
  108457. message?: string;
  108458. exception?: any;
  108459. };
  108460. /**
  108461. * Internal only
  108462. * @hidden
  108463. */
  108464. _setErrorObject(message?: string, exception?: any): void;
  108465. /**
  108466. * Execute the current task
  108467. * @param scene defines the scene where you want your assets to be loaded
  108468. * @param onSuccess is a callback called when the task is successfully executed
  108469. * @param onError is a callback called if an error occurs
  108470. */
  108471. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108472. /**
  108473. * Execute the current task
  108474. * @param scene defines the scene where you want your assets to be loaded
  108475. * @param onSuccess is a callback called when the task is successfully executed
  108476. * @param onError is a callback called if an error occurs
  108477. */
  108478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108479. /**
  108480. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  108481. * This can be used with failed tasks that have the reason for failure fixed.
  108482. */
  108483. reset(): void;
  108484. private onErrorCallback;
  108485. private onDoneCallback;
  108486. }
  108487. /**
  108488. * Define the interface used by progress events raised during assets loading
  108489. */
  108490. export interface IAssetsProgressEvent {
  108491. /**
  108492. * Defines the number of remaining tasks to process
  108493. */
  108494. remainingCount: number;
  108495. /**
  108496. * Defines the total number of tasks
  108497. */
  108498. totalCount: number;
  108499. /**
  108500. * Defines the task that was just processed
  108501. */
  108502. task: AbstractAssetTask;
  108503. }
  108504. /**
  108505. * Class used to share progress information about assets loading
  108506. */
  108507. export class AssetsProgressEvent implements IAssetsProgressEvent {
  108508. /**
  108509. * Defines the number of remaining tasks to process
  108510. */
  108511. remainingCount: number;
  108512. /**
  108513. * Defines the total number of tasks
  108514. */
  108515. totalCount: number;
  108516. /**
  108517. * Defines the task that was just processed
  108518. */
  108519. task: AbstractAssetTask;
  108520. /**
  108521. * Creates a AssetsProgressEvent
  108522. * @param remainingCount defines the number of remaining tasks to process
  108523. * @param totalCount defines the total number of tasks
  108524. * @param task defines the task that was just processed
  108525. */
  108526. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  108527. }
  108528. /**
  108529. * Define a task used by AssetsManager to load meshes
  108530. */
  108531. export class MeshAssetTask extends AbstractAssetTask {
  108532. /**
  108533. * Defines the name of the task
  108534. */
  108535. name: string;
  108536. /**
  108537. * Defines the list of mesh's names you want to load
  108538. */
  108539. meshesNames: any;
  108540. /**
  108541. * Defines the root url to use as a base to load your meshes and associated resources
  108542. */
  108543. rootUrl: string;
  108544. /**
  108545. * Defines the filename of the scene to load from
  108546. */
  108547. sceneFilename: string;
  108548. /**
  108549. * Gets the list of loaded meshes
  108550. */
  108551. loadedMeshes: Array<AbstractMesh>;
  108552. /**
  108553. * Gets the list of loaded particle systems
  108554. */
  108555. loadedParticleSystems: Array<IParticleSystem>;
  108556. /**
  108557. * Gets the list of loaded skeletons
  108558. */
  108559. loadedSkeletons: Array<Skeleton>;
  108560. /**
  108561. * Gets the list of loaded animation groups
  108562. */
  108563. loadedAnimationGroups: Array<AnimationGroup>;
  108564. /**
  108565. * Callback called when the task is successful
  108566. */
  108567. onSuccess: (task: MeshAssetTask) => void;
  108568. /**
  108569. * Callback called when the task is successful
  108570. */
  108571. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  108572. /**
  108573. * Creates a new MeshAssetTask
  108574. * @param name defines the name of the task
  108575. * @param meshesNames defines the list of mesh's names you want to load
  108576. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  108577. * @param sceneFilename defines the filename of the scene to load from
  108578. */
  108579. constructor(
  108580. /**
  108581. * Defines the name of the task
  108582. */
  108583. name: string,
  108584. /**
  108585. * Defines the list of mesh's names you want to load
  108586. */
  108587. meshesNames: any,
  108588. /**
  108589. * Defines the root url to use as a base to load your meshes and associated resources
  108590. */
  108591. rootUrl: string,
  108592. /**
  108593. * Defines the filename of the scene to load from
  108594. */
  108595. sceneFilename: string);
  108596. /**
  108597. * Execute the current task
  108598. * @param scene defines the scene where you want your assets to be loaded
  108599. * @param onSuccess is a callback called when the task is successfully executed
  108600. * @param onError is a callback called if an error occurs
  108601. */
  108602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108603. }
  108604. /**
  108605. * Define a task used by AssetsManager to load text content
  108606. */
  108607. export class TextFileAssetTask extends AbstractAssetTask {
  108608. /**
  108609. * Defines the name of the task
  108610. */
  108611. name: string;
  108612. /**
  108613. * Defines the location of the file to load
  108614. */
  108615. url: string;
  108616. /**
  108617. * Gets the loaded text string
  108618. */
  108619. text: string;
  108620. /**
  108621. * Callback called when the task is successful
  108622. */
  108623. onSuccess: (task: TextFileAssetTask) => void;
  108624. /**
  108625. * Callback called when the task is successful
  108626. */
  108627. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  108628. /**
  108629. * Creates a new TextFileAssetTask object
  108630. * @param name defines the name of the task
  108631. * @param url defines the location of the file to load
  108632. */
  108633. constructor(
  108634. /**
  108635. * Defines the name of the task
  108636. */
  108637. name: string,
  108638. /**
  108639. * Defines the location of the file to load
  108640. */
  108641. url: string);
  108642. /**
  108643. * Execute the current task
  108644. * @param scene defines the scene where you want your assets to be loaded
  108645. * @param onSuccess is a callback called when the task is successfully executed
  108646. * @param onError is a callback called if an error occurs
  108647. */
  108648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108649. }
  108650. /**
  108651. * Define a task used by AssetsManager to load binary data
  108652. */
  108653. export class BinaryFileAssetTask extends AbstractAssetTask {
  108654. /**
  108655. * Defines the name of the task
  108656. */
  108657. name: string;
  108658. /**
  108659. * Defines the location of the file to load
  108660. */
  108661. url: string;
  108662. /**
  108663. * Gets the lodaded data (as an array buffer)
  108664. */
  108665. data: ArrayBuffer;
  108666. /**
  108667. * Callback called when the task is successful
  108668. */
  108669. onSuccess: (task: BinaryFileAssetTask) => void;
  108670. /**
  108671. * Callback called when the task is successful
  108672. */
  108673. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  108674. /**
  108675. * Creates a new BinaryFileAssetTask object
  108676. * @param name defines the name of the new task
  108677. * @param url defines the location of the file to load
  108678. */
  108679. constructor(
  108680. /**
  108681. * Defines the name of the task
  108682. */
  108683. name: string,
  108684. /**
  108685. * Defines the location of the file to load
  108686. */
  108687. url: string);
  108688. /**
  108689. * Execute the current task
  108690. * @param scene defines the scene where you want your assets to be loaded
  108691. * @param onSuccess is a callback called when the task is successfully executed
  108692. * @param onError is a callback called if an error occurs
  108693. */
  108694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108695. }
  108696. /**
  108697. * Define a task used by AssetsManager to load images
  108698. */
  108699. export class ImageAssetTask extends AbstractAssetTask {
  108700. /**
  108701. * Defines the name of the task
  108702. */
  108703. name: string;
  108704. /**
  108705. * Defines the location of the image to load
  108706. */
  108707. url: string;
  108708. /**
  108709. * Gets the loaded images
  108710. */
  108711. image: HTMLImageElement;
  108712. /**
  108713. * Callback called when the task is successful
  108714. */
  108715. onSuccess: (task: ImageAssetTask) => void;
  108716. /**
  108717. * Callback called when the task is successful
  108718. */
  108719. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  108720. /**
  108721. * Creates a new ImageAssetTask
  108722. * @param name defines the name of the task
  108723. * @param url defines the location of the image to load
  108724. */
  108725. constructor(
  108726. /**
  108727. * Defines the name of the task
  108728. */
  108729. name: string,
  108730. /**
  108731. * Defines the location of the image to load
  108732. */
  108733. url: string);
  108734. /**
  108735. * Execute the current task
  108736. * @param scene defines the scene where you want your assets to be loaded
  108737. * @param onSuccess is a callback called when the task is successfully executed
  108738. * @param onError is a callback called if an error occurs
  108739. */
  108740. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108741. }
  108742. /**
  108743. * Defines the interface used by texture loading tasks
  108744. */
  108745. export interface ITextureAssetTask<TEX extends BaseTexture> {
  108746. /**
  108747. * Gets the loaded texture
  108748. */
  108749. texture: TEX;
  108750. }
  108751. /**
  108752. * Define a task used by AssetsManager to load 2D textures
  108753. */
  108754. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  108755. /**
  108756. * Defines the name of the task
  108757. */
  108758. name: string;
  108759. /**
  108760. * Defines the location of the file to load
  108761. */
  108762. url: string;
  108763. /**
  108764. * Defines if mipmap should not be generated (default is false)
  108765. */
  108766. noMipmap?: boolean | undefined;
  108767. /**
  108768. * Defines if texture must be inverted on Y axis (default is false)
  108769. */
  108770. invertY?: boolean | undefined;
  108771. /**
  108772. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108773. */
  108774. samplingMode: number;
  108775. /**
  108776. * Gets the loaded texture
  108777. */
  108778. texture: Texture;
  108779. /**
  108780. * Callback called when the task is successful
  108781. */
  108782. onSuccess: (task: TextureAssetTask) => void;
  108783. /**
  108784. * Callback called when the task is successful
  108785. */
  108786. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  108787. /**
  108788. * Creates a new TextureAssetTask object
  108789. * @param name defines the name of the task
  108790. * @param url defines the location of the file to load
  108791. * @param noMipmap defines if mipmap should not be generated (default is false)
  108792. * @param invertY defines if texture must be inverted on Y axis (default is false)
  108793. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108794. */
  108795. constructor(
  108796. /**
  108797. * Defines the name of the task
  108798. */
  108799. name: string,
  108800. /**
  108801. * Defines the location of the file to load
  108802. */
  108803. url: string,
  108804. /**
  108805. * Defines if mipmap should not be generated (default is false)
  108806. */
  108807. noMipmap?: boolean | undefined,
  108808. /**
  108809. * Defines if texture must be inverted on Y axis (default is false)
  108810. */
  108811. invertY?: boolean | undefined,
  108812. /**
  108813. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108814. */
  108815. samplingMode?: number);
  108816. /**
  108817. * Execute the current task
  108818. * @param scene defines the scene where you want your assets to be loaded
  108819. * @param onSuccess is a callback called when the task is successfully executed
  108820. * @param onError is a callback called if an error occurs
  108821. */
  108822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108823. }
  108824. /**
  108825. * Define a task used by AssetsManager to load cube textures
  108826. */
  108827. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  108828. /**
  108829. * Defines the name of the task
  108830. */
  108831. name: string;
  108832. /**
  108833. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108834. */
  108835. url: string;
  108836. /**
  108837. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108838. */
  108839. extensions?: string[] | undefined;
  108840. /**
  108841. * Defines if mipmaps should not be generated (default is false)
  108842. */
  108843. noMipmap?: boolean | undefined;
  108844. /**
  108845. * Defines the explicit list of files (undefined by default)
  108846. */
  108847. files?: string[] | undefined;
  108848. /**
  108849. * Gets the loaded texture
  108850. */
  108851. texture: CubeTexture;
  108852. /**
  108853. * Callback called when the task is successful
  108854. */
  108855. onSuccess: (task: CubeTextureAssetTask) => void;
  108856. /**
  108857. * Callback called when the task is successful
  108858. */
  108859. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  108860. /**
  108861. * Creates a new CubeTextureAssetTask
  108862. * @param name defines the name of the task
  108863. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108864. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108865. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108866. * @param files defines the explicit list of files (undefined by default)
  108867. */
  108868. constructor(
  108869. /**
  108870. * Defines the name of the task
  108871. */
  108872. name: string,
  108873. /**
  108874. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108875. */
  108876. url: string,
  108877. /**
  108878. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108879. */
  108880. extensions?: string[] | undefined,
  108881. /**
  108882. * Defines if mipmaps should not be generated (default is false)
  108883. */
  108884. noMipmap?: boolean | undefined,
  108885. /**
  108886. * Defines the explicit list of files (undefined by default)
  108887. */
  108888. files?: string[] | undefined);
  108889. /**
  108890. * Execute the current task
  108891. * @param scene defines the scene where you want your assets to be loaded
  108892. * @param onSuccess is a callback called when the task is successfully executed
  108893. * @param onError is a callback called if an error occurs
  108894. */
  108895. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108896. }
  108897. /**
  108898. * Define a task used by AssetsManager to load HDR cube textures
  108899. */
  108900. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  108901. /**
  108902. * Defines the name of the task
  108903. */
  108904. name: string;
  108905. /**
  108906. * Defines the location of the file to load
  108907. */
  108908. url: string;
  108909. /**
  108910. * Defines the desired size (the more it increases the longer the generation will be)
  108911. */
  108912. size: number;
  108913. /**
  108914. * Defines if mipmaps should not be generated (default is false)
  108915. */
  108916. noMipmap: boolean;
  108917. /**
  108918. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108919. */
  108920. generateHarmonics: boolean;
  108921. /**
  108922. * 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)
  108923. */
  108924. gammaSpace: boolean;
  108925. /**
  108926. * Internal Use Only
  108927. */
  108928. reserved: boolean;
  108929. /**
  108930. * Gets the loaded texture
  108931. */
  108932. texture: HDRCubeTexture;
  108933. /**
  108934. * Callback called when the task is successful
  108935. */
  108936. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  108937. /**
  108938. * Callback called when the task is successful
  108939. */
  108940. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  108941. /**
  108942. * Creates a new HDRCubeTextureAssetTask object
  108943. * @param name defines the name of the task
  108944. * @param url defines the location of the file to load
  108945. * @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.
  108946. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108947. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108948. * @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)
  108949. * @param reserved Internal use only
  108950. */
  108951. constructor(
  108952. /**
  108953. * Defines the name of the task
  108954. */
  108955. name: string,
  108956. /**
  108957. * Defines the location of the file to load
  108958. */
  108959. url: string,
  108960. /**
  108961. * Defines the desired size (the more it increases the longer the generation will be)
  108962. */
  108963. size: number,
  108964. /**
  108965. * Defines if mipmaps should not be generated (default is false)
  108966. */
  108967. noMipmap?: boolean,
  108968. /**
  108969. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108970. */
  108971. generateHarmonics?: boolean,
  108972. /**
  108973. * 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)
  108974. */
  108975. gammaSpace?: boolean,
  108976. /**
  108977. * Internal Use Only
  108978. */
  108979. reserved?: boolean);
  108980. /**
  108981. * Execute the current task
  108982. * @param scene defines the scene where you want your assets to be loaded
  108983. * @param onSuccess is a callback called when the task is successfully executed
  108984. * @param onError is a callback called if an error occurs
  108985. */
  108986. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108987. }
  108988. /**
  108989. * This class can be used to easily import assets into a scene
  108990. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  108991. */
  108992. export class AssetsManager {
  108993. private _scene;
  108994. private _isLoading;
  108995. protected _tasks: AbstractAssetTask[];
  108996. protected _waitingTasksCount: number;
  108997. protected _totalTasksCount: number;
  108998. /**
  108999. * Callback called when all tasks are processed
  109000. */
  109001. onFinish: (tasks: AbstractAssetTask[]) => void;
  109002. /**
  109003. * Callback called when a task is successful
  109004. */
  109005. onTaskSuccess: (task: AbstractAssetTask) => void;
  109006. /**
  109007. * Callback called when a task had an error
  109008. */
  109009. onTaskError: (task: AbstractAssetTask) => void;
  109010. /**
  109011. * Callback called when a task is done (whatever the result is)
  109012. */
  109013. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  109014. /**
  109015. * Observable called when all tasks are processed
  109016. */
  109017. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  109018. /**
  109019. * Observable called when a task had an error
  109020. */
  109021. onTaskErrorObservable: Observable<AbstractAssetTask>;
  109022. /**
  109023. * Observable called when a task is successful
  109024. */
  109025. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  109026. /**
  109027. * Observable called when a task is done (whatever the result is)
  109028. */
  109029. onProgressObservable: Observable<IAssetsProgressEvent>;
  109030. /**
  109031. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  109032. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109033. */
  109034. useDefaultLoadingScreen: boolean;
  109035. /**
  109036. * Creates a new AssetsManager
  109037. * @param scene defines the scene to work on
  109038. */
  109039. constructor(scene: Scene);
  109040. /**
  109041. * Add a MeshAssetTask to the list of active tasks
  109042. * @param taskName defines the name of the new task
  109043. * @param meshesNames defines the name of meshes to load
  109044. * @param rootUrl defines the root url to use to locate files
  109045. * @param sceneFilename defines the filename of the scene file
  109046. * @returns a new MeshAssetTask object
  109047. */
  109048. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  109049. /**
  109050. * Add a TextFileAssetTask to the list of active tasks
  109051. * @param taskName defines the name of the new task
  109052. * @param url defines the url of the file to load
  109053. * @returns a new TextFileAssetTask object
  109054. */
  109055. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  109056. /**
  109057. * Add a BinaryFileAssetTask to the list of active tasks
  109058. * @param taskName defines the name of the new task
  109059. * @param url defines the url of the file to load
  109060. * @returns a new BinaryFileAssetTask object
  109061. */
  109062. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  109063. /**
  109064. * Add a ImageAssetTask to the list of active tasks
  109065. * @param taskName defines the name of the new task
  109066. * @param url defines the url of the file to load
  109067. * @returns a new ImageAssetTask object
  109068. */
  109069. addImageTask(taskName: string, url: string): ImageAssetTask;
  109070. /**
  109071. * Add a TextureAssetTask to the list of active tasks
  109072. * @param taskName defines the name of the new task
  109073. * @param url defines the url of the file to load
  109074. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109075. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  109076. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109077. * @returns a new TextureAssetTask object
  109078. */
  109079. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  109080. /**
  109081. * Add a CubeTextureAssetTask to the list of active tasks
  109082. * @param taskName defines the name of the new task
  109083. * @param url defines the url of the file to load
  109084. * @param extensions defines the extension to use to load the cube map (can be null)
  109085. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109086. * @param files defines the list of files to load (can be null)
  109087. * @returns a new CubeTextureAssetTask object
  109088. */
  109089. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  109090. /**
  109091. *
  109092. * Add a HDRCubeTextureAssetTask to the list of active tasks
  109093. * @param taskName defines the name of the new task
  109094. * @param url defines the url of the file to load
  109095. * @param size defines the size you want for the cubemap (can be null)
  109096. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109097. * @param generateHarmonics defines if you want to automatically generate (true by default)
  109098. * @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)
  109099. * @param reserved Internal use only
  109100. * @returns a new HDRCubeTextureAssetTask object
  109101. */
  109102. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  109103. /**
  109104. * Remove a task from the assets manager.
  109105. * @param task the task to remove
  109106. */
  109107. removeTask(task: AbstractAssetTask): void;
  109108. private _decreaseWaitingTasksCount;
  109109. private _runTask;
  109110. /**
  109111. * Reset the AssetsManager and remove all tasks
  109112. * @return the current instance of the AssetsManager
  109113. */
  109114. reset(): AssetsManager;
  109115. /**
  109116. * Start the loading process
  109117. * @return the current instance of the AssetsManager
  109118. */
  109119. load(): AssetsManager;
  109120. }
  109121. }
  109122. declare module BABYLON {
  109123. /**
  109124. * Wrapper class for promise with external resolve and reject.
  109125. */
  109126. export class Deferred<T> {
  109127. /**
  109128. * The promise associated with this deferred object.
  109129. */
  109130. readonly promise: Promise<T>;
  109131. private _resolve;
  109132. private _reject;
  109133. /**
  109134. * The resolve method of the promise associated with this deferred object.
  109135. */
  109136. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  109137. /**
  109138. * The reject method of the promise associated with this deferred object.
  109139. */
  109140. readonly reject: (reason?: any) => void;
  109141. /**
  109142. * Constructor for this deferred object.
  109143. */
  109144. constructor();
  109145. }
  109146. }
  109147. declare module BABYLON {
  109148. /**
  109149. * Class used to help managing file picking and drag'n'drop
  109150. */
  109151. export class FilesInput {
  109152. /**
  109153. * List of files ready to be loaded
  109154. */
  109155. static readonly FilesToLoad: {
  109156. [key: string]: File;
  109157. };
  109158. /**
  109159. * Callback called when a file is processed
  109160. */
  109161. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  109162. private _engine;
  109163. private _currentScene;
  109164. private _sceneLoadedCallback;
  109165. private _progressCallback;
  109166. private _additionalRenderLoopLogicCallback;
  109167. private _textureLoadingCallback;
  109168. private _startingProcessingFilesCallback;
  109169. private _onReloadCallback;
  109170. private _errorCallback;
  109171. private _elementToMonitor;
  109172. private _sceneFileToLoad;
  109173. private _filesToLoad;
  109174. /**
  109175. * Creates a new FilesInput
  109176. * @param engine defines the rendering engine
  109177. * @param scene defines the hosting scene
  109178. * @param sceneLoadedCallback callback called when scene is loaded
  109179. * @param progressCallback callback called to track progress
  109180. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  109181. * @param textureLoadingCallback callback called when a texture is loading
  109182. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  109183. * @param onReloadCallback callback called when a reload is requested
  109184. * @param errorCallback callback call if an error occurs
  109185. */
  109186. 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);
  109187. private _dragEnterHandler;
  109188. private _dragOverHandler;
  109189. private _dropHandler;
  109190. /**
  109191. * Calls this function to listen to drag'n'drop events on a specific DOM element
  109192. * @param elementToMonitor defines the DOM element to track
  109193. */
  109194. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  109195. /**
  109196. * Release all associated resources
  109197. */
  109198. dispose(): void;
  109199. private renderFunction;
  109200. private drag;
  109201. private drop;
  109202. private _traverseFolder;
  109203. private _processFiles;
  109204. /**
  109205. * Load files from a drop event
  109206. * @param event defines the drop event to use as source
  109207. */
  109208. loadFiles(event: any): void;
  109209. private _processReload;
  109210. /**
  109211. * Reload the current scene from the loaded files
  109212. */
  109213. reload(): void;
  109214. }
  109215. }
  109216. declare module BABYLON {
  109217. /**
  109218. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109220. */
  109221. export class SceneOptimization {
  109222. /**
  109223. * Defines the priority of this optimization (0 by default which means first in the list)
  109224. */
  109225. priority: number;
  109226. /**
  109227. * Gets a string describing the action executed by the current optimization
  109228. * @returns description string
  109229. */
  109230. getDescription(): string;
  109231. /**
  109232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109233. * @param scene defines the current scene where to apply this optimization
  109234. * @param optimizer defines the current optimizer
  109235. * @returns true if everything that can be done was applied
  109236. */
  109237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109238. /**
  109239. * Creates the SceneOptimization object
  109240. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109241. * @param desc defines the description associated with the optimization
  109242. */
  109243. constructor(
  109244. /**
  109245. * Defines the priority of this optimization (0 by default which means first in the list)
  109246. */
  109247. priority?: number);
  109248. }
  109249. /**
  109250. * Defines an optimization used to reduce the size of render target textures
  109251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109252. */
  109253. export class TextureOptimization extends SceneOptimization {
  109254. /**
  109255. * Defines the priority of this optimization (0 by default which means first in the list)
  109256. */
  109257. priority: number;
  109258. /**
  109259. * 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
  109260. */
  109261. maximumSize: number;
  109262. /**
  109263. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109264. */
  109265. step: number;
  109266. /**
  109267. * Gets a string describing the action executed by the current optimization
  109268. * @returns description string
  109269. */
  109270. getDescription(): string;
  109271. /**
  109272. * Creates the TextureOptimization object
  109273. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109274. * @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
  109275. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109276. */
  109277. constructor(
  109278. /**
  109279. * Defines the priority of this optimization (0 by default which means first in the list)
  109280. */
  109281. priority?: number,
  109282. /**
  109283. * 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
  109284. */
  109285. maximumSize?: number,
  109286. /**
  109287. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109288. */
  109289. step?: number);
  109290. /**
  109291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109292. * @param scene defines the current scene where to apply this optimization
  109293. * @param optimizer defines the current optimizer
  109294. * @returns true if everything that can be done was applied
  109295. */
  109296. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109297. }
  109298. /**
  109299. * Defines an optimization used to increase or decrease the rendering resolution
  109300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109301. */
  109302. export class HardwareScalingOptimization extends SceneOptimization {
  109303. /**
  109304. * Defines the priority of this optimization (0 by default which means first in the list)
  109305. */
  109306. priority: number;
  109307. /**
  109308. * Defines the maximum scale to use (2 by default)
  109309. */
  109310. maximumScale: number;
  109311. /**
  109312. * Defines the step to use between two passes (0.5 by default)
  109313. */
  109314. step: number;
  109315. private _currentScale;
  109316. private _directionOffset;
  109317. /**
  109318. * Gets a string describing the action executed by the current optimization
  109319. * @return description string
  109320. */
  109321. getDescription(): string;
  109322. /**
  109323. * Creates the HardwareScalingOptimization object
  109324. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109325. * @param maximumScale defines the maximum scale to use (2 by default)
  109326. * @param step defines the step to use between two passes (0.5 by default)
  109327. */
  109328. constructor(
  109329. /**
  109330. * Defines the priority of this optimization (0 by default which means first in the list)
  109331. */
  109332. priority?: number,
  109333. /**
  109334. * Defines the maximum scale to use (2 by default)
  109335. */
  109336. maximumScale?: number,
  109337. /**
  109338. * Defines the step to use between two passes (0.5 by default)
  109339. */
  109340. step?: number);
  109341. /**
  109342. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109343. * @param scene defines the current scene where to apply this optimization
  109344. * @param optimizer defines the current optimizer
  109345. * @returns true if everything that can be done was applied
  109346. */
  109347. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109348. }
  109349. /**
  109350. * Defines an optimization used to remove shadows
  109351. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109352. */
  109353. export class ShadowsOptimization extends SceneOptimization {
  109354. /**
  109355. * Gets a string describing the action executed by the current optimization
  109356. * @return description string
  109357. */
  109358. getDescription(): string;
  109359. /**
  109360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109361. * @param scene defines the current scene where to apply this optimization
  109362. * @param optimizer defines the current optimizer
  109363. * @returns true if everything that can be done was applied
  109364. */
  109365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109366. }
  109367. /**
  109368. * Defines an optimization used to turn post-processes off
  109369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109370. */
  109371. export class PostProcessesOptimization extends SceneOptimization {
  109372. /**
  109373. * Gets a string describing the action executed by the current optimization
  109374. * @return description string
  109375. */
  109376. getDescription(): string;
  109377. /**
  109378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109379. * @param scene defines the current scene where to apply this optimization
  109380. * @param optimizer defines the current optimizer
  109381. * @returns true if everything that can be done was applied
  109382. */
  109383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109384. }
  109385. /**
  109386. * Defines an optimization used to turn lens flares off
  109387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109388. */
  109389. export class LensFlaresOptimization extends SceneOptimization {
  109390. /**
  109391. * Gets a string describing the action executed by the current optimization
  109392. * @return description string
  109393. */
  109394. getDescription(): string;
  109395. /**
  109396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109397. * @param scene defines the current scene where to apply this optimization
  109398. * @param optimizer defines the current optimizer
  109399. * @returns true if everything that can be done was applied
  109400. */
  109401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109402. }
  109403. /**
  109404. * Defines an optimization based on user defined callback.
  109405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109406. */
  109407. export class CustomOptimization extends SceneOptimization {
  109408. /**
  109409. * Callback called to apply the custom optimization.
  109410. */
  109411. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109412. /**
  109413. * Callback called to get custom description
  109414. */
  109415. onGetDescription: () => string;
  109416. /**
  109417. * Gets a string describing the action executed by the current optimization
  109418. * @returns description string
  109419. */
  109420. getDescription(): string;
  109421. /**
  109422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109423. * @param scene defines the current scene where to apply this optimization
  109424. * @param optimizer defines the current optimizer
  109425. * @returns true if everything that can be done was applied
  109426. */
  109427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109428. }
  109429. /**
  109430. * Defines an optimization used to turn particles off
  109431. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109432. */
  109433. export class ParticlesOptimization extends SceneOptimization {
  109434. /**
  109435. * Gets a string describing the action executed by the current optimization
  109436. * @return description string
  109437. */
  109438. getDescription(): string;
  109439. /**
  109440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109441. * @param scene defines the current scene where to apply this optimization
  109442. * @param optimizer defines the current optimizer
  109443. * @returns true if everything that can be done was applied
  109444. */
  109445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109446. }
  109447. /**
  109448. * Defines an optimization used to turn render targets off
  109449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109450. */
  109451. export class RenderTargetsOptimization extends SceneOptimization {
  109452. /**
  109453. * Gets a string describing the action executed by the current optimization
  109454. * @return description string
  109455. */
  109456. getDescription(): string;
  109457. /**
  109458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109459. * @param scene defines the current scene where to apply this optimization
  109460. * @param optimizer defines the current optimizer
  109461. * @returns true if everything that can be done was applied
  109462. */
  109463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109464. }
  109465. /**
  109466. * Defines an optimization used to merge meshes with compatible materials
  109467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109468. */
  109469. export class MergeMeshesOptimization extends SceneOptimization {
  109470. private static _UpdateSelectionTree;
  109471. /**
  109472. * Gets or sets a boolean which defines if optimization octree has to be updated
  109473. */
  109474. /**
  109475. * Gets or sets a boolean which defines if optimization octree has to be updated
  109476. */
  109477. static UpdateSelectionTree: boolean;
  109478. /**
  109479. * Gets a string describing the action executed by the current optimization
  109480. * @return description string
  109481. */
  109482. getDescription(): string;
  109483. private _canBeMerged;
  109484. /**
  109485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109486. * @param scene defines the current scene where to apply this optimization
  109487. * @param optimizer defines the current optimizer
  109488. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  109489. * @returns true if everything that can be done was applied
  109490. */
  109491. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  109492. }
  109493. /**
  109494. * Defines a list of options used by SceneOptimizer
  109495. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109496. */
  109497. export class SceneOptimizerOptions {
  109498. /**
  109499. * Defines the target frame rate to reach (60 by default)
  109500. */
  109501. targetFrameRate: number;
  109502. /**
  109503. * Defines the interval between two checkes (2000ms by default)
  109504. */
  109505. trackerDuration: number;
  109506. /**
  109507. * Gets the list of optimizations to apply
  109508. */
  109509. optimizations: SceneOptimization[];
  109510. /**
  109511. * Creates a new list of options used by SceneOptimizer
  109512. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  109513. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  109514. */
  109515. constructor(
  109516. /**
  109517. * Defines the target frame rate to reach (60 by default)
  109518. */
  109519. targetFrameRate?: number,
  109520. /**
  109521. * Defines the interval between two checkes (2000ms by default)
  109522. */
  109523. trackerDuration?: number);
  109524. /**
  109525. * Add a new optimization
  109526. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  109527. * @returns the current SceneOptimizerOptions
  109528. */
  109529. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  109530. /**
  109531. * Add a new custom optimization
  109532. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  109533. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  109534. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109535. * @returns the current SceneOptimizerOptions
  109536. */
  109537. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  109538. /**
  109539. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  109540. * @param targetFrameRate defines the target frame rate (60 by default)
  109541. * @returns a SceneOptimizerOptions object
  109542. */
  109543. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109544. /**
  109545. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  109546. * @param targetFrameRate defines the target frame rate (60 by default)
  109547. * @returns a SceneOptimizerOptions object
  109548. */
  109549. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109550. /**
  109551. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  109552. * @param targetFrameRate defines the target frame rate (60 by default)
  109553. * @returns a SceneOptimizerOptions object
  109554. */
  109555. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109556. }
  109557. /**
  109558. * Class used to run optimizations in order to reach a target frame rate
  109559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109560. */
  109561. export class SceneOptimizer implements IDisposable {
  109562. private _isRunning;
  109563. private _options;
  109564. private _scene;
  109565. private _currentPriorityLevel;
  109566. private _targetFrameRate;
  109567. private _trackerDuration;
  109568. private _currentFrameRate;
  109569. private _sceneDisposeObserver;
  109570. private _improvementMode;
  109571. /**
  109572. * Defines an observable called when the optimizer reaches the target frame rate
  109573. */
  109574. onSuccessObservable: Observable<SceneOptimizer>;
  109575. /**
  109576. * Defines an observable called when the optimizer enables an optimization
  109577. */
  109578. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  109579. /**
  109580. * Defines an observable called when the optimizer is not able to reach the target frame rate
  109581. */
  109582. onFailureObservable: Observable<SceneOptimizer>;
  109583. /**
  109584. * Gets a boolean indicating if the optimizer is in improvement mode
  109585. */
  109586. readonly isInImprovementMode: boolean;
  109587. /**
  109588. * Gets the current priority level (0 at start)
  109589. */
  109590. readonly currentPriorityLevel: number;
  109591. /**
  109592. * Gets the current frame rate checked by the SceneOptimizer
  109593. */
  109594. readonly currentFrameRate: number;
  109595. /**
  109596. * Gets or sets the current target frame rate (60 by default)
  109597. */
  109598. /**
  109599. * Gets or sets the current target frame rate (60 by default)
  109600. */
  109601. targetFrameRate: number;
  109602. /**
  109603. * Gets or sets the current interval between two checks (every 2000ms by default)
  109604. */
  109605. /**
  109606. * Gets or sets the current interval between two checks (every 2000ms by default)
  109607. */
  109608. trackerDuration: number;
  109609. /**
  109610. * Gets the list of active optimizations
  109611. */
  109612. readonly optimizations: SceneOptimization[];
  109613. /**
  109614. * Creates a new SceneOptimizer
  109615. * @param scene defines the scene to work on
  109616. * @param options defines the options to use with the SceneOptimizer
  109617. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  109618. * @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)
  109619. */
  109620. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  109621. /**
  109622. * Stops the current optimizer
  109623. */
  109624. stop(): void;
  109625. /**
  109626. * Reset the optimizer to initial step (current priority level = 0)
  109627. */
  109628. reset(): void;
  109629. /**
  109630. * Start the optimizer. By default it will try to reach a specific framerate
  109631. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  109632. */
  109633. start(): void;
  109634. private _checkCurrentState;
  109635. /**
  109636. * Release all resources
  109637. */
  109638. dispose(): void;
  109639. /**
  109640. * Helper function to create a SceneOptimizer with one single line of code
  109641. * @param scene defines the scene to work on
  109642. * @param options defines the options to use with the SceneOptimizer
  109643. * @param onSuccess defines a callback to call on success
  109644. * @param onFailure defines a callback to call on failure
  109645. * @returns the new SceneOptimizer object
  109646. */
  109647. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  109648. }
  109649. }
  109650. declare module BABYLON {
  109651. /**
  109652. * Class used to serialize a scene into a string
  109653. */
  109654. export class SceneSerializer {
  109655. /**
  109656. * Clear cache used by a previous serialization
  109657. */
  109658. static ClearCache(): void;
  109659. /**
  109660. * Serialize a scene into a JSON compatible object
  109661. * @param scene defines the scene to serialize
  109662. * @returns a JSON compatible object
  109663. */
  109664. static Serialize(scene: Scene): any;
  109665. /**
  109666. * Serialize a mesh into a JSON compatible object
  109667. * @param toSerialize defines the mesh to serialize
  109668. * @param withParents defines if parents must be serialized as well
  109669. * @param withChildren defines if children must be serialized as well
  109670. * @returns a JSON compatible object
  109671. */
  109672. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  109673. }
  109674. }
  109675. declare module BABYLON {
  109676. /**
  109677. * This represents the different options avilable for the video capture.
  109678. */
  109679. export interface VideoRecorderOptions {
  109680. /** Defines the mime type of the video */
  109681. mimeType: string;
  109682. /** Defines the video the video should be recorded at */
  109683. fps: number;
  109684. /** Defines the chunk size for the recording data */
  109685. recordChunckSize: number;
  109686. }
  109687. /**
  109688. * This can helps recording videos from BabylonJS.
  109689. * This is based on the available WebRTC functionalities of the browser.
  109690. *
  109691. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  109692. */
  109693. export class VideoRecorder {
  109694. private static readonly _defaultOptions;
  109695. /**
  109696. * Returns wehther or not the VideoRecorder is available in your browser.
  109697. * @param engine Defines the Babylon Engine to check the support for
  109698. * @returns true if supported otherwise false
  109699. */
  109700. static IsSupported(engine: Engine): boolean;
  109701. private readonly _options;
  109702. private _canvas;
  109703. private _mediaRecorder;
  109704. private _recordedChunks;
  109705. private _fileName;
  109706. private _resolve;
  109707. private _reject;
  109708. /**
  109709. * True wether a recording is already in progress.
  109710. */
  109711. readonly isRecording: boolean;
  109712. /**
  109713. * Create a new VideoCapture object which can help converting what you see in Babylon to
  109714. * a video file.
  109715. * @param engine Defines the BabylonJS Engine you wish to record
  109716. * @param options Defines options that can be used to customized the capture
  109717. */
  109718. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  109719. /**
  109720. * Stops the current recording before the default capture timeout passed in the startRecording
  109721. * functions.
  109722. */
  109723. stopRecording(): void;
  109724. /**
  109725. * Starts recording the canvas for a max duration specified in parameters.
  109726. * @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.
  109727. * @param maxDuration Defines the maximum recording time in seconds.
  109728. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  109729. * @return a promise callback at the end of the recording with the video data in Blob.
  109730. */
  109731. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  109732. /**
  109733. * Releases internal resources used during the recording.
  109734. */
  109735. dispose(): void;
  109736. private _handleDataAvailable;
  109737. private _handleError;
  109738. private _handleStop;
  109739. }
  109740. }
  109741. declare module BABYLON {
  109742. /**
  109743. * Helper class to push actions to a pool of workers.
  109744. */
  109745. export class WorkerPool implements IDisposable {
  109746. private _workerInfos;
  109747. private _pendingActions;
  109748. /**
  109749. * Constructor
  109750. * @param workers Array of workers to use for actions
  109751. */
  109752. constructor(workers: Array<Worker>);
  109753. /**
  109754. * Terminates all workers and clears any pending actions.
  109755. */
  109756. dispose(): void;
  109757. /**
  109758. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109759. * pended until a worker has completed its action.
  109760. * @param action The action to perform. Call onComplete when the action is complete.
  109761. */
  109762. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109763. private _execute;
  109764. }
  109765. }
  109766. declare module BABYLON {
  109767. /**
  109768. * Class containing a set of static utilities functions for screenshots
  109769. */
  109770. export class ScreenshotTools {
  109771. /**
  109772. * Captures a screenshot of the current rendering
  109773. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109774. * @param engine defines the rendering engine
  109775. * @param camera defines the source camera
  109776. * @param size This parameter can be set to a single number or to an object with the
  109777. * following (optional) properties: precision, width, height. If a single number is passed,
  109778. * it will be used for both width and height. If an object is passed, the screenshot size
  109779. * will be derived from the parameters. The precision property is a multiplier allowing
  109780. * rendering at a higher or lower resolution
  109781. * @param successCallback defines the callback receives a single parameter which contains the
  109782. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109783. * src parameter of an <img> to display it
  109784. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109785. * Check your browser for supported MIME types
  109786. */
  109787. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  109788. /**
  109789. * Generates an image screenshot from the specified camera.
  109790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109791. * @param engine The engine to use for rendering
  109792. * @param camera The camera to use for rendering
  109793. * @param size This parameter can be set to a single number or to an object with the
  109794. * following (optional) properties: precision, width, height. If a single number is passed,
  109795. * it will be used for both width and height. If an object is passed, the screenshot size
  109796. * will be derived from the parameters. The precision property is a multiplier allowing
  109797. * rendering at a higher or lower resolution
  109798. * @param successCallback The callback receives a single parameter which contains the
  109799. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109800. * src parameter of an <img> to display it
  109801. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109802. * Check your browser for supported MIME types
  109803. * @param samples Texture samples (default: 1)
  109804. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109805. * @param fileName A name for for the downloaded file.
  109806. */
  109807. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109808. }
  109809. }
  109810. declare module BABYLON {
  109811. /**
  109812. * A cursor which tracks a point on a path
  109813. */
  109814. export class PathCursor {
  109815. private path;
  109816. /**
  109817. * Stores path cursor callbacks for when an onchange event is triggered
  109818. */
  109819. private _onchange;
  109820. /**
  109821. * The value of the path cursor
  109822. */
  109823. value: number;
  109824. /**
  109825. * The animation array of the path cursor
  109826. */
  109827. animations: Animation[];
  109828. /**
  109829. * Initializes the path cursor
  109830. * @param path The path to track
  109831. */
  109832. constructor(path: Path2);
  109833. /**
  109834. * Gets the cursor point on the path
  109835. * @returns A point on the path cursor at the cursor location
  109836. */
  109837. getPoint(): Vector3;
  109838. /**
  109839. * Moves the cursor ahead by the step amount
  109840. * @param step The amount to move the cursor forward
  109841. * @returns This path cursor
  109842. */
  109843. moveAhead(step?: number): PathCursor;
  109844. /**
  109845. * Moves the cursor behind by the step amount
  109846. * @param step The amount to move the cursor back
  109847. * @returns This path cursor
  109848. */
  109849. moveBack(step?: number): PathCursor;
  109850. /**
  109851. * Moves the cursor by the step amount
  109852. * If the step amount is greater than one, an exception is thrown
  109853. * @param step The amount to move the cursor
  109854. * @returns This path cursor
  109855. */
  109856. move(step: number): PathCursor;
  109857. /**
  109858. * Ensures that the value is limited between zero and one
  109859. * @returns This path cursor
  109860. */
  109861. private ensureLimits;
  109862. /**
  109863. * Runs onchange callbacks on change (used by the animation engine)
  109864. * @returns This path cursor
  109865. */
  109866. private raiseOnChange;
  109867. /**
  109868. * Executes a function on change
  109869. * @param f A path cursor onchange callback
  109870. * @returns This path cursor
  109871. */
  109872. onchange(f: (cursor: PathCursor) => void): PathCursor;
  109873. }
  109874. }
  109875. declare module BABYLON {
  109876. /** @hidden */
  109877. export var blurPixelShader: {
  109878. name: string;
  109879. shader: string;
  109880. };
  109881. }
  109882. declare module BABYLON {
  109883. /** @hidden */
  109884. export var bones300Declaration: {
  109885. name: string;
  109886. shader: string;
  109887. };
  109888. }
  109889. declare module BABYLON {
  109890. /** @hidden */
  109891. export var instances300Declaration: {
  109892. name: string;
  109893. shader: string;
  109894. };
  109895. }
  109896. declare module BABYLON {
  109897. /** @hidden */
  109898. export var pointCloudVertexDeclaration: {
  109899. name: string;
  109900. shader: string;
  109901. };
  109902. }
  109903. // Mixins
  109904. interface Window {
  109905. mozIndexedDB: IDBFactory;
  109906. webkitIndexedDB: IDBFactory;
  109907. msIndexedDB: IDBFactory;
  109908. webkitURL: typeof URL;
  109909. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  109910. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  109911. WebGLRenderingContext: WebGLRenderingContext;
  109912. MSGesture: MSGesture;
  109913. CANNON: any;
  109914. AudioContext: AudioContext;
  109915. webkitAudioContext: AudioContext;
  109916. PointerEvent: any;
  109917. Math: Math;
  109918. Uint8Array: Uint8ArrayConstructor;
  109919. Float32Array: Float32ArrayConstructor;
  109920. mozURL: typeof URL;
  109921. msURL: typeof URL;
  109922. VRFrameData: any; // WebVR, from specs 1.1
  109923. DracoDecoderModule: any;
  109924. setImmediate(handler: (...args: any[]) => void): number;
  109925. }
  109926. interface Document {
  109927. mozCancelFullScreen(): void;
  109928. msCancelFullScreen(): void;
  109929. webkitCancelFullScreen(): void;
  109930. requestPointerLock(): void;
  109931. exitPointerLock(): void;
  109932. mozFullScreen: boolean;
  109933. msIsFullScreen: boolean;
  109934. readonly webkitIsFullScreen: boolean;
  109935. readonly pointerLockElement: Element;
  109936. mozPointerLockElement: HTMLElement;
  109937. msPointerLockElement: HTMLElement;
  109938. webkitPointerLockElement: HTMLElement;
  109939. }
  109940. interface HTMLCanvasElement {
  109941. requestPointerLock(): void;
  109942. msRequestPointerLock?(): void;
  109943. mozRequestPointerLock?(): void;
  109944. webkitRequestPointerLock?(): void;
  109945. /** Track wether a record is in progress */
  109946. isRecording: boolean;
  109947. /** Capture Stream method defined by some browsers */
  109948. captureStream(fps?: number): MediaStream;
  109949. }
  109950. interface CanvasRenderingContext2D {
  109951. msImageSmoothingEnabled: boolean;
  109952. }
  109953. interface MouseEvent {
  109954. mozMovementX: number;
  109955. mozMovementY: number;
  109956. webkitMovementX: number;
  109957. webkitMovementY: number;
  109958. msMovementX: number;
  109959. msMovementY: number;
  109960. }
  109961. interface Navigator {
  109962. mozGetVRDevices: (any: any) => any;
  109963. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109964. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109965. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109966. webkitGetGamepads(): Gamepad[];
  109967. msGetGamepads(): Gamepad[];
  109968. webkitGamepads(): Gamepad[];
  109969. }
  109970. interface HTMLVideoElement {
  109971. mozSrcObject: any;
  109972. }
  109973. interface Math {
  109974. fround(x: number): number;
  109975. imul(a: number, b: number): number;
  109976. }
  109977. interface WebGLProgram {
  109978. context?: WebGLRenderingContext;
  109979. vertexShader?: WebGLShader;
  109980. fragmentShader?: WebGLShader;
  109981. isParallelCompiled: boolean;
  109982. onCompiled?: () => void;
  109983. }
  109984. interface WebGLRenderingContext {
  109985. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  109986. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  109987. vertexAttribDivisor(index: number, divisor: number): void;
  109988. createVertexArray(): any;
  109989. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  109990. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  109991. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  109992. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  109993. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  109994. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  109995. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  109996. // Queries
  109997. createQuery(): WebGLQuery;
  109998. deleteQuery(query: WebGLQuery): void;
  109999. beginQuery(target: number, query: WebGLQuery): void;
  110000. endQuery(target: number): void;
  110001. getQueryParameter(query: WebGLQuery, pname: number): any;
  110002. getQuery(target: number, pname: number): any;
  110003. MAX_SAMPLES: number;
  110004. RGBA8: number;
  110005. READ_FRAMEBUFFER: number;
  110006. DRAW_FRAMEBUFFER: number;
  110007. UNIFORM_BUFFER: number;
  110008. HALF_FLOAT_OES: number;
  110009. RGBA16F: number;
  110010. RGBA32F: number;
  110011. R32F: number;
  110012. RG32F: number;
  110013. RGB32F: number;
  110014. R16F: number;
  110015. RG16F: number;
  110016. RGB16F: number;
  110017. RED: number;
  110018. RG: number;
  110019. R8: number;
  110020. RG8: number;
  110021. UNSIGNED_INT_24_8: number;
  110022. DEPTH24_STENCIL8: number;
  110023. /* Multiple Render Targets */
  110024. drawBuffers(buffers: number[]): void;
  110025. readBuffer(src: number): void;
  110026. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  110027. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  110028. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  110029. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  110030. // Occlusion Query
  110031. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  110032. ANY_SAMPLES_PASSED: number;
  110033. QUERY_RESULT_AVAILABLE: number;
  110034. QUERY_RESULT: number;
  110035. }
  110036. interface WebGLBuffer {
  110037. references: number;
  110038. capacity: number;
  110039. is32Bits: boolean;
  110040. }
  110041. interface WebGLProgram {
  110042. transformFeedback?: WebGLTransformFeedback | null;
  110043. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  110044. }
  110045. interface EXT_disjoint_timer_query {
  110046. QUERY_COUNTER_BITS_EXT: number;
  110047. TIME_ELAPSED_EXT: number;
  110048. TIMESTAMP_EXT: number;
  110049. GPU_DISJOINT_EXT: number;
  110050. QUERY_RESULT_EXT: number;
  110051. QUERY_RESULT_AVAILABLE_EXT: number;
  110052. queryCounterEXT(query: WebGLQuery, target: number): void;
  110053. createQueryEXT(): WebGLQuery;
  110054. beginQueryEXT(target: number, query: WebGLQuery): void;
  110055. endQueryEXT(target: number): void;
  110056. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  110057. deleteQueryEXT(query: WebGLQuery): void;
  110058. }
  110059. interface WebGLUniformLocation {
  110060. _currentState: any;
  110061. }
  110062. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  110063. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  110064. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  110065. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110066. interface WebGLRenderingContext {
  110067. readonly RASTERIZER_DISCARD: number;
  110068. readonly DEPTH_COMPONENT24: number;
  110069. readonly TEXTURE_3D: number;
  110070. readonly TEXTURE_2D_ARRAY: number;
  110071. readonly TEXTURE_COMPARE_FUNC: number;
  110072. readonly TEXTURE_COMPARE_MODE: number;
  110073. readonly COMPARE_REF_TO_TEXTURE: number;
  110074. readonly TEXTURE_WRAP_R: number;
  110075. readonly HALF_FLOAT: number;
  110076. readonly RGB8: number;
  110077. readonly RED_INTEGER: number;
  110078. readonly RG_INTEGER: number;
  110079. readonly RGB_INTEGER: number;
  110080. readonly RGBA_INTEGER: number;
  110081. readonly R8_SNORM: number;
  110082. readonly RG8_SNORM: number;
  110083. readonly RGB8_SNORM: number;
  110084. readonly RGBA8_SNORM: number;
  110085. readonly R8I: number;
  110086. readonly RG8I: number;
  110087. readonly RGB8I: number;
  110088. readonly RGBA8I: number;
  110089. readonly R8UI: number;
  110090. readonly RG8UI: number;
  110091. readonly RGB8UI: number;
  110092. readonly RGBA8UI: number;
  110093. readonly R16I: number;
  110094. readonly RG16I: number;
  110095. readonly RGB16I: number;
  110096. readonly RGBA16I: number;
  110097. readonly R16UI: number;
  110098. readonly RG16UI: number;
  110099. readonly RGB16UI: number;
  110100. readonly RGBA16UI: number;
  110101. readonly R32I: number;
  110102. readonly RG32I: number;
  110103. readonly RGB32I: number;
  110104. readonly RGBA32I: number;
  110105. readonly R32UI: number;
  110106. readonly RG32UI: number;
  110107. readonly RGB32UI: number;
  110108. readonly RGBA32UI: number;
  110109. readonly RGB10_A2UI: number;
  110110. readonly R11F_G11F_B10F: number;
  110111. readonly RGB9_E5: number;
  110112. readonly RGB10_A2: number;
  110113. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  110114. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  110115. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  110116. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  110117. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  110118. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  110119. 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;
  110120. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  110121. readonly TRANSFORM_FEEDBACK: number;
  110122. readonly INTERLEAVED_ATTRIBS: number;
  110123. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  110124. createTransformFeedback(): WebGLTransformFeedback;
  110125. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  110126. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  110127. beginTransformFeedback(primitiveMode: number): void;
  110128. endTransformFeedback(): void;
  110129. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  110130. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110131. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110132. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  110133. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  110134. }
  110135. interface ImageBitmap {
  110136. readonly width: number;
  110137. readonly height: number;
  110138. close(): void;
  110139. }
  110140. interface WebGLQuery extends WebGLObject {
  110141. }
  110142. declare var WebGLQuery: {
  110143. prototype: WebGLQuery;
  110144. new(): WebGLQuery;
  110145. };
  110146. interface WebGLSampler extends WebGLObject {
  110147. }
  110148. declare var WebGLSampler: {
  110149. prototype: WebGLSampler;
  110150. new(): WebGLSampler;
  110151. };
  110152. interface WebGLSync extends WebGLObject {
  110153. }
  110154. declare var WebGLSync: {
  110155. prototype: WebGLSync;
  110156. new(): WebGLSync;
  110157. };
  110158. interface WebGLTransformFeedback extends WebGLObject {
  110159. }
  110160. declare var WebGLTransformFeedback: {
  110161. prototype: WebGLTransformFeedback;
  110162. new(): WebGLTransformFeedback;
  110163. };
  110164. interface WebGLVertexArrayObject extends WebGLObject {
  110165. }
  110166. declare var WebGLVertexArrayObject: {
  110167. prototype: WebGLVertexArrayObject;
  110168. new(): WebGLVertexArrayObject;
  110169. };
  110170. // Type definitions for WebVR API
  110171. // Project: https://w3c.github.io/webvr/
  110172. // Definitions by: six a <https://github.com/lostfictions>
  110173. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110174. interface VRDisplay extends EventTarget {
  110175. /**
  110176. * Dictionary of capabilities describing the VRDisplay.
  110177. */
  110178. readonly capabilities: VRDisplayCapabilities;
  110179. /**
  110180. * z-depth defining the far plane of the eye view frustum
  110181. * enables mapping of values in the render target depth
  110182. * attachment to scene coordinates. Initially set to 10000.0.
  110183. */
  110184. depthFar: number;
  110185. /**
  110186. * z-depth defining the near plane of the eye view frustum
  110187. * enables mapping of values in the render target depth
  110188. * attachment to scene coordinates. Initially set to 0.01.
  110189. */
  110190. depthNear: number;
  110191. /**
  110192. * An identifier for this distinct VRDisplay. Used as an
  110193. * association point in the Gamepad API.
  110194. */
  110195. readonly displayId: number;
  110196. /**
  110197. * A display name, a user-readable name identifying it.
  110198. */
  110199. readonly displayName: string;
  110200. readonly isConnected: boolean;
  110201. readonly isPresenting: boolean;
  110202. /**
  110203. * If this VRDisplay supports room-scale experiences, the optional
  110204. * stage attribute contains details on the room-scale parameters.
  110205. */
  110206. readonly stageParameters: VRStageParameters | null;
  110207. /**
  110208. * Passing the value returned by `requestAnimationFrame` to
  110209. * `cancelAnimationFrame` will unregister the callback.
  110210. * @param handle Define the hanle of the request to cancel
  110211. */
  110212. cancelAnimationFrame(handle: number): void;
  110213. /**
  110214. * Stops presenting to the VRDisplay.
  110215. * @returns a promise to know when it stopped
  110216. */
  110217. exitPresent(): Promise<void>;
  110218. /**
  110219. * Return the current VREyeParameters for the given eye.
  110220. * @param whichEye Define the eye we want the parameter for
  110221. * @returns the eye parameters
  110222. */
  110223. getEyeParameters(whichEye: string): VREyeParameters;
  110224. /**
  110225. * Populates the passed VRFrameData with the information required to render
  110226. * the current frame.
  110227. * @param frameData Define the data structure to populate
  110228. * @returns true if ok otherwise false
  110229. */
  110230. getFrameData(frameData: VRFrameData): boolean;
  110231. /**
  110232. * Get the layers currently being presented.
  110233. * @returns the list of VR layers
  110234. */
  110235. getLayers(): VRLayer[];
  110236. /**
  110237. * Return a VRPose containing the future predicted pose of the VRDisplay
  110238. * when the current frame will be presented. The value returned will not
  110239. * change until JavaScript has returned control to the browser.
  110240. *
  110241. * The VRPose will contain the position, orientation, velocity,
  110242. * and acceleration of each of these properties.
  110243. * @returns the pose object
  110244. */
  110245. getPose(): VRPose;
  110246. /**
  110247. * Return the current instantaneous pose of the VRDisplay, with no
  110248. * prediction applied.
  110249. * @returns the current instantaneous pose
  110250. */
  110251. getImmediatePose(): VRPose;
  110252. /**
  110253. * The callback passed to `requestAnimationFrame` will be called
  110254. * any time a new frame should be rendered. When the VRDisplay is
  110255. * presenting the callback will be called at the native refresh
  110256. * rate of the HMD. When not presenting this function acts
  110257. * identically to how window.requestAnimationFrame acts. Content should
  110258. * make no assumptions of frame rate or vsync behavior as the HMD runs
  110259. * asynchronously from other displays and at differing refresh rates.
  110260. * @param callback Define the eaction to run next frame
  110261. * @returns the request handle it
  110262. */
  110263. requestAnimationFrame(callback: FrameRequestCallback): number;
  110264. /**
  110265. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110266. * Repeat calls while already presenting will update the VRLayers being displayed.
  110267. * @param layers Define the list of layer to present
  110268. * @returns a promise to know when the request has been fulfilled
  110269. */
  110270. requestPresent(layers: VRLayer[]): Promise<void>;
  110271. /**
  110272. * Reset the pose for this display, treating its current position and
  110273. * orientation as the "origin/zero" values. VRPose.position,
  110274. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110275. * updated when calling resetPose(). This should be called in only
  110276. * sitting-space experiences.
  110277. */
  110278. resetPose(): void;
  110279. /**
  110280. * The VRLayer provided to the VRDisplay will be captured and presented
  110281. * in the HMD. Calling this function has the same effect on the source
  110282. * canvas as any other operation that uses its source image, and canvases
  110283. * created without preserveDrawingBuffer set to true will be cleared.
  110284. * @param pose Define the pose to submit
  110285. */
  110286. submitFrame(pose?: VRPose): void;
  110287. }
  110288. declare var VRDisplay: {
  110289. prototype: VRDisplay;
  110290. new(): VRDisplay;
  110291. };
  110292. interface VRLayer {
  110293. leftBounds?: number[] | Float32Array | null;
  110294. rightBounds?: number[] | Float32Array | null;
  110295. source?: HTMLCanvasElement | null;
  110296. }
  110297. interface VRDisplayCapabilities {
  110298. readonly canPresent: boolean;
  110299. readonly hasExternalDisplay: boolean;
  110300. readonly hasOrientation: boolean;
  110301. readonly hasPosition: boolean;
  110302. readonly maxLayers: number;
  110303. }
  110304. interface VREyeParameters {
  110305. /** @deprecated */
  110306. readonly fieldOfView: VRFieldOfView;
  110307. readonly offset: Float32Array;
  110308. readonly renderHeight: number;
  110309. readonly renderWidth: number;
  110310. }
  110311. interface VRFieldOfView {
  110312. readonly downDegrees: number;
  110313. readonly leftDegrees: number;
  110314. readonly rightDegrees: number;
  110315. readonly upDegrees: number;
  110316. }
  110317. interface VRFrameData {
  110318. readonly leftProjectionMatrix: Float32Array;
  110319. readonly leftViewMatrix: Float32Array;
  110320. readonly pose: VRPose;
  110321. readonly rightProjectionMatrix: Float32Array;
  110322. readonly rightViewMatrix: Float32Array;
  110323. readonly timestamp: number;
  110324. }
  110325. interface VRPose {
  110326. readonly angularAcceleration: Float32Array | null;
  110327. readonly angularVelocity: Float32Array | null;
  110328. readonly linearAcceleration: Float32Array | null;
  110329. readonly linearVelocity: Float32Array | null;
  110330. readonly orientation: Float32Array | null;
  110331. readonly position: Float32Array | null;
  110332. readonly timestamp: number;
  110333. }
  110334. interface VRStageParameters {
  110335. sittingToStandingTransform?: Float32Array;
  110336. sizeX?: number;
  110337. sizeY?: number;
  110338. }
  110339. interface Navigator {
  110340. getVRDisplays(): Promise<VRDisplay[]>;
  110341. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110342. }
  110343. interface Window {
  110344. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110345. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110346. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110347. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110348. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110349. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110350. }
  110351. interface Gamepad {
  110352. readonly displayId: number;
  110353. }
  110354. interface XRDevice {
  110355. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110356. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110357. }
  110358. interface XRSession {
  110359. getInputSources(): Array<any>;
  110360. baseLayer: XRWebGLLayer;
  110361. requestFrameOfReference(type: string): Promise<void>;
  110362. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110363. end(): Promise<void>;
  110364. requestAnimationFrame: Function;
  110365. addEventListener: Function;
  110366. }
  110367. interface XRSessionCreationOptions {
  110368. outputContext?: WebGLRenderingContext | null;
  110369. immersive?: boolean;
  110370. environmentIntegration?: boolean;
  110371. }
  110372. interface XRLayer {
  110373. getViewport: Function;
  110374. framebufferWidth: number;
  110375. framebufferHeight: number;
  110376. }
  110377. interface XRView {
  110378. projectionMatrix: Float32Array;
  110379. }
  110380. interface XRFrame {
  110381. getDevicePose: Function;
  110382. getInputPose: Function;
  110383. views: Array<XRView>;
  110384. baseLayer: XRLayer;
  110385. }
  110386. interface XRFrameOfReference {
  110387. }
  110388. interface XRWebGLLayer extends XRLayer {
  110389. framebuffer: WebGLFramebuffer;
  110390. }
  110391. declare var XRWebGLLayer: {
  110392. prototype: XRWebGLLayer;
  110393. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110394. };